Source code for formhtr.libs.extract_ROI.cli_inputs
import cv2
[docs]
def process_cli(widget):
"""Dispatch keyboard commands for ``SelectROIsWidget``.
Args:
widget: Instance with ``undo_add_rectangle``.
Returns:
``None`` when the user presses ``q`` or Esc.
"""
exit = False
while not exit:
key = cv2.waitKey(0)
# Close program with 'q' or 'Esc' button
if key == ord('q') or key == 27:
exit = True
# Delete last rectangle with 'd'
if key == ord('r'):
widget.undo_add_rectangle()