目录
一、人脸识别
1、初级版
默认使用HOG算法
import os
os.chdir('C:/Users/Administrator/AppData/Local/Programs/Python/Python37/Lib/site-packages')
import cv2
import matplotlib.pyplot as plt
def detect(filename):
face_cascade=cv2.CascadeClassifier('C:/Users/Administrator/AppData/Local/Programs/Python/Python37/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml')
img=cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces=face_cascade.detectMultiScale(gray,1.1,5)
for (x,y,w,h) in faces:
img=cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),4)
plt.imshow(img)
plt.axis('off')
plt.show()
detect('disanzhang.jpg')
运行结果:

本文探讨了人脸识别技术,从初级版的HOG算法到进阶版的CNN模型,展示了精度提升的效果。同时指出了使用cv2包进行路径处理时可能出现的中文路径和引用问题。在人脸对齐部分,通过模型库文件可以精确标出五官位置。
最低0.47元/天 解锁文章
8003

被折叠的 条评论
为什么被折叠?



