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.