目录
openvino 树莓派 人脸实时检测测试效果_哔哩哔哩_bilibili
参考步骤
- Openvino:安装、部署。(可参考以下文档,验证不建议参考)
树莓派+神经计算棒2部署Openvino的human_pose_estimation_demo实例_hwxhxyz1998403的博客-CSDN博客_openpose 树莓派
树莓派4B使用OpenVINO部署人体关键点检测模型Demo (视频中使用的文件在介绍里下载)_哔哩哔哩_bilibili
安装包链接:https://pan.baidu.com/s/1g-pCfJY0wkwTCclqOCKOng
提取码:48z7参考到此部分
- 验证参考我之前写的博客
树莓派测试验证OpenVINO安装是否成功_dujuancao11的博客-CSDN博客- 摄像头实时人脸检测参考
用树莓派+英特尔神经棒2实现人脸识别及监测系统_哔哩哔哩_bilibili
人脸检测py代码
图片形式
#coding=utf-8
import cv2 as cv
# Load the model.
net = cv.dnn.readNet('face-detection-adas-0001.xml',
'face-detection-adas-0001.bin')
# Specify target device.
net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
# Read an image.
frame = cv.imread('/home/pi/Downloads/inference_engine_vpu_arm/deployment_tools/inference_engine/samples/cpp/build/1.jpeg')
if frame is None:
raise Exception('Image not found!')
# Prepare input blob and perform an inference.
blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)
net.setInput(blob)
out = net.forward()
# Draw detected faces on the frame.
for detection in out.reshape(-1, 7):
confidence = float(detection[2])
xmin = int(detection[3] * frame.shape[1])
ymin = int(detection[4] * frame.shape[0])
xmax = int(detection[5] * frame.shape[1])
ymax = int(detection[6] * frame.shape[0])
if confidence > 0.5:
cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))
# Save the frame to an image file.
cv.imwrite('out111.png', frame)
摄像头实时
#coding=utf-8
import cv2 as cv
import numpy as np
print("start!")
# Load the model.
net = cv.dnn.readNet('face-detection-adas-0001.xml',
'face-detection-adas-0001.bin')
# Specify target device.
net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
# Read an image.
#frame = cv.imread('/home/pi/Downloads/inference_engine_vpu_arm/deployment_tools/inference_engine/samples/cpp/build/1.jpeg')
#
cap = cv.VideoCapture(0)
while(1):
ret, frame = cap.read()
frame = cv.resize(frame,(480,320),interpolation=cv.INTER_CUBIC)
# Prepare input blob and perform an inference.
blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)
net.setInput(blob)
out = net.forward()
# Draw detected faces on the frame.
for detection in out.reshape(-1, 7):
confidence = float(detection[2])
xmin = int(detection[3] * frame.shape[1])
ymin = int(detection[4] * frame.shape[0])
xmax = int(detection[5] * frame.shape[1])
ymax = int(detection[6] * frame.shape[0])
if confidence > 0.5:
cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))
cv.imshow('capture',frame)
if cv.waitKey(1) &0xFF==ord('q'):
# Save the frame to an image file.
cv.imwrite('out111.png', frame)
print('save done')
cap.release()
cv.destroyAllWindows()
树莓派+openvino 人脸检测实时效果
openvino 树莓派 人脸实时检测测试效果_哔哩哔哩_bilibili
问题小记录(其中涉及到一些我的机器人的具体问题,仅作为自己复习用)
- 手机要开启定位才能进入局域网连接,误操作长按KEY1进入直连模式再次尝试。
- 问题:cmake编译问题,重新换了一个终端可以了。