1 Star 0 Fork 40

@若水/FaceMaster

forked from 花开富贵/FaceMaster 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
face_detection_cv2.py 530 Bytes
一键复制 编辑 原始数据 按行查看 历史
花开富贵 提交于 2024-04-07 10:15 . 【优化】代码规范
import cv2
# 加载人脸检测器
face_cascade = cv2.CascadeClassifier('models/haarcascade_frontalface_default.xml')
# 读取图片
image_path = 'images/003.jpg'
image = cv2.imread(image_path)
# 缩放图片
# image = cv2.resize(image, None, fx=0.8, fy=0.8)
# 检测人脸
faces = face_cascade.detectMultiScale(image)
# 在图像中标记人脸
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (255, 0, 0), 2)
# 显示图像
cv2.imshow('Face Detection', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w_h_y_/FaceMaster.git
git@gitee.com:w_h_y_/FaceMaster.git
w_h_y_
FaceMaster
FaceMaster
master

搜索帮助