Ask Your Question
0

returning captured frame

asked 2013-10-02 21:17:56 -0600

updated 2013-10-03 01:28:46 -0600

Moster gravatar image

I am trying to create this function

void videoHandler::getNextFrame(Mat& frame){

vf* tempFrame=new vf();
VideoCapture capture;
capture.open(0);
capture.set(CV_CAP_PROP_FRAME_WIDTH,640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,480);
capture.read(frame);}

but as the compilers exits and the Mat pointer is accessed I get an access violation error as if the frame info was destroyed. I tried using

tempFrame->setImage(frame);

which sets the image and It only works when I use copyto() or clone() functions but slows down the compilation alot. I tried return frame; static declarations; so unless a copy is made the frame is lost when the compiler goes out of scope. any suggestions for an alternative or better way to do it.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-10-03 01:19:25 -0600

Michael Burdinov gravatar image

Documentation of VideoCapture has very simple and very informative example of reading frames from camera. Just do the same and everything will work properly.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-10-02 21:17:56 -0600

Seen: 125 times

Last updated: Oct 03 '13