当前位置:网站首页>3h精通OpenCV(九)-最简单的人脸检测
3h精通OpenCV(九)-最简单的人脸检测
2022-06-29 17:37:00 【华为云】
| 0、准备工作 |
|---|
右击新建的项目,选择Python File,新建一个Python文件,然后在开头import cv2导入cv2库。
import cv2
| 1、实现源码 |
|---|
要进行人脸检测,对于现在的深度学习来说简直是入门级项目了。
如果我们使用传统的方法来进行人脸检测,就可以省去寻找数据集、调参以及训练的时间了。
- faceCascade是我们的人脸分类器,一个写好的分类器文件,虽然很老,但是很有效。关注公众号《萌新加油站》,后台回复:==人脸识别==,即可获取。
- img是读取的图像,先通过
cvtColor(img,cv2.COLOR_BGR2GRAY)转为灰度图像 detectMultiScale()中的参数是灰度图像,比例因子,还有邻居个数。- 下面围绕面孔创建一个边界框,边界框的两个坐标点可以确定框的位置,然后是bounding box的颜色,最后是线条的厚度。
- 最后就
imshow显示结果图像,waitKey(0)让窗口持久保持。
import cv2faceCascade=cv2.CascadeClassifier("Resources/haarcascade_frontalface_default.xml")img=cv2.imread("Resources/mm.jpg")imgGray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)faces=faceCascade.detectMultiScale(imgGray,1.1,4)for(x,y,w,h) in faces: cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)cv2.imshow("Result",img)cv2.waitKey(0)| 2、运行效果 |
|---|
可以看到我们霉霉的脸被边界框框起来了,检测的准确率还可以。
当然,我们不仅可以放入图像进行检测,还可以打开摄像头,进行动态的人脸检测,摄像头在第一节就介绍了,感兴趣的小伙伴去尝试尝试吧~
边栏推荐
- The aggregate function in the epidisplay package of R language divides numerical variables into different subsets based on factor variables, and calculates the summary statistics and aggregate data. W
- mysql.sock的概念是什么
- 机器人不需要保养和出界也能拿金牌是一样一样的
- 力扣今日题-535. TinyURL 的加密与解密
- 传承中华美德,关注中老年大健康,育润奶粉敬老情浓
- 底层内功修养
- 0基础自学STM32(野火)——使用寄存器点亮LED——GPIO功能框图讲解
- 2022 software evaluator examination outline
- 外部自动(PLC启动机器人)
- mysql支持外键吗
猜你喜欢

MySQL触发器如何创建与删除
![填充每个节点的下一个右侧节点指针[利用好每个点->尽可能降低时空复杂度]](/img/33/bda0a898bfe3503197026d1f62e851.png)
填充每个节点的下一个右侧节点指针[利用好每个点->尽可能降低时空复杂度]

Face recognition 4- research on Baidu commercial solutions

linux中mysql 1045错误如何解决

Basic operations such as MySQL startup under Windows platform

Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor

Inherit Chinese virtues, pay attention to the health of the middle-aged and the elderly, and Yurun milk powder has strong respect for the elderly

mysql在linux中2003错误如何解决
Master slave replication of MySQL

SRM供应商协同管理系统功能介绍
随机推荐
Bottom level internal skill cultivation
First batch! Tencent cloud's ability to pass the solution of the government affairs collaboration platform of the China Academy of ICT
MySQL触发器如何创建与删除
Sectigo ov pan domain name certificate is 1590 yuan a year easy to use
如何使用B/S开发工具DevExtreme的图表控件 - 自定义轴位置?
What are the advantages of SaaS services
分割回文串[dp + dfs组合]
Tencent cloud released orbit, an automated delivery and operation and maintenance product, to promote enterprise applications to be fully cloud native
Freedom自由协议质押挖矿系统开发
Younger sister Juan takes you to learn JDBC - 2-day dash Day1
High landing pressure of "authorization and consent"? Privacy computing provides a possible compliance "technical solution"
传承中华美德,关注中老年大健康,育润奶粉敬老情浓
R语言dplyr包filter函数通过组合逻辑(与逻辑)过滤dataframe数据中的数据、其中一个字段的内容等于指定向量中的其中一个,并且另外一个字段值大于某一阈值
Self taught structure (small turtle C language)
What is the function of MySQL cursors
What value can SRM systems bring to the enterprise?
How MySQL queries character set codes of tables
序列检测器
selenium 文件上传方法
Visual Studio插件CodeRush正式发布v22.1——优化调试可视化工具