PacktPublishing/Learn-OpenCV-4-By-Building-Projects-Second-Edition

Chapter_02 sample2.cpp open defalut camera failed

vk8051 opened this issue · 2 comments

VideoCapture cap; // open the default camera
if(videoFile != "")
cap.open(videoFile);
else
cap.open("Recording3.webm"); <<==========Here can not open default camera
if(!cap.isOpened()) // check if we succeeded
return -1;

The correct would be

if(videoFile != "")
   cap.open(videoFile);
else
   cap.open(0);
if(!cap.isOpened()) // check if we succeeded
   return -1;

Fixed in the source code.