cv2.imshow() doesn't work correctly without a named window (Bug #2146)

Added by Gareth Webber about 5 years ago. Updated almost 2 years ago.

Status:Open Start date:2012-07-06
Priority:Normal Due date:
Assignee:- % Done:


Target version:Next Hackathon
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:



I'm using opencv 2.4.2, python 2.7 and installed the bindings from here

The following code created a window of the correct size, but its contents is just blank (grey):

img = cv2.imread(r'D:\opencv\samples\c\box.png')
#cv2.namedWindow("gray", 1)
cv2.imshow("gray", img)

It only works as expected with a named window being created first, which was not the case in previous versions. This stops certain samples from working for me as well, such as


Updated by Andrey Kamaev almost 5 years ago

  • Category changed from highgui-images to highgui-gui

Updated by Vadim Pisarevsky almost 5 years ago

  • Target version deleted ()
  • Assignee deleted (Vadim Pisarevsky)

Updated by Kirill Kornyakov over 4 years ago

  • Target version set to Next Hackathon

Updated by Emily Dunham about 4 years ago

Tested this and found that it does not happen with the latest OpenCV installed from source on Linux, but is still a problem in Windows 7 with the closest version (opencv 2.4.5) from the site linked in the description.

Updated by Maksim Shabunin almost 2 years ago

Issue has been transferred to GitHub:

Also available in: Atom PDF