content
Raspberry Pi+openvino face detection real-time effect
Openvino Raspberry Pi real-time face detection test results_bilibili_bilibili
Reference steps
- Openvino: Install, deploy. (You can refer to the following documents, verification is not recommended)
Installation package link: https://pan.baidu.com/s/1g-pCfJY0wkwTCclqOCKOng
Extraction code: 48z7refer to this section
- For verification, refer to my previous blog
Raspberry Pi test to verify whether the installation of OpenVINO is successful - Programmer Sought- Camera real-time face detection reference
using Raspberry Pi + Intel Neural Stick 2 to realize face recognition and monitoring system_bilibili_bilibili
face detection py code
picture form
#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)
webcam live
#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()
Raspberry Pi+openvino face detection real-time effect
Openvino Raspberry Pi real-time face detection test results_bilibili_bilibili
A small record of problems (which involves some specific problems of my robot, just for my own review)
- The mobile phone needs to turn on the positioning to enter the LAN connection. By mistake, press and hold KEY1 to enter the direct connection mode and try again.
- Problem: cmake compilation problem, just change a terminal again.