可以参考这里人脸年龄、性别预测
and
这里人脸年龄、性别预测
- 首先下载对应的模型
AgeGenderDeepLearning 可以到github里下载
这里不全
又或者是这里github 项目opencv_tutorial
这里都有
下载得到六个文件,分别是以下等号右边六个
> faceProto = "opencv_face_detector.pbtxt"
> faceModel ="opencv_face_detector_uint8.pb"
>
> ageProto = "age_deploy.prototxt"
> ageModel = "age_net.caffemodel"
>
> genderProto = "gender_deploy.prototxt"
> genderModel = "gender_net.caffemodel"
将下好的模型放在程序的同一目录下
2.代码如下
#-*- coding: utf-8 -*-
import cv2 as cv
import time
# 检测人脸并绘制人脸bounding box
def getFaceBox(net, frame, conf_threshold=0.7):

本文介绍了如何在树莓派上实现人脸年龄和性别的预测。通过下载特定的模型,如AgeGenderDeepLearning,并确保OpenCV库的版本足够高。在遇到AttributeError关于'dnn'的问题时,可以通过升级OpenCV或者在Python虚拟环境中安装新版本的库来解决。最终,成功运行代码后,可以得到人脸年龄和性别的预测结果。
最低0.47元/天 解锁文章
1078

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



