January 2018
Intermediate to advanced
268 pages
6h 20m
English
As we can see in the main function of the program, we initialize a video capture object. We then bind the function draw_rectangle with the MouseCallback function in the following line:
cv2.setMouseCallback('Webcam', draw_rectangle, event_params)
We then start an infinite loop and start capturing the video stream. Let's see what is happening in the function draw_rectangle; whenever we draw a rectangle using the mouse, we basically have to detect three types of mouse events: mouse click, mouse movement, and mouse button release. This is exactly what we do in this function. Whenever we detect a mouse click event, we initialize the top left point of the rectangle. As we move the mouse, we select the region of interest by keeping ...
Read now
Unlock full access