Getting codes of pressed keys. From http://stackoverflow.com/questions/14494101/using-other-keys-for-the-waitkey-function-of-opencv
while(1):
k = cv2.waitKey(33) & 0xFF
if k==27: # Esc key to stop
break
elif k==-1: # normally -1 returned,so don't print it
continue
else:
print k # else print its value