iOS VideoCapture cap(0); Code will never be executed

asked 2015-07-09 12:03:08 -0600

updated 2015-07-09 12:09:43 -0600

LBerger gravatar image

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();



    }
edit retag flag offensive close merge delete

Comments

2

I dont't understand why you write return 0 three lines after main

LBerger gravatar imageLBerger ( 2015-07-09 12:11:34 -0600 )edit