Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions FaceDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,20 @@
cam = cv2.VideoCapture(0) # initialization camera

while True:
_, img = cam.read() # read the frame from the camera

_,img = cam.read() # read the frame from the camera

grayImg = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # converting color into gray scale image
grayImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # converting color into gray scale image

face = cascade.detectMultiScale(grayImg) # get coordinates of face

for (x, y, w, h) in face: # segregating x,y,w,h

cv2.rectangle(img, (x, y), (x + w, y + h),(0,255,0),2) # draw the retangle

cv2.imshow("FaceDetect",img)
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2) # draw the retangle

key = cv2.waitKey(1)
cv2.imshow("FaceDetect", img)

if key == 81 or key == 113 :
key = cv2.waitKey(1)
if key == 81 or key == 113: # 81: 'q', 113: 'F2'
break

cam.release()
cv2.destroyAllWindows()