I'm literally just starting out, but already stuck .. I'm trying to get an image to display, but imshow()
only opens an empty window. I don't get any errors, and the program doesn't hang (pressing a key closes the window just fine) - it's just that there is no image in the window.
I know that the image is loaded correctly, because I'm printing out the arrays and image data looks right. Also I can see that the window always has the correct _measurements_ for whichever image file I'm picking.
import numpy as np
import cv2
img = cv2.imread('butterfly.jpg', 0)
print(img)
cv2.imshow('Butterfly', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Things I have tried (to no avail):
- using an absolute path instead
- adding
cv2.startWindowThread(); cv2.namedWindow('Butterfly')
before theimshow()
command - reading lots of posts with similar problems
I'm using Python3.6, on macOS (Mojave), cv2 v.4.0.1
Any ideas what I might be doing wrong?