opencv: OpenCV 3.2 + Python 3.6.1: imshow() not worked even with waitKey(0)

System information (version)
  • OpenCV => 3.2
  • Operating System / Platform => MacOS Sierra 10.12.5
  • Compiler => Terminal

I followed the documentation with:

import cv2
import numpy as np

img = cv2.imread('1.jpg')
print(img)
cv2.imshow('Image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

But I got empty content window:

Image

Is this related to OpenCV?

For readability I posted this question to stackoverflow: https://stackoverflow.com/q/44469973/7813604

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Same problem, attacked in multiple ways, all failed.

  • macOS 10.12.5
  • trial#1, 2: built from source
    • using both py35 and py36
  • trial#3 installed using: conda install -c menpo opencv3 in virtual env for py35
  • tested against several images e.g., img = cv2.imread(‘tmp.png’,0); cv2.imshow(‘test’,img);cv2.waitKey(0)

In every case, once cv2.imshow() in invoked, I get the window title bar but an empty window

Just to make clear: despite the odd grammar in the title of this issue, and some problems with the info given about it, it is a perfectly legitimate OpenCV issue to raise. Several of us are finding runtime window display errors with various versions of cv2 running on recent incarnations of MacOS. Via Python and C++ examples. Compilations give no indication whatsoever of a problem.

Note also that cv2 works fine, as far as my testing shows, as long as no cv2 display commands are invoked. For example cv2.imread() works, and display of the resulting image through matplotlib also.