Ask Your Question
0

cap.set property is not working in C++

asked 2016-06-21 08:19:08 -0600

Cemow gravatar image

While cap.get property is working, I used cap.set property in a simple code but it doesn't seem to be working:

cap.set(CV_CAP_PROP_FPS, 60);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 360.0);

for(;;)
{
    cap >> frame;
    if( frame.empty() ) break; // end of video stream
    imshow("Display Window",frame);

    if( waitKey(1) == 27 ) break; // stop capturing by pressing ESC
}
waitKey();
return 0;

Any ideas, am I missing something here?

Thanks.

edit retag flag offensive close merge delete

Comments

1

What does it mean "doesn't seem to be working"? What is cap?

LBerger gravatar imageLBerger ( 2016-06-21 09:45:31 -0600 )edit
1

What OS are you using? A possible solution on Linux would be to install the libv4l-dev (video for linux development) package and rebuild OpenCV.

kbarni gravatar imagekbarni ( 2016-06-21 10:43:12 -0600 )edit

@LBerger it does not work, I mean it doesn't change, the "set" property doesn't change anything. "cap" is Videocapture class variable.

@kbarni, I am using ubuntu 14.04. libv4l-dev is already installed.

Cemow gravatar imageCemow ( 2016-06-22 01:30:53 -0600 )edit
1

When you open cap is it a camera or a video file?

LBerger gravatar imageLBerger ( 2016-06-22 01:51:00 -0600 )edit

@LBerger it is camera.

Cemow gravatar imageCemow ( 2016-06-22 02:19:08 -0600 )edit
1

@Cemow Maybe your camera doesn't support 60 fps, or that the frame height must be set before the fps. I know for sure that, in opencv code, frame width/height and fps are set in a special order. Maybe by swapping both lines it would work.

Also, did you check that your camera supports 60 fps ? You could verify it by installing v4l2-ctl and then doing v4l2-ctl -d /dev/video0 --list-formats-ext (change /dev/video0 by your camera of course). It lists all the available size and their framerate !

Major Squirrel gravatar imageMajor Squirrel ( 2016-06-22 03:29:55 -0600 )edit
1

What does it mean 60fps? If your camera have got some automatic adjustement you can have time exposure 0.02s so it's impossible to have 60fps. many camera works like a digital lens reflex camera : speed priority aperture priority or automatic. If you have camera like this one manual adjustement is possible...

LBerger gravatar imageLBerger ( 2016-06-22 04:28:32 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-22 05:52:02 -0600

Cemow gravatar image

I solved the problem as @Major Squirrel mentioned I checked the cameras fps properties with v4l2-ctl and got it that it has only 30 fps in all formats. Also as I saw from v4l2-ctl I tried to use one of the particular camera dimensions and it worked well.

Thank you very much to all of you, @kbarni, @LBerger, @Major Squirrel

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-21 08:17:27 -0600

Seen: 2,944 times

Last updated: Jun 21 '16