Ask Your Question

Read frame by frame VC++

asked 2014-05-24 20:55:02 -0500

vbopencv gravatar image

updated 2014-05-25 19:52:09 -0500

How do read a particular frame from a capute file

Current Code:

cvSetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES, trackBar2); // set to value of trackBar
frame =  cvQueryFrame(capture); 
label8->Text = "Frame No.: " + (int)cvGetCaptureProperty(capture,CV_CAP_PROP_POS_FRAMES) + " trackBar2->value: " + trackBar2->Value ;

It seems the (int(cvGetCaptureProperty(capture, CV_CAP_PROP_POS_Frames) doesn't give the next or prior frame when I adjust the trackBar2 which step back or forward by 1. It seems the trackBar2-Value increment correctly by 1 or -1 (depending on the scroll) but the CV_CAP_PROP_POS_Frames a random value.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-05-25 04:09:33 -0500

berak gravatar image

hi vbopencv, please use the c++ api in the 'next' version of your code ;)

cv::VideoCapture cap(some_stream);

if (!cap.isOpened())  // check if we succeeded
    cerr << "Can't open Capture" << endl;

double pos = cap.get(CV_CAP_PROP_POS_FRAMES);
bool ok = cap.set(CV_CAP_PROP_PROP_POS_FRAMES, pos); // please check return value..

then, not all properties might be supported by your capture/device or the src you're using.

i.e you can't cue the stream from a webcam, also some video formats don't support that.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2014-05-24 20:55:02 -0500

Seen: 77 times

Last updated: May 25 '14