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

Learn OpenCV 4 By Building Projects, Second Edition, published by Packt
MIT License
383 stars 191 forks source link

Chapter_02 sample2.cpp open defalut camera failed #6

Closed vk8051 closed 4 years ago

vk8051 commented 4 years ago

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;

ViniGodoy commented 4 years ago

The correct would be

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

Fixed in the source code.