简体   繁体   中英

opencv build failed with xcode

I have a problem with a webcam capturing in opencv.

This can be built successfully:

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
using namespace cv;

int main() {
//    VideoCapture cap(0);
//    while(true){
//        Mat Webcam;
//        cap.read(Webcam);
//        imshow("Webcam", Webcam);
//    }
}

However, this is not:

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
using namespace cv;

int main() {
    VideoCapture cap(0);
    while(true){
        Mat Webcam;
        cap.read(Webcam);
        imshow("Webcam", Webcam);
    }
}

There is no error or warning message popped out, so I can't solve it by myself.

Any idea is appreciated!

Updates:

Error message

It seems something went wrong when I updated xcode.....

Error message 2

Your code is perfectly ok except following line after imshow:

waitKey(10);

It will provide ui thread to draw the frames. Without this delay ui thread can not be updated or get time slice from cpu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM