学习笔记(01):英特尔®OpenVINO™工具套件中级课程-(第一章)人脸检测

立即学习:https://edu.csdn.net/course/play/28807/427170?utm_source=blogtoedu

人脸检测

图1

程序如下:

图1

练习

1. cd ~/CSDN200/01/exercise-1/

2. source /opt/intel/openvino/bin/setupvars.sh

3. vi face-detection.py

import cv2 as cv

# Load the model
net = cv.dnn.readNet('face-detection-adas-0001.xml', 'face-detection-adas-0001.bin')

# Specify target device (CPU)
net.setPreferableTarget(cv.dnn.DNN_TARGET_CPU)

# Read an image
frame = cv.imread('faces.jpg')

# Prepare input blob
blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)

#perform inference (face detection)
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('out.png', frame)

按ESC后输入:q 来退出编辑模式

4. 使用show命令可以显示图片,播放视频:
show faces.jpg

5. 运行人脸检测代码

python3 face-detection.py

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值