Reputation:
I have 64bit, ubuntu system. Im running the code in idel. I was facing opencv hang issue , the image shows up but I have to force kill the image window. So reffered to this thread -- Using other keys for the waitKey() function of opencv
import cv2
img = cv2.imread('sof.jpg') # load a dummy image
while(1):
cv2.imshow('img',img)
k = cv2.waitKey(3000) & 0xff
if k==32: # SpaceBar key to stop
break
elif k==-1: # normally -1 returned,so don't print it
continue
else:
print k # else print its value
Still its not working image hangs and I have to close it manually.
Upvotes: 0
Views: 2933
Reputation: 101
Add cv2.waitkey(0) and cv2.destroyallwindows() but If you have used python notebooks then there is a problem in Unix based system to run a program of opencv. It will cause system freeze so you will need to restart kernel everytime when you try to execute code.
I have an alternative method which would prevent from freezing your system
Steps:
This will run code directly from terminal. Hope this helps you. Example Link: https://youtu.be/8O-FW4Wm10s
Upvotes: 0