OpenCV waitKey 无法正常捕捉方向键(上下左右),总结和解决方案,可以用waitKeyEx


 在win10+python+opencv3.4.5,测试

while True:
    key = cv2.waitKey(0)
    print('key =', key)

依次按上、下、左、右方向键,输出:

key = 0
key = 0
key = 0
key = 0

 

测试代码:

while True:
    key = cv2.waitKeyEx(0)
    print('key =', key)

依次按上、下、左、右方向键,输出:

key = 2490368
key = 2621440
key = 2424832
key = 2555904

 

官方说,waitKeyEx和waitKey类似,Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM