OpenCV grab does nothing on webcam

后端 未结 2 936
猫巷女王i
猫巷女王i 2021-01-25 06:11

I\'ve been trying to simultaneously grab frames from two different cameras, but no matter how many times I call VideoCapture::grab(), there seems to be no effect. The frame retr

2条回答
  •  醉话见心
    2021-01-25 07:04

    I ran my test and note very strange behavior of .garab and .retrive functions. This is example:

    cv::Mat input = cv::Mat(512, 512, CV_8UC1, cv::Scalar(0));
    cv::VideoCapture cap(0);
    
    while (true)
    {
        cap.grab();
        cap.retrieve(input, 5);
        cv::imshow("input", input);
        cv::waitKey(0);
    }
    

    If you press any key slowly, about every 5 seconds, and change something in front of the camera between pressing, the position of the object on the image will change every second image showing, that is, every second call of the .grab and .retrive functions.

    If you press any key quickly, about every 1 seconds, and also change something in front of the camera between pressing, the position of the object on the image will be changed every image showing.

    This circumstance tell about that this function can be used to sync cameras.

提交回复
热议问题