iOS VideoCapture cap(0); Code will never be executed
I am trying to capture my computer webcam image using Xcode. Here my code: // // main.cpp // OpevCVTest1
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/video/video.hpp"
using namespace cv;
int main(int argc, const char * argv[]) {
std::cout << "OpenCV Version" << CV_VERSION << std::endl;
return 0;
VideoCapture cap(0); - Error message “code will never be executed” semantic issue
cap.open(0);
if (!cap.isOpened()) {
std::cout << "Unable to read stream from specified device." << std::endl;
}
while (true)
{
// retrieve the frame:
Mat frame;
if (!cap.read(frame)) {
std::cout << "Unable to retrieve frame from video stream." << std::endl;
break;
}
// display it:
imshow("MyVideo", frame);
// check if Esc has been pressed:
if (waitKey(1) == 27) {
break;
}
// else continue:
}
cap.release();
}
I dont't understand why you write return 0 three lines after main