【问题标题】:Trying to run OpenVINO inference kit with an OpenCV version of 4.5.1, while reporting error尝试使用 OpenCV 版本 4.5.1 运行 OpenVINO 推理套件,同时报告错误
【发布时间】:2022-10-19 14:02:49
【问题描述】:

我得到的错误是:

cv2.error: OpenCV(4.5.1) /private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pip-req-build-yaf6rry6/opencv/modules/dnn/src/dnn.cpp:3901: error: (-2:Unspecified error) Build OpenCV with Inference Engine to enable loading models from Model Optimizer. in function 'readFromModelOptimizer'

调用OpenVINO套件功能的完整代码为:

import cv2 as cv

// Check the path of the package

print(cv.__file__)
print(cv.getBuildInformation())

// 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.2:
        cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))

// Save the frame to an image file

cv.imwrite('output_02.png', frame)

其中face-detection-adas-0001.xml''face-detection-adas-0001.bin' 的声明实际上是MobileNet 的模型,因为OpenVINO 推理引擎的默认设置包括在内。

请问我在处理神经网络架构方面是否有任何错误,或者我的硬件设置存在某种问题?我正在使用带有 Catalina 10.15.7 的 Macbook Pro(13 英寸,2020,3-thunderbolt 端口)。

谢谢!~

【问题讨论】:

    标签: python opencv


    【解决方案1】:

    你是如何在你的机器上安装 OpenCV(和 OpenVINO)的?

    您是否从源代码构建 OpenCV 或安装了预构建、预打包的版本?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多