开发者

cvHoughLines2 memory leak

开发者 https://www.devze.com 2023-03-02 09:51 出处:网络
Does OpenCV method HoughLines2 has a memory leak that\'s not been fixed since now (version 2.1.0.6), or there\'s something wrong with this part of my code ?

Does OpenCV method HoughLines2 has a memory leak that's not been fixed since now (version 2.1.0.6), or there's something wrong with this part of my code ?

CvMemStorage *storage = cvCreateMemStorage(0);
CvSeq *linesSeq = 0;
double smallL = 0.0, bigL=0.0, smallA = 0.0, bigA = 0.0;
linesSeq = cvHoughLines2(cannyImg, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180.0, 30, 50, 15);
for( int i = 0;i < linesSeq->total; i++ ){
    CvPoint* line = (CvPoint*)cvGetSeqElem(linesSeq,i);
    double sz = sqrt((line[0].x- line[1].x) *(line[0].x- line[1].x) + (line[0].y -line[1].y)*(line[0].y-line[1].y));
    if(sz < 70.0 ) smallL+=1.0;
    else bigL +=1.0;

    double deltaY = line[1].y - line[0].y;
    double deltaX = line[1].x - line[0].x;
    double angle;
    if ( abs(deltaX) > 1e-7){
        angle = atan2(deltaY, deltaX);

        if (an开发者_开发知识库gle < 0.1) smallA+=1.0;
        else bigA+=1.0;
    }else{

    }
 }

cvClearMemStorage(storage);
cvClearSeq(linesSeq);
cvReleaseImage(&cannyImg);

Thank you


You are using cvClearMemStorage. This does not deallocate memory, it just resets some pointers. If you want to release the memory, you should use cvReleaseMemStorage(&storage) (and you wouldn't need cvClearSeq anymore, by the way, since you would deallocate memory).

0

精彩评论

暂无评论...
验证码 换一张
取 消