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