Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.
5843 Discussions

openvivo 2022.1 (pip install) run cv.dnn.readNet error(-2:Unspecified error)

jsy1784
Beginner
422 Views

I got a error message:

(openvino_env) c:\openvino>python stu01.py
Traceback (most recent call last):
File "stu01.py", line 4, in <module>
net=cv.dnn.readNet('face-detection-adas-0001.xml','face-detection-adas-0001.bin')
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\dnn.cpp:4319: error: (-2:Unspecified error) Build OpenCV with Inference Engine to enable loading models from Model Optimizer. in function 'cv::dnn::dnn4_v20211220::Net::readFromModelOptimizer'

 

I installed openvino2022 by pip. i got the same error on windows,ubuntu20.04 and docker image .
I installed openvino2022 follow the "openvino_docs_install_guides_install_dev_tools.html".

i run openvino_env\Scripts\activate on windows11 ,run source openvino_env/bin/activate on ubuntu.

my py file like this:

import cv2 as cv
import cv2.dnn

net=cv.dnn.readNet('face-detection-adas-0001.xml','face-detection-adas-0001.bin')
net.setPreferableTarget(cv.dnn.DNN_TARGET_CPU)
frame = cv.imread('faces.jpg')
blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)

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.imwrite('out.png', frame)

 face-detection-adas-0001.xml and face-detection-adas-0001.bin and faces.jpg and stu01.py in the same folder.

 

How can I solve this problem? Thanks

0 Kudos
3 Replies
Peh_Intel
Moderator
264 Views

Hi jsy1784,

 

Thanks for reaching out to us.

 

Download and install this OpenCV:  Win pack with dnn module accelerated by Inference Engine (DLDT) (for AVX2 platforms).

 

After extracting all the files, run the setupvars (opencv-4.5.5-openvino-dldt-2021.4.2-vc16-avx2\opencv\build\setup_vars_opencv4.cmd) for the OpenCV in command prompt.

 

 

Regards,

Peh

 

Maksim_S_Intel
Employee
257 Views

OpenVINO from pip does not include OpenCV built with OpenVINO support, instead it uses community opencv-python package. If you want to run models in OpenVINO IR format via OpenCV DNN API and OpenVINO from pip you can try to install OpenCV used by the OpenVINO installer package:

  • Download and extract corresponding archive from this location: https://storage.openvinotoolkit.org/repositories/openvino/packages/2022.1/opencv/
  • Activate virtual envionment with OpenVINO installed: <path-to-venv>\Scripts\activate
  • Activate OpenCV environment: <path-to-opencv>\setupvars.bat
  • Add OpenVINO libs location to the PATH: set PATH=<path-to-venv>\Lib\site-packages\openvino\libs;%PATH%
  • Try it: python -c "import cv2; print(cv2.__file__)"
Peh_Intel
Moderator
129 Views

Hi jsy1784,


This thread will no longer be monitored since we have provided solutions and suggestions. If you need any additional information from Intel, please submit a new question. 



Regards,

Peh


Reply