Ask Your Question
0

Read frame by frame VC++

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

vbopencv gravatar image

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

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
1

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

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

Question Tools

Stats

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

Seen: 216 times

Last updated: May 25 '14