openvino人脸

 

在Intel® Neural Compute Stick 2上yolov3推理时间是一帧300多毫秒,做人脸检测还可以

CPU i5的推理时间大概是2s左右。

 

有权重,无代码:

https://github.com/BenedictusAryo/OpenVino_face-detection_python

有权重,opencv调用:

https://github.com/0d3ng/face-detection-vino

 

https://github.com/opencv/open_model_zoo

这个说是有三维方向:

https://download.01.org/openvinotoolkit/2018_R4/open_model_zoo/face-detection-adas-0001/FP16/face-detection-adas-0001.bin

https://download.01.org/openvinotoolkit/2018_R4/open_model_zoo/face-detection-adas-0001/FP16/face-detection-adas-0001.xml
 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import cv2
# Load the model
net = cv2.dnn.readNet('face-detection-adas-0001.xml', 'face-detection-adas-0001.bin')
# Specify target device
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
# Read an image

cv=cv2.VideoCapture(0)

while True:

    _,frame=cv.read()
# Prepare input blob and perform an inference
    blob = cv2.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv2.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
    cv2.imshow('out.png', frame)
    cv2.waitKey(1)

 

你可能感兴趣的:(opencv)