Skip to content

Commit 790d50c

Browse files
Added face recognization
1 parent c2e9183 commit 790d50c

File tree

5 files changed

+33390
-0
lines changed

5 files changed

+33390
-0
lines changed

opencv/faceRecognization/faceRecog.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import cv2
2+
import sys
3+
# from PIL import Image
4+
5+
# Get user supplied values
6+
imagePath = sys.argv[1]
7+
# cascPath = sys.argv[2]
8+
9+
10+
cascadePath = "haarcascade_frontalface_default.xml"
11+
12+
# Create the haar cascade
13+
faceCascade = cv2.CascadeClassifier(cascadePath)
14+
15+
# Read the image
16+
image = cv2.imread(imagePath)
17+
image = cv2.resize(image, (0, 0), fx=0.5, fy=0.5)
18+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
19+
20+
# Detect faces in the image
21+
faces = faceCascade.detectMultiScale(
22+
gray,
23+
scaleFactor=1.1,
24+
minNeighbors=5,
25+
minSize=(10, 10),
26+
maxSize=(100, 100)
27+
# flags=cv2.cv.CV_HAAR_SCALE_IMAGE
28+
)
29+
30+
print "Found {0} faces!".format(len(faces))
31+
32+
# Draw a rectangle around the faces
33+
for (x, y, w, h) in faces:
34+
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
35+
36+
cv2.imshow("Faces found", image)
37+
cv2.waitKey(0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy