Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV Error: Assertion failed (size and height = 0) in imshow following adaptiveThreshold.

This is a weird one.

adaptiveThreshold(src_grn, scratch, max_BINARY_value, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 3, weight); imshow(output_window_name2, scratch);

gives 'unhandled exception' in debug mode, with the second line being indicated as the next to execute after the break. In release mode, the command line shows:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, fi le C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\highgui\src\windo w.cpp, line 266

with the same input file.

src_grn is an image of CV_8UC1 type (green channel extracted from an RGB image with mixChannels earlier). Mat scratch is declared earlier but not initialized to any particular size or type.

If I continue instead of breaking after the exception it looks like the top 1/3 of the image gets filtered. Commenting out the imshow prevents the error (not that that is helpful).

Putting the imshow back in and setting the window to autosize spits out: image description

(sorry for the screen grab, it won't let me copy the text) something about 'Bad flag' in core\src\array.cpp, line 2489.

Commenting the adaptiveThreshold line gives my source image back again, displayed normally.

This is OpenCV3.0 under VS13 express.

Ideas?