face detection machine learning
#https://www.datacamp.com/community/tutorials/machine-learning-models-api-python
trained datasetsfor face detection
#https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml
import cv2
trained_face_data=cv2.CascadeClassifier("face_detection.xml")
capture = cv2.VideoCapture(0)
while(capture.isOpened()):
    ret,frame= capture.read()
    if ret == True:
        cv2.imshow("video",frame)
        # Display the resulting frame
        faces  = trained_face_data.detectMultiScale(frame)
        cv2.imshow('car detector machine',frame)
        for (x,y,w,h) in faces:
            cv2.rectangle(frame, (x,y),(x+w,y+h), (0,0,255),2)
        # Break the loop
    else:
        break
        if cv2.waitKey(1) & 0xFF ==ord("s"):
            break
capture.release()
cv2.destroyAllWindows()
print("code completed")
 
 
Comments
Post a Comment