Handle the keyboard Task
Handle the keyboard Task
1. Waiting fuction of keyboard input
cv2.waitKey(delay=None) -> retval
- delay : Waiting time ex) delay <= 0 is infinite delay. defautl value is 0.
-
retval : Putted key (ASCII code). ex) if not key is putted,it’s -1.
- Note
- cv2.waitKey() function opearates when OpenCV window is opened.
- If you want to check the specific key press, you use the ord() function.
while True: if cv2.waitKey() == ord('q'): break
*** Main special Key code : 27 (ESC), 13 (ENTER), 9 (TAB)
2. Handle the mouse event
- the function that calls back the mouse event.
cv2.setMouseCallback(windowName, onMouse, param=None) -> None
- windowName : Window name that mouse event handle.
- onMouse : The callback function for handle mouse event.
- It should follow like that frame
onMouse(event,x,y,flags,param) -> None
- It should follow like that frame
- param : data that pass to callback funtion
3. THe frame that handle mouse event function(callback function)
onMouse(event,x,y,flags,param) -> None
-
event : The sort of mouse event. ex) constant starting with cv.EVENT_FLAG
- x : x coordination
- y : y coordination
- flags : The situation when break mouse event ex) constant starting with cv.EVENT_FLAG
- param : The data that is setted from cv2.setMouseCallback() function.
4. The method How to check the operation time
-
Computer Vision generally handles high capacity data. So We should manage the final result through series of processes checking the operation time.
-
TickMeter class could check the operation time in OpenCV
cv2.TickMeter() -> tm
- tm : cv2.TickMeter object
- tm.start() : start time check
- tm.stop() : stop time check
- tm.reset() : initialize time check
- tm.getTimeSec() : return the time check per second
- tm.getTimeMilli() : return the time check per milli second
- tm.getTimeMicro() : return the time check per micro second
Leave a comment