If you want to use another button and you don't know the ID, you can check easily using the following code:

from cv2_tools.Managment import ManagerCV2
import cv2
# keystroke=27 is the button `esc`
manager_cv2 = ManagerCV2(cv2.VideoCapture(0), is_stream=True, keystroke=27, wait_key=1, fps_limit=60)
# This for will manage file descriptor for you
for frame in manager_cv2:
# Each time you press a button, you will get its id in your terminal
last_keystroke = manager_cv2.get_last_keystroke()
if last_keystroke != -1:
print(last_keystroke)
cv2.imshow('Easy button checker', frame)
cv2.destroyAllWindows()

SelectorCV2

Firstly create a SelectorCV2 object. You can pass it optional parameters to configure the output.

If you want to use the same object multiple times you can easily change the content inside it:

# This method could help change rectangles to
selector.set_range_valid_rectangles( origin, destination)
# This method could help if you know exactly the indexes that you want to keep
# Default = [], so if you just want to clean the buffer call this method without parameters
set_valid_rectangles(indexes)

If you want, you can see the example detect_faces.py, it also use an open source library called face_recognition.