cv2.waitKey()
# function store 'key' that you press during output windows open,
# also wait for certain amount of time
#if yoy press 'q' then cv2.waitKey(1) replace with ASCII value which is 113
if cv2.waitKey(1000) & 0xFF == ord('q'): # wait for 1000 millisecond
break
# now your code will look like this
if 113 & 0xFF == ord('q'):
break
if cv2.waitKey(1) & 0xFF == ord('q'): # wait for 1 millisecond
break
import numpy as np
import cv2
im = np.zeros((100, 300), np.uint8)
cv2.imshow('Keypressed', im)
while True:
key = cv2.waitKey(0)
im_c = im.copy()
cv2.putText(
im_c,
f'{chr(key)} -> {key}',
(10, 60),
cv2.FONT_HERSHEY_SIMPLEX,
1,
(255,255,255),
2)
cv2.imshow('Keypressed', im_c)
if key == 27: break # 'ESC'
cv2.waitKey()
# function store 'key' that you press during output windows open,
# also wait for certain amount of time
#if yoy press 'q' then cv2.waitKey(1) replace with ASCII value which is 113
if cv2.waitKey(1000) & 0xFF == ord('q'): # wait for 1000 millisecond
break
# now your code will look like this
if 113 & 0xFF == ord('q'):
break
if cv2.waitKey(1) & 0xFF == ord('q'): # wait for 1 millisecond
break
import numpy as np
import cv2
im = np.zeros((100, 300), np.uint8)
cv2.imshow('Keypressed', im)
while True:
key = cv2.waitKey(0)
im_c = im.copy()
cv2.putText(
im_c,
f'{chr(key)} -> {key}',
(10, 60),
cv2.FONT_HERSHEY_SIMPLEX,
1,
(255,255,255),
2)
cv2.imshow('Keypressed', im_c)
if key == 27: break # 'ESC'