Knowing the face
All right, we have detected the face by using a few lines of code, but I would not consider it to be a very big victory as we were fighting using the sword made by other developers. The learning set imported was a generic face learned set. However, in this chapter, we will go ahead and make our very own learning set to recognize a specific human face. This is really a cool thing and I'm sure you will love doing it.
So, let's get started. As you did earlier, go through the explanation first and then write the code so that you understand it very well.
Firstly, we are using the program to capture the images of the object that needs to be detected. In our case, this object will be a person and his face. So, let's see what we need to do:
import cv2 import numpy as np faceDetect = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') cam = cv2.VideoCapture(0) sampleNum = 0 id = raw_input('enter user id') while True: ret,img = cam.read() gray = cv2.cvtColor...