Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV's waitKey() alternative in IPython Notebook

I'm trying to show images with cv2 library in my Jupiter Notebook with cv2.imshow(img) and it shows as expected, but I can not use or don't know how to use cv2.waitKey(0), hence the cell will not stop executing.

cv2.waitKey(0) works in script, but not in Notebook.

Here's a snippet:

cv2.imshow('Image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

How do I stop executing cell without restarting the whole kernel?

like image 663
primoz Avatar asked Sep 30 '15 08:09

primoz


1 Answers

So, thanks to @Micka, here's the solution:

You must write cv2.startWindowThread() first, explained here.

like image 68
primoz Avatar answered Sep 25 '22 09:09

primoz