January 2018
Intermediate to advanced
268 pages
6h 20m
English
Let's see how we can use the mouse to interact with a live video stream from the webcam. We can use the mouse to select a region, and then apply a negative film effect on that region, as shown in the following image:

In the following program, we will capture the video stream from the webcam, select a region of interest with the mouse, and then apply this effect:
import cv2 import numpy as np def update_pts(params, x, y): global x_init, y_init params["top_left_pt"] = (min(x_init, x), min(y_init, y)) params["bottom_right_pt"] = (max(x_init, x), max(y_init, y)) img[y_init:y, x_init:x] = 255 - img[y_init:y, ...
Read now
Unlock full access