本文整理匯總了Python中cv2.waitKeyEx方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.waitKeyEx方法的具體用法?Python cv2.waitKeyEx怎麽用?Python cv2.waitKeyEx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cv2
的用法示例。
在下文中一共展示了cv2.waitKeyEx方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_process_messages
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import waitKeyEx [as 別名]
def on_process_messages(self, sleep_time=0):
has_windows = False
has_capture_keys = False
if len(self.named_windows) != 0:
has_windows = True
if len(self.capture_keys_windows) != 0:
has_capture_keys = True
if has_windows or has_capture_keys:
wait_key_time = max(1, int(sleep_time*1000) )
ord_key = cv2.waitKeyEx(wait_key_time)
shift_pressed = False
if ord_key != -1:
chr_key = chr(ord_key) if ord_key <= 255 else chr(0)
if chr_key >= 'A' and chr_key <= 'Z':
shift_pressed = True
ord_key += 32
elif chr_key == '?':
shift_pressed = True
ord_key = ord('/')
elif chr_key == '<':
shift_pressed = True
ord_key = ord(',')
elif chr_key == '>':
shift_pressed = True
ord_key = ord('.')
else:
if sleep_time != 0:
time.sleep(sleep_time)
if has_capture_keys and ord_key != -1:
self.add_key_event ( self.focus_wnd_name, ord_key, False, False, shift_pressed)