当前位置:网站首页>OpenCV学习(二)---树莓派上安装opencv
OpenCV学习(二)---树莓派上安装opencv
2022-06-25 09:45:00 【胖哥王老师】
缘由
找到了之前的树莓派,买了一个摄像头,看看能不能也像ubuntu下那样进行人脸识别这种操作,毕竟考虑到使用的便捷性。总不能用电脑来做个产品吧。
前面用单片机做的人脸识别,还是挺简单的,不过准确性来说,可能还是比较差,用个照片都能糊弄过去,可能还需要加一些红外什么的识别人体吧,不过这么一说,干嘛非要用人脸照片当钥匙呢,用个复杂的照片,会不会更好一些,只要别被别人知道你用的什么照片,感觉比人脸更安全,毕竟人脸总是露在外边。用个二维码感觉效果更好呢。
安装方法
话不多说,还是说怎么在树莓派上安装opencv-python吧。
系统是官方工具安装的,这里就不说了。
参考了流浪猫-《超简单教你在树莓派上安装opencv(二)》
不过后续没有按照他的方式安装opencv,倒也能用起来,几分钟就装上了。
不过不知道会不会缺少什么库,后续发现在解决吧
那么就开始吧
更换源
wget -qO- https://tech.biko.pub/resource/rpi-replace-apt-source-buster.sh | sudo bash
升级软件
sudo apt-get update
sudo apt-get upgrade
安装库
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install aptitude
sudo aptitude install libqtgui4
sudo apt-get install python3-pyqt5
sudo aptitude install libqt4-test
注意有些提示并不是错误,不需要在意
安装opencv并升级numpy
sudo pip3 install opencv-python
pip3 install -U numpy
其他配置
打开摄像头
执行
sudo raspi-config
选择3 Interface Options
然后将camera和ssh都打开 ,ssh打开是方便传输文件。
上传测试文件
我这里用winscp上传了一个之前的测试脚本,测试人脸识别和摄像头的
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# 1.导入库
import cv2
# 2.加载人脸模型
faceModel = cv2.CascadeClassifier('/usr/local/lib/python3.9/dist-packages/cv2/data/haarcascade_frontalface_default.xml')
# 3.打开摄像头
capture = cv2.VideoCapture(0)
# 4.获取摄像头的实时画面
while True:
#4.1读取每一帧的画面
ret,image = capture.read()
#4.2灰度处理
gray = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY)
#4.3检查人脸
# faces = faceModel.detectMultiScale(gray,1.1,3,0)
faces = faceModel.detectMultiScale(
gray,
scaleFactor=1.15,
minNeighbors=5,
minSize=(5, 5),
# flags=cv2.cv.CV_HAAR_SCALE_IMAGE
)
print("发现{0}个人脸!".format(len(faces)))
#4.4标记人脸
for(x,y,w,h) in faces:
# 1.原始图片 2.人脸坐标原点 3.标记的高度 4,线的颜色 5,线宽
cv2.rectangle(image,(x,y),(x+w,y+h),(0,255,0),2)
#4.5显示图片
cv2.imshow('人脸识别摄像头',image)
#4.6暂停窗口
if cv2.waitKey(5) & 0xFF == ord('q'):
break
# 5.释放资源
capture.release()
# 6.销毁窗口
cv2.destroyAllWindows()
效果
居然把梦大师拍的如此模糊。
人脸识别的弊端
开始我们用人脸识别带来便捷和安全,后来有人用人脸识别来杀熟,在商场安装了摄像头,就能识别出你是第一次来还是常客,从而针对性输出。
做过人脸识别录入的用户都知道,被采集者需要通过眨眼、转头、张嘴等动作来配合采集“活体信息”。
“一张照片用那种活化程序,普通人都能够做到让照片摇头、眨眼睛。”清华大学法学院教授劳东燕对《中国消费者报》记者说,“那种软件技术层级比较低。”
人脸作为暴露程度最高的生物指纹,个人感觉不适合用来作为安全手段来保护一些重要信息。
有人擅长伪造,就有人想办法解决,增加活体判断,更新算法等技术,但是感觉总是被动防守,难以及时对症。
已经有人开始欺骗AI了,《如何防止被人脸识别?》
Fawkes的这个工具可以将你上传的照片,无法进行机器学习。下载地址
结束语
昨天看了几个高考语文题目要求,
看出什么情况了吗?
这些题目放在一起看,目的性就太明显了,国家希望我们的学生,既有牢固的基础,又有敢于创新的精神。先学本手,再学妙手,虽有亭翼然,但也不一味醉翁。
重点来了!
最令我欣慰的就是,北京的这个题目,我也算是压对了,
翻看我以前的博客都知道,我可是一直在强调学习不能停止的!
虽然说是领悟的有点晚了,但是还是希望,看到的人,都能保持一颗学习不停的心。
至少是得到了政府的肯定。
边栏推荐
- MySQL source code reading (II) login connection debugging
- Flask博客实战 - 实现个人中心及权限管理
- Yolov5更换上采样方式
- Basic use and principle of Minio
- js工具函数,自己封装一个节流函数
- DDS learning notes of opendds
- 【论文阅读|深读】LINE: Large-scale Information Network Embedding
- Exception: gradle task assemblydebug failed with exit code 1
- View. post VS Handler. Differences and usage scenarios of post
- NetCore性能排查
猜你喜欢
Encoding format for x86
How to make small programs on wechat? How to make small programs on wechat
Tiktok brand goes to sea: both exposure and transformation are required. What are the skills of information flow advertising?
[MySQL learning notes 22] index
Mqtt beginner level chapter
Basic usage and principle of schedulemaster distributed task scheduling center
Webapi performance optimization
Methodchannel of flutter
Consul的基本使用与集群搭建
How much does a small program cost? How much does a small program cost? It's clear at a glance
随机推荐
CyCa 2022 children's physical etiquette primary teacher class Shenzhen headquarters station successfully concluded
使用EVO
Rxjs TakeUntil 操作符的学习笔记
申请多域名SSL证书的要求及注意事项
Free applet making tool, how to make wechat applet
Basic use and principle of Minio
Jetpack compose layout (III) - custom layout
Houdini图文笔记:Your driver settings have been set to force 4x Antialiasing in OpenGL applications问题的解决
Swift recursively queries the array for the number closest to the specified value
8. Intelligent transportation project (1)
Android database security: after the user exits, the transaction rollback log still stores relevant data information
Learning notes of rxjs takeuntil operator
The left sliding menu +menu item icon is grayed out
Mengyou Technology: tiktok live broadcast with goods elements hot topics retention skills shaping image highlight selling points
Can two Mitsubishi PLC adopt bcnettcp protocol to realize wireless communication of network interface?
Get started quickly with jetpack compose Technology
Requirements and precautions for applying for multi domain SSL certificate
How to make a self-made installer and package the program to generate an installer
Bitmap is converted into drawable and displayed on the screen
This is enough for request & response