Ask Your Question
1

cvReleaseImage throws exception

asked 2013-05-31 09:29:28 -0600

Marian gravatar image

I created an image by capturing camera simple:

IplImage *img;
CvCapture *capture = cvCreateCameraCapture(0);
CvSize size = cvSize(1920, 1080);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH , size.width);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT , size.height);
img = cvQueryFrame(capture);
cvNamedWindow("VideoTest", CV_WINDOW_AUTOSIZE);
cvShowImage("VideoTest", img);
cvReleaseImage(&img);

The problem is cvReleaseImage throws a memory exception. It cannot deallocate memory for image. How can I fix it?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-05-31 10:03:56 -0600

berak gravatar image

updated 2013-05-31 10:08:33 -0600

yes, you should cvReleaseImage() all images you create,

but the image you get from the videocapture is the one exception to that rule. ( it hasn't got own memory, but uses mem inside the driver ) so don't release that!

edit flag offensive delete link more

Comments

1

Or just switch to the C++ openCV2.0 API and stop worrying about allocating and releasing memory yourself :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-05-31 12:50:52 -0600 )edit
0

answered 2013-05-31 10:10:33 -0600

Prasanna gravatar image

Hey there Marian,

I am not able to reproduce your error on my computer. Can you please post your error details? It would be helpful to debug.

Regards, Prasanna S

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-05-31 09:29:28 -0600

Seen: 1,467 times

Last updated: May 31 '13