Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

the VideoCapture::set method does not guarantee anything, so change the code and see what happens

#include <opencv2/objdetect/objdetect.hpp>
...

int main( )
{
    cout <<"Start main"<<endl;
    VideoCapture cap; // open the default camera
    if(cap.open(0)) {
       cap.set(CV_CAP_PROP_FRAME_WIDTH , 640);
       cap.set(CV_CAP_PROP_FRAME_HEIGHT ,480);

       if((int)cap.get(CV_CAP_PROP_FRAME_WIDTH) != 640
           || (int)cap.get(CV_CAP_PROP_FRAME_HEIGHT) != 480)
            std::cout << "Warning! Can not adjust video capture properties!" << std::endl;

       Mat meter_image;
       if(cap.read(meter_image)) {
            imwrite("/card/imgs.jpg", meter_image);
            cap.release();
            return 0;
       } else {
           cap.release();
           return -1; // can not read frame
       }
    } else {
         return -2; // can not open video capture device
    }
}