February 2019
Beginner to intermediate
308 pages
7h 42m
English
Let's write the code for the onboarding process. During the onboarding process, we need to activate the webcam to capture a true image of the authorized user. OpenCV has a function called VideoCapture that allows us to activate and capture the image from the computer's webcam:
import cv2video_capture = cv2.VideoCapture(0)
Let's give the user five seconds to prepare before taking a photo using the webcam. We start a counter variable with an initial value of 5 and snap a photo using the webcam once the counter reaches 0. Note that we use the code in the face_detection.py file that we have written earlier in the chapter to detect faces in front of the webcam. The photo will be saved as 'true_img.png' in the same folder ...