#raspberry #pi #tutotials #techyogi #tech #yogi #facedetect #opencv #face #detection
In this video we are showing how to work with openCV. We can detect face from the given image file. We can also mark on the face in the image.
For this you need to a XML file, which is you can download from the below link.
raw.githubuser...
I have writing whole code here. So that viewer can easily copy and paste in their system. This is the final code which is showing in video in last step.
import cv2
import sys
Get user supplied values
imagePath = sys.argv[1]
cascPath = "haarcascade_frontalface_default.xml"
Create the haar cascade
faceCascade = cv2.CascadeClassifier(cascPath)
Read the image
image = cv2.imread(imagePath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
Detect faces in the image
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.2,
minNeighbors=5,
minSize=(30, 30),
flags = cv2.CASCADE_SCALE_IMAGE
)
print("Found {0} faces!".format(len(faces)))
Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.imshow("Faces found", image)
cv2.waitKey(0)
Негізгі бет Face detection with python and openCV | फेस डिटेक्ट करना सीखे ओपन सीवी के साथ
Пікірлер