Ask Your Question
0

cv2.imshow freezes after trying to close it on MacOs

asked 2019-11-04 21:03:37 -0600

updated 2019-11-05 01:00:35 -0600

berak gravatar image

Hi, I am currently using anaconda python 3.7 on macOS Mojave 10.14.6. Here is the code that I use. When I try to close it down (by clicking any key), it freezes. In the window, there's also no "close window" button like in the picture below.

import cv2

image = cv2.imread('./captured_images/frame20.jpg')

cv2.imshow('First frame', image)

cv2.waitKey()

cv2.destroyAllWindows()

image description

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2019-11-05 11:38:41 -0600

supra56 gravatar image

Try this:

import cv2

image = cv2.imread('./captured_images/frame20.jpg')
cv2.imshow('First frame', image)

while True:
    key = cv2.waitKey(0)
    if key in [27, ord('q'), ord('Q')]:
        cv2.destroyAllWindows()
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-11-04 21:03:37 -0600

Seen: 4,826 times

Last updated: Nov 05 '19