Python3的人脸识别的两种方法
发布时间
阅读量:
阅读量
import cv2
import numpy as np
filename = 'test1.jpg'
path = r'D:\face'
def detect(filename):
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
face_cascade.load(path + '\haarcascade_frontalface_default.xml')
img = cv2.imread(filename)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x, y, w, h) in faces:
img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
cv2.namedWindow("vikings detected")
cv2.imshow("vikings detected",
全部评论 (0)
还没有任何评论哟~
