Ask Your Question
0

Images captured from webcam are cropped

asked 2014-05-27 09:23:30 -0600

Hi there, iḿ using OpenCv 2.4.8 trying to capture video from my webcam. The problem it's that sometimes I get a cropped like this: imageCropped Image.

This the code i 'm using:

void CaptureThread::run(){
this->activo=true;
cap = new VideoCapture(0);
cap->set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap->set(CV_CAP_PROP_FRAME_HEIGHT, 480);

while(this->activo){
    QThread::msleep(10);
    Mat frame;
    cap->operator >>(frame);
    if( frame.empty() ){
        continue;
    }
    this->visor->setImage(frame);
    frame.release();
}

}

And every time I run the app i get this message:

HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP

HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP

Thanks, for you help. AM

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-05-29 09:24:28 -0600

I was releasing the frame before finishing to process the image, as i'm using a thread to process the image i was doing this:

this->visor->setImage(frame); //image processing
frame.release();

But now, just to solve quickly, I decided to sleep before releasing:

this->visor->setImage(frame);
QThread::msleep(50);//give sometime to process the image
frame.release();

Sure a mutex or some other multithreading mechanism for synchronization would be better than just waiting but this is not a serious work. Regards, AM.

edit flag offensive delete link more

Comments

you don't even have to call release() manually.

berak gravatar imageberak ( 2014-05-29 09:26:05 -0600 )edit

Question Tools

Stats

Asked: 2014-05-27 09:23:30 -0600

Seen: 364 times

Last updated: May 29 '14