Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::threshold crash

I hope I'm doing something idiotic and there is a simple fix for this but, every time I try to take a threshold on an image it crashes.

I'm trying to do simple background subtraction and then take a threshold on the resultant image (to later use as a mask). Here is the relevant code:

src.convertTo(src, CV_8UC1, 1.0/256.0, 0);

if(firstFrame) { 
    firstFrame = false;
cv::addWeighted(src, .001, background , .999, 0, background);
cv::absdiff(src, background, difference);
cv::threshold(difference, thresh, 100, 1, cv::THRESH_BINARY);

src, background,difference, and thresh are all created as cv::Mat In the header.

The code crashes on the last like when I try the call to cv::theshold. I can call imshow on src, background, and difference and they all look reasonable.

I'm using OpenCV 2.4.5 under c++ using VS2010.

Any help or suggestions would be appreciated.