-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any tutorial or example to show how to use Inference Engine models in OpenCV #20
Comments
Hey, @Bahramudin ! I believe, you saw the demos in this repo that show how to do detection of human/face/etc. And your questions are mostly about @dkurt, can you comment on the |
@Bahramudin, after Take a look on dnn's samples: https://github.com/opencv/opencv/tree/master/samples/dnn. As for mentioned model, you can use OpenCV's object detection sample:
|
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) |
@snosov1 Sure. This is the OpenCV Dnn::Net Documentation:
I did something like this:
|
@dkurt Thanks, for the example, I am going to try this now. |
@dkurt Can you tell me what is the different between
And also what is What is your comment? |
@Bahramudin, I think the code can tell you more than my words: And referencing it's documentation: https://docs.opencv.org/master/d6/d0f/group__dnn.html#ga3b34fe7a29494a6a4295c169a7d32422
672x384 is a size of input blob. The network has been trained on images of that size. @snosov1, isn't it? Actually, object detection models can work well on different input sizes. However for now you can test it only with models in native formats using OpenCV. Inference Engine's feature called shape inference which allows you change input dimensions is not implemented in OpenCV right now. |
@dkurt I was able to use the code in your answer and successfully detected the objects, THANKS FOR THAT.
I tried to build the OpenCV from source with Inference Engine, but CMake was not able to find the Inference Engine DIR,
I have done everything as the wiki example. Thanks!! |
@Bahramudin, could you please specify Inferene Engine version (release of OpenVINO) and output of setupvars.bat? |
@dkurt output of setupvars.bat: |
@snosov1 What about the first Question, which asks: How to build OpenCV with Inference Engine |
@Bahramudin To double-check that I understand your question correctly - are you talking about building OpenCV with Inference Engine backend to the If you simply need to work with IE and OpenCV in a single application, then there's really nothing special about that - you just build the libraries independently and link against them in your application. |
@snosov1 Yes, you understand correctly. The OpenCV pre-build library which comes with Intel® OpenVINO™ toolkit has already built with IE backend, which can load and able to run the intel_models. But the pre-built library does not contain some other functionality which I need, e.g GStreamer, ... etc. So I want to build the OpenCV by my self with all the needed backends. Anyway, thanks for your reply!!! |
Ok, got it! But I don't know anybody better than @dkurt who can assist with that =) |
GStreamer is available in OpenCV for OpenVINO for Linux builds only. There are logs of custom OpenCV builds using Inference Engine from OpenVINO installation: |
@alalek Thanks!!! Yes, there is GStreamer available for Linux system, but not for Windows, and also the pre-built lib also does not contain opencv_contrib. My first target system is Windows OS. While building OpenCV from source, everything goes well, but only CMake is not able to find the InferenceEngine_DIR-NOTFOUND which when I load the intel_models after build, it throws the exception below:
:( |
You should resolve this problem first. Specify |
@Bahramudin, what is |
@dkurt It is CMake error which unable to find IE dir I have manually given the path to the InferenceEngine, e.g:
No one was working. |
@Bahramudin, could you try to set InferenceEngine_DIR=C:\Intel\computer_vision_sdk_2018.4.420\deployment_tools\inference_engine\share? |
@snosov1 I have tried the path you mentioned, it seems that cmake was able to find the DIR. |
@Bahramudin, can reproduce your issue using CMake GUI. |
@Bahramudin, as a workaround you may try to comment the following two lines in add_subdirectory(${IE_SRC_DIR}/extension EXCLUDE_FROM_ALL ie_cpu_extension)
add_library(IE::ie_cpu_extension ALIAS ie_cpu_extension) Please add error messages in text instead of screenshots next time. Otherwise other users can't find this issue if they faced similar problem. |
@dkurt Yes, that was solved the problem. By the way, thanks for your suggestion due to add error messages in text instead of screenshots, I will keep it in mind. One small question that why there are more than one computer_vision_sdk directory in the Inference Engine Toolkit e.g
And also why there are more than one inference_engine inside each computer_vision_sdk directory, e.g
This will cnfused people which one to take or use? It was just a suggestion, thank you! |
|
@nikogamulin, please do not duplicate it everywhere. Let's keep our discussion at forum. |
@dkurt Hi, I tried using your open-cv code for loading the face detection model, it worked great !! But now I am trying to use the age and gender model and when I'm getting its output, I only get the gender in the form of softmax output, I don't get the age. If you know how to get the age too, please let me know. Thanks in advance. |
@Mashex, |
@dkurt Thank you very much |
Seems like this is a fairly popular topic. @dkurt do you have any collateral we can reference in the docs? (Since I don't think that this issue is an appropriate place for disseminating information) |
@snosov1, There is a wiki page of how to build OpenCV with IE support https://github.com/opencv/opencv/wiki/Intel%27s-Deep-Learning-Inference-Engine-backend. There is no API difference between OpenCV's dnn and OpenCV's dnn with IE backend. So author should follow samples or tutorials. |
Well, neither samples nor tutorials cover the specific topic in question - "How to use Anyway, closing this issue for now. |
any body know how to use the model license-plate-recognition-barrier-0001 in openCV? there are two inputs, name: "data" and name: "seq_ind" . How to set these two inputs in openCV ? name: "data" can be set by converting image with cv.dnn.blobFromImage, but how to convert name: "seq_ind" for setInput ? |
I know it has been really long....I hope you have got the answer, but if you haven't here it is: Instance Methods
|
Do we have a c++ dnn sample which works with openvino model files ? I am facing similar issue as highlighted in ticket #2567 |
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!!!!
The text was updated successfully, but these errors were encountered: