|
1 |
| -## Name - Soumyajit Chakraborty |
| 1 | +## Name - Soumyajit Chakraborty |
2 | 2 | ## place - kolkata
|
3 | 3 | ## date - 10 / 08 / 2020
|
4 | 4 |
|
5 | 5 | import cv2 as cv
|
6 |
| -face_cascade = cv.CascadeClassifier('..\libs\haarcascade_frontalface_default.xml') |
7 |
| -face_cascade_eye = cv.CascadeClassifier('..\libs\haarcascade_eye.xml') |
8 |
| -#face_glass = cv.CascadeClassifier('..\libs\haarcascade_eye_tree_eyeglasses.xml') |
| 6 | + |
| 7 | +face_cascade = cv.CascadeClassifier("..\libs\haarcascade_frontalface_default.xml") |
| 8 | +face_cascade_eye = cv.CascadeClassifier("..\libs\haarcascade_eye.xml") |
| 9 | +# face_glass = cv.CascadeClassifier('..\libs\haarcascade_eye_tree_eyeglasses.xml') |
9 | 10 |
|
10 | 11 | cap = cv.VideoCapture(0)
|
11 |
| -while(cap.isOpened()): |
| 12 | +while cap.isOpened(): |
12 | 13 |
|
13 |
| - falg ,img = cap.read() #start reading the camera output i mean frames |
| 14 | + falg, img = cap.read() # start reading the camera output i mean frames |
14 | 15 | # cap.read() returning a bool value and a frame onject type value
|
15 | 16 |
|
16 |
| - gray = cv.cvtColor(img , cv.COLOR_BGR2GRAY) # converting to grayscale image to perform smoother |
17 |
| - faces = face_cascade.detectMultiScale(img , 1.1, 7) #we use detectMultiscale library function to detect the predefined structures of a face |
18 |
| - eyes = face_cascade_eye.detectMultiScale(img , 1.1 , 7) |
| 17 | + gray = cv.cvtColor( |
| 18 | + img, cv.COLOR_BGR2GRAY |
| 19 | + ) # converting to grayscale image to perform smoother |
| 20 | + faces = face_cascade.detectMultiScale( |
| 21 | + img, 1.1, 7 |
| 22 | + ) # we use detectMultiscale library function to detect the predefined structures of a face |
| 23 | + eyes = face_cascade_eye.detectMultiScale(img, 1.1, 7) |
19 | 24 | # using for loops we are trying to read each and every frame and map
|
20 |
| - for(x , y ,w ,h ) in faces: |
21 |
| - cv.rectangle(img , (x , y) , (x+w , y+h) , (0 , 255 , 0) , 1) |
| 25 | + for (x, y, w, h) in faces: |
| 26 | + cv.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 1) |
22 | 27 |
|
23 |
| - for(a , b , c , d) in eyes: |
24 |
| - cv.rectangle(img, (a , b), (a+c, b+d), (255, 0, 0), 1) |
| 28 | + for (a, b, c, d) in eyes: |
| 29 | + cv.rectangle(img, (a, b), (a + c, b + d), (255, 0, 0), 1) |
25 | 30 |
|
26 |
| - cv.imshow('img' , img ) |
| 31 | + cv.imshow("img", img) |
27 | 32 | c = cv.waitKey(1)
|
28 |
| - if c == ord('q'): |
| 33 | + if c == ord("q"): |
29 | 34 | break
|
30 | 35 |
|
31 | 36 | cv.release()
|
32 | 37 | cv.destroyAllWindows()
|
33 |
| - |
34 |
| - |
|
0 commit comments