OpenCV IPLImage Not getting recycled

200 Views Asked by At

Im trying to use cvBlob to do some processing but I noticed its using all of the RAM and i noticd this

IplImage* image2=cvCloneImage(&(IplImage)thresh);
IplImage *labelImg=cvCreateImage(cvGetSize(image2), IPL_DEPTH_LABEL, 1);
cvb::CvBlobs blobs;
unsigned int result=cvLabel(image2, labelImg, blobs);
cvb::cvRenderBlobs(labelImg, blobs, image2, image2);

for (cvb::CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it)
{
    drawObject(it->second->centroid.x, it->second->centroid.y,camera);
    drawLines(
        it->second->minx,
        it->second->maxx,
        it->second->minx,
        it->second->maxx,
        it->second->miny,
        it->second->miny,
        it->second->maxy,
        it->second->maxy,
        camera);
} 
thresh = Mat(image2);

the initial two calls that create IPLImages, they're leaking about 1mb worth of memory. Every iteration, the memory used by my exe increases by 2mb. If i comment those lines out, it keeps steady.

tldr; how do i recycle IPLImages

1

There are 1 best solutions below

0
On
cvReleaseImage(&image2);
cvReleaseImage(&labelImg);
cvReleaseBlobs(blobs);