Ask Your Question
1

Release resources in openCV

asked 2013-06-12 08:12:37 -0600

igormat gravatar image

Hello everyone. I started learn openCV and have one important for me question. I use code like this:

CvMemStorage* storage = cvCreateMemStorage(0); CvSeq* contours=0; int contoursCont = cvFindContours( bin, storage,&contours,sizeof(CvContour),CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE,cvPoint(0,0));

Do I need to free storage? How I can do this correctly? What API I need to use? Sorry for stupid question but I can't find it in manual.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-06-12 09:01:32 -0600

Ben gravatar image

Yes, you have to free memory using cvReleaseMemStorage().

But as you are learning OpenCV, I strongly recommend using the C++ API. It is easier to understand, easier to use and much easier to avoid memory leaks with it, because you don't have to release memory yourself. The C++ API used to be a wrapper around C core functions and was slower. But there are more and more functions using a C++ core with a C wrapper function. So unless you don't really need high performance for special functions still having a C core, there is almost no reason using the C API.

The corresponding function to the one used in your code above would be findContours()

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-12 08:12:37 -0600

Seen: 1,325 times

Last updated: Jun 12 '13