0
votes

My development enviroment is Mingw32 bit CMake on Windows 7.(this same code works fine on Linux)

I use cvFindContours() to detect contours using OpenCV.

I use recursive method to traveser the resultant CvSeq to access the contours by level as follows:

void helperParseCurves(CvSeq* contour, int level) {


    //Travel same level contours
    if(contour->h_next != NULL) {
        helperParseCurves(contour->h_next, level);
    }
    if(contour->v_next != NULL) {
        helperParseCurves(contour->v_next, level+1);
    }
    //Travel child levels
    for(int i=0; i<contour->total; i++){

        //Try to access Point data -- Crash here when threshold level 114 ?
        //Works when uncommented
        CvPoint* p = CV_GET_SEQ_ELEM(CvPoint, contour, i);

    }
}

But the application crashes at the line CvPoint* p = CV_GET_SEQ_ELEM(CvPoint, contour, i); This happens to some specific large images and works fine in Linux.

I have uploaded an sample program to demonstrate the scenario at

http://dl.dropbox.com/u/17399055/opencv-test.zip

*download and compile using CMake

*run the code using the sample image - "OCvTest.exe test-img.tif"

*change the slider value around 114 , application crashes.

*if the line #27 is commented works fine.

Any tips on this ?

Could this be a OpenCV bug ?

thanks in advance.

1

1 Answers

0
votes

I realized that this happens due to the recursive function.Once I made it an iterative one ,everything worked fine. Now I know why recursive functions are bad...didnt really "practically" understood that before..