Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Crash when deallocating HoughLines (OCV2.4.9)

I am consistently seeing a crash after calling HoughLines or HoughLinesP. Oddly enough the crash is not happening inside those functions, but whenever the lines vector is being deallocated. (Moving the lines vector to global scope means the crash will happen later.) If I just push my own Vec4i items into the vector it works. If I do not call HoughLines/P it works too. But with HoughLines/P I get a crash / dbgheap error on Windows (using Visual Studio 2010/2013).

What might be causing this ?

// discard color
cvtColor(*pImg, *pImg, CV_RGBA2GRAY);
// turn into black/white with threshold
Rect bounds(100,100,400,400);
Mat center(*pImg, bounds);
threshold(center, center, 80, 255, THRESH_BINARY);
Canny(center, center, 50, 200, 3);
{
    std::vector<cv::Vec4i> lines;
    if (!pImg->empty()) {       
        const int MIN_LENGTH = 180;
        HoughLinesP(center, lines, 1, CV_PI / 180,
            80, MIN_LENGTH, 30);
    }
    // Still okay..
}
// This is where things go bad..