October 2016
Intermediate to advanced
558 pages
12h 39m
English
Let's see how we can use the mouse to interact with live video stream from the webcam. We can use the mouse to select a region and then apply the "negative film" effect on that region, as shown next:

In the following program, we will capture the video stream from the webcam, select a region of interest with the mouse, and then apply the effect:
import cv2 import numpy as np def draw_rectangle(event, x, y, flags, params): global x_init, y_init, drawing, top_left_pt, bottom_right_pt if event == cv2.EVENT_LBUTTONDOWN: drawing = True x_init, y_init = x, y elif event == cv2.EVENT_MOUSEMOVE: if drawing: top_left_pt = ...
Read now
Unlock full access