Installing OPENCV
Conda Install OpenCV
Using Python
Import NumPy as NP import CV2 import Matplotlib.pyplot as plot face_cascade = Cv2. Cascadeclassifier ("C:\\opencv3.2.0\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml") eye _cascade = Cv2.
Cascadeclassifier ("C:\\opencv3.2.0\\opencv\\sources\\data\\haarcascades\\haarcascade_eye_tree_eyeglasses.xml") # img = Cv2.imread ("D:\\databases\\picdata\\girls.jpeg") def cvdetect (myframe): Gray = Cv2.cvtcolor (MyFrame, Cv2. Color_bgr2gray) faces = Face_cascade.detectmultiscale (gray,1.1,5,cv2. Cascade_scale_image) If Len (faces) > 0:for facerect in faces:x,y,w,h = Facerect Cv2.rectangle (MyFrame, (x, Y ), (x + W, y + h), (255, 0, 0), 2, 8, 0) Roi_gray = gray[y:y+h, x:x+w] Roi_color = Myframe[y:y+h, x:x+h] eyes = E Ye_cascade.detectmultiscale (Roi_gray, 1.1, 1, Cv2. Cascade_scale_image, (2,2)) for (Ex,ey,ew,eh) in Eyes:cv2.rectangle (Roi_color, (Ex,ey), (Ex+ew, Ey+eh), (0,255,0), 2 ) cv2.imshow ("img", myframe) cap = Cv2. Videocapture (0) while (1): Ret,frame= Cap.read () # cv2.imshow ("frame", frame) if Cv2.waitkey (1) &0xff==ord (' Q '): Break Cvdetect (frame) cap.release () Cv2.destroyallwindows () cv2.waitkey (0)