OpenCV C++ Video Capture does not seem to work

前端 未结 5 777
北荒
北荒 2020-12-18 14:34

I am using a Mac OS X 10.6 machine. I have OpenCV 2.1 x64 compiled from source using Xcode and its GCC compiler.

I am having trouble using the C++ video reading feat

5条回答
  •  情书的邮戳
    2020-12-18 15:18

    Try simplifying the program so that you can identify the exact location of the problem, e.g. change your loop so that it looks like this:

    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
    //  cvtColor(frame, edges, CV_BGR2GRAY);
    //  GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
    //  Canny(edges, edges, 0, 30, 3);
    //  imshow("edges", edges);
        imshow("edges", frame);
        if(waitKey(200) >= 0) break;
    }
    

    If that works OK then try adding the processing calls back in, one at a time, e.g

    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);
    //  GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
    //  Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if(waitKey(200) >= 0) break;
    }
    

    and so on...

    Once you've identified the problematic line you can then focus on that and investigate further.

提交回复
热议问题