1

a simple task simply does not work. Nothing on SO helps (e.g. this).

>>> import cv2
>>> img = cv2.imread("clouds.jpg")
>>> img
    array([[[103,  75,  64],
            [108,  80,  69],
            [100,  72,  61],
             ..., 
            [ 88,  69,  62],
            [ 79,  60,  47],
            [ 75,  52,  37]]], dtype=uint8)
>>> cv2.imshow('window title', img)
>>> cv2.waitKey(1) # or 0, 10, 100, ...

Picture of non working window

Any idea what I'm missing? Thank you very much in advance.

Boern
  • 7,233
  • 5
  • 55
  • 86
  • 1
    This is the third question this week with the exact same problem (haven't seen an answer, although a reinstall did work for someone else). What version of Numpy do you have installed? Edit: wait, did you install through `pip` with `opencv-python`? – alkasm Jun 21 '17 at 21:51
  • 2
    `waitKey(1)` just waits for 1 millisecond, too short too see anything. You may want to wait more or until keypressed `waitKey(0)`. Another thing, is your image just 3 pixel wide? – Quang Hoang Jun 22 '17 at 02:47
  • Thank you guys. To install, i followed http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/ guide. As far as i can remember, there was never a `pip install opencv-python` command. But I'm able to import and run `cv2.__version__` - so I don't think that is the issue? To get the binaries I used http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/ guide in addition. `waitKey(0)` does not make any difference. I tried that out already... – Boern Jun 22 '17 at 06:14
  • 1
    As the other user mentioned, is the image supposed to be only three pixels wide? Because the output of `img` shows only three pixels in width. And that's a good guide to follow---don't install with `pip` as you're guaranteed to not have any `imshow` functionality. You might have good luck asking the author btw. FWIW I have it working with your same OS, Python version, and OpenCV version from following his *other* guide, where you build the binaries, so don't give up yet! It's possible! – alkasm Jun 22 '17 at 13:36
  • Thanks for pointing me to his blog again. Image is 512 × 384, I just reduced the console output. I also followed his other guide where you build the binaries. Something seems to be messed up. Seems to be something with the current `HEAD` version - I'll keep you posted. – Boern Jun 22 '17 at 15:00

0 Answers0