Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

first, please use cv::VideoCapture (c++), not the deprecated c-api calls.

then, you can try to set properties on the capture, like CAP_MODE_YUVY but none of them are guaranteed to succed., it all depends on your os / hardware / driver mix.

#include "opencv2/opencv.hpp"
using namespace cv;

#include <iostream>
using namespace std;

int main()
{
    VideoCapture cap(0);

    bool ok = cap.set(CAP_PROP_CONVERT_RGB, 0);
    cerr << ok << endl;


    while(cap.isOpened())
    {
        Mat f;
        cap >> f;
        if (f.empty())
        {
            cerr << "."; // older webcams might need some "warmup" ..
            continue;
        }
        imshow("ocv",f);
        if (waitKey(10)==27) break;
    }
}