Ask Your Question

Assertion failed window_w32.cpp OpenCV-4.0.0

asked 2018-12-22 03:37:45 -0600

WolfG gravatar image

updated 2020-11-05 14:58:03 -0600


I'm new here and say hello to all!

From // I've downloaded the C++ source and compiled it with OpenCV-4.0.0 w/o errors.

I run the program with 2 input files: image.bmp and a template.bmp containing an existing crop (60x60) of image.bmp. The program fails with error OpenCV: terminate handler is called! The last OpenCV error is: OpenCV(4.0.0) Error: Assertion failed ( == (uchar*)dst_ptr) in cvShowImage, file C:\OpenCV\source\modules\highgui\src\window_w32.cpp, line 1230

Any hints whats going wrong?

Thanks for reading


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-12-22 04:00:41 -0600

berak gravatar image

updated 2018-12-22 10:26:12 -0600

that's an internal bug. (imshow can only handle uchar images in the version you have)

please download the latest opencv master branch and rebuild again, in the meantime, convert your image manually:

img.convertTo(img, CV_8U, 255); //for float images
imshow("I", img);


the conversion factor ofc. has to be 255 to go from float -> uchar, but 1.0/255 when coming from ushort.

edit flag offensive delete link more



@berak do you know how to retag opencv 4.4.0 in opencv4.0.0?

LBerger gravatar imageLBerger ( 2018-12-22 04:04:08 -0600 )edit

^^ done. (there's a "retag" button under the question for this) (but you have to be quick, and be done, before the "auto-fill something" comes up with silly proposals there, like hashtags ....

berak gravatar imageberak ( 2018-12-22 04:12:06 -0600 )edit

webpage was probably cached in the browser, so you did not see the effect

(oh, and sorry, i removed the wrong comment...)

berak gravatar imageberak ( 2018-12-22 04:15:00 -0600 )edit

Question Tools

1 follower


Asked: 2018-12-22 03:37:45 -0600

Seen: 1,437 times

Last updated: Dec 22 '18