import numpy as np
import cv2
import os
os.chdir(r"E:\faceeyedetection")
cap =cv2.VideoCapture(0)
address = 'put your address here'
cap.open(address)
face_cascade =cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
#eyes_cascade =cv2.CascadeClassifier("haarcascade_eye.xml")
while(cap.isOpened()):
ret ,frame =cap.read()
gray =cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faces =face_cascade.detectMultiScale(gray ,1.3 , 4)
for (x,y,h,w) in faces :
img = cv2.rectangle(frame ,(x,y),(x+w ,y+h),(0,255,0),3)
img[y:y+h,x:x+w] = cv2.medianBlur(img[y:y+h,x:x+w],75)
#roi_gray=gray[y:y+h ,x:x+w]
#roi_color=frame[y:y+h ,x:x+w]
#eyes =eyes_cascade.detectMultiScale(roi_gray)
#for(ex,ey,eh,ew) in eyes :
#cv2.rectangle(roi_color ,(ex,ey),(ex+ew ,ey+eh),(0,0,255),3)
cv2.imshow("frame" ,frame)
key =cv2.waitKey(1)
if(key == 27):
break
cap.release()
cv2.destroyAllWindows()
===========================
Click here to get the Data used in this video
===========================
Comments
Post a Comment
I hope you have benefited from this blog, and if you have any question, feel free to leave it here.