diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-05-30 17:27:04 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-05-30 17:27:04 +0200 |
| commit | 0890fdd951d021308550a0db2e7b6f2593512957 (patch) | |
| tree | a0050b153242ccde662fc0a957a79fc7a7edc4b4 /cli/app/utils/display_utils.py | |
initial site copied in
Diffstat (limited to 'cli/app/utils/display_utils.py')
| -rw-r--r-- | cli/app/utils/display_utils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/app/utils/display_utils.py b/cli/app/utils/display_utils.py new file mode 100644 index 0000000..7bc1782 --- /dev/null +++ b/cli/app/utils/display_utils.py @@ -0,0 +1,28 @@ +import sys +import logging + +import cv2 as cv + + + +log = logging.getLogger('swimmer') + +def handle_keyboard(delay_amt=1): + '''Used with cv.imshow('title', image) to wait for keyboard press + ''' + while True: + k = cv.waitKey(delay_amt) & 0xFF + if k == 27 or k == ord('q'): # ESC + cv.destroyAllWindows() + sys.exit() + elif k == 32 or k == 83: # 83 = right arrow + break + elif k != 255: + log.debug(f'k: {k}') + +def handle_keyboard_video(delay_amt=1): + key = cv.waitKey(1) & 0xFF + # if the `q` key was pressed, break from the loop + if key == ord("q"): + cv.destroyAllWindows() + sys.exit() |
