我最近安装了 OpenVINO,但我不知道我应该如何提供输入并从 OpenVINO 预训练模型中获得预测。
有两个带有 .bin 和 .xml 后缀的文件,我刚刚使用过 keras,所以我不能在 opencv 中使用这个模型。
我找到了这段代码,但它没有用。
import cv2 as cv
net = cv.dnn.readNet('face-detection-adas-0001.bin', 'face-detection-adas-0001.xml')
cap = cv.VideoCapture(0)
while cv.waitKey(1) < 0:
hasFrame, frame = cap.read()
if not hasFrame:
break
blob = cv.dnn.blobFromImage(frame, size=(672, 384))
net.setInput(blob)
out = net.forward()
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('OpenVINO face detection', frame)
有错误代码:
Traceback (most recent call last):
File "C:\Users\Ali-10\Desktop\facial_landmark\face.py", line 3, in <module>
net = cv.dnn.readNet('face-detection-adas-0001.bin', 'face-detection-adas-0001.xml')
cv2.error: OpenCV(3.4.4) C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp:2428: error: (-2:Unspecified error) Build OpenCV with Inference Engine to enable loading models from Model Optimizer. in function 'cv::dnn::experimental_dnn_34_v10::Net::readFromModelOptimizer'
我期望模型的预测,但我只是得到这个错误。