原理:通过opencv中的waitKey来实现
示例代码:
def key_control():
while 1:
cv2.imshow('tmp', np.zeros(shape=(100, 100, 3), dtype=np.uint8))
key = cv2.waitKey(1)
if key == ord('w'):
print("w")
elif key == ord('s'):
print("s")
elif key == ord('a'):
print("a")
elif key == ord('d'):
print("d")
elif key == ord(' '):
break
cv2.destroyAllWindows()
标签:字符,elif,读取,python,cv2,np,key,print,ord
From: https://www.cnblogs.com/hnu-hua/p/17539129.html