Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python face recognition

# simple python code: face recognition
import cv2
import numpy as np

detect = cv2.CascadeClassifier(cv2.data.haarcascades +'haarcascade_frontalface_default.xml')

cam = cv2.VideoCapture('image.jpg')
check, img = cam.read()

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = detect.detectMultiScale(gray,1.2,5)

for (x,y,w,h) in faces:
      cv2.rectangle(img, (x,y), (x+w, y+h), (255, 0, 0), 2)

cv2.imshow('Face Detect', img)
cv2.waitKey(600000)

cam.release()
cv2.destroyAllWindows()
 
PREVIOUS NEXT
Tagged: #python #face #recognition
ADD COMMENT
Topic
Name
5+9 =