summaryrefslogtreecommitdiff
path: root/megapixels/app/utils/display_utils.py
blob: 7b74aa46b8a5ac78297014c4faad988398ce7698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import sys

import cv2 as cv


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 != 255:
      # any key to continue
      break