First time here? Check out the FAQ!

Ask Your Question
1

Release resources in openCV

asked Jun 12 '13

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.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Jun 12 '13

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()

Preview: (hide)

Question Tools

Stats

Asked: Jun 12 '13

Seen: 1,353 times

Last updated: Jun 12 '13