Face detection in python using OpenCV is a really awesome project for your resume. Because this kind of technology is used by tesla in their autopilot mode. Think you can also make it with python is it not really sound cool
Modules:
In this project, we will use two modules of python
- numpy
- opencv
We also use a data set for detecting the faces you can find it from here
Code
import cv2
import numpy as np
cap=cv2.VideoCapture(0)
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
while True:
ret,frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3,5)
for (x,y,w,h) in faces:
cv2.rectangle(frame,(x,y),(x+w,y+h),(255,0,0),5)
cv2.imshow('frame',frame)
if(cv2.waitKey(1)==ord('e')):
break
cap.release()
cv2.destroyAllWindows()
Comments
Post a Comment