question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any tutorial or example to show how to use Inference Engine models in OpenCV

See original GitHub issue

I want to know if there is a tutorial or a using example to show how to use Inference Engine pre-trained models in OpenCV to detect the objects like face, human, car, etc…

I have already downloaded and installed the Intel® OpenVINO™ toolkit I followed this wiki.

Basically I have two questions Question 1: I tried to build OpenCV from source with Inference Engine, but the CMake was unable to locate the Inference Engine_DIR, It will be better to also have a tutorial to show how to build, it the wiki above it is not very clear. So I was not able to load the Inference Engine pre-trained model in the OpenCV which was built by me, it has thrwon the exception which say the Inference Engine is not enable. OK, so I used the OpenCV which came with the OpenVINO toolkit.

Question 2: When I loaded the face-detection-adas-0001 xml and bin using cv::dnn::Net::readxxxxx(xml, bin) it was woking and did not throw any exception, but in the next step I don’t know how to pass the frame (cv::Mat) to the Network and get the result. I am looking for an axample to show how to the pre-trained models in OpenCV.

Thanks!!!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:35 (17 by maintainers)

github_iconTop GitHub Comments

8reactions
dkurtcommented, Dec 5, 2018

Just for example,

import cv2 as cv

net = cv.dnn.readNet('/opt/intel/computer_vision_sdk_2018.4.420/deployment_tools/intel_models/face-detection-adas-0001/FP32/face-detection-adas-0001.bin',
                     '/opt/intel/computer_vision_sdk_2018.4.420/deployment_tools/intel_models/face-detection-adas-0001/FP32/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)
2reactions
dkurtcommented, Dec 14, 2018

@Bahramudin, as a workaround you may try to comment the following two lines in C:\Intel\computer_vision_sdk_2018.4.420\inference_engine\share\InferenceEngineConfig.cmake:

        add_subdirectory(${IE_SRC_DIR}/extension EXCLUDE_FROM_ALL ie_cpu_extension)
        add_library(IE::ie_cpu_extension ALIAS ie_cpu_extension)

https://github.com/opencv/dldt/blob/55a41d7570f78aaea0d6764d157dd7434730d56f/inference-engine/cmake/share/InferenceEngineConfig.cmake#L167-L168

Please add error messages in text instead of screenshots next time. Otherwise other users can’t find this issue if they faced similar problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using OpenVINO with OpenCV
Performance comparison of image classification, object detection and pose estimation tasks using OpenCV with OpenVINO and without OpenVINO.
Read more >
How to Speed Up Deep Learning Inference Using ...
To run inference using OpenVino we have to initialize and load the network in IR, prepare input data and call infer function. In...
Read more >
Inference in Five Lines of Code | OpenVINO™ toolkit | Ep. 50
5 lines of OpenCV code to run inference with OpenVINO. See how simple it is to use the Inference - engine, ...
Read more >
End to end video analytics end2end_video_analytics_opencv ...
This tutorial demonstrate an end to end video analytics example with OpenCV-DNN. The code includes few pipe stages. ... This tutorial demonstrates how...
Read more >
Run Inference of a Face Detection Model Using OpenCV ...
Run the OpenCV deep learning module with the Inference Engine back-end with this Python* sample, which works with the pre-trained Face ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found