Skip to content

Add rs-dnn-vino sample #5360

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

Merged
merged 4 commits into from
Dec 8, 2019
Merged

Conversation

maloel
Copy link
Contributor

@maloel maloel commented Dec 3, 2019

rs-dnn-vino

This example demonstrates OpenVINO™ toolkit integration with object detection, using
basic depth information to approximate distance.

rs-dnn-vino

The same exact neural network (MobileNet-SSD) is used here as in the OpenCV DNN sample (rs-dnn), for
comparison.

Detected objects are labeled.

Multiple models, if supplied, can be loaded at once and switched at runtime, for comparison.

@maloel maloel added the openvino label Dec 3, 2019
@maloel maloel requested a review from dorodnic December 3, 2019 10:32
* Uses same model as rs-dnn, for comparison
* Can load multiple models and switch on the fly (press '1' for first, '2', etc.)
* Revised download mechanism errors in openvino/CMakeLists.txt
Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done - though some more polishing is, IMHO, required

# OpenCV is required here
if(NOT DEFINED OpenCV_DIR OR NOT IS_DIRECTORY ${OpenCV_DIR})
set(OpenCV_DIR "" CACHE PATH "The path to the OpenCV Toolkit build directory")
message( FATAL_ERROR "OpenVINO examples require OpenCV; specify OpenCV_DIR" )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls specify the OpenCv version required

Copy link
Contributor Author

@maloel maloel Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# OpenCV is required here. You can simply use the version that's supplied with
# OpenVINO (${INTEL_OPENVINO_DIR}/opencv/cmake).

Added the same comment to the readme.md


This sample makes use of OpenCV.

Though we are detecting general objects in the neural network, the inputs and
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By inspecting the code the demo requires a camera with Depth +RGB sensors. Pls mention it in the tutorial

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a "Requirements" section with:
A camera with both depth and RGB sensors is required here.

and added the OpenCV requirements there, too.

auto color_frame = frames.get_color_frame();
auto depth_frame = frames.get_depth_frame();

// If we only received a new depth frame, but the color did not update, continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible that either one of them will be nullptr if the streaming starts with interval.
Put a sanity check if (!color || !depth) continue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

}

// Wait for the results of the previous frame we enqueued: we're going to process these
p_detector->wait();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seem to be a blocking code - is it possible to offload and wait for detector's result in a separate thread to get more performance ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but I thought that's beyond the purpose of the sample. I actually did this in the viewer.
And some steps are made to actually improve performance: the frame is sent for inference and we only wait for the result once the next frame arrives.

prev_image = image;

// Display the results (from the last frame) as rectangles on top (of the current frame)
for( auto && face : faces )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make the main function more concise so it will focus on the detection flow and wrap
utility routines and rendering stuff with function calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I separated the main body into several functions:

detect_objects()
draw_objects()
draw_detector_overlay()

That does make it better.

@maloel
Copy link
Contributor Author

maloel commented Dec 5, 2019

I'm working on renaming the openvino_helpers::face_detection to object_detection so it's clearer that face detection is just one use-case


By default, the samples use the `CPU` device for running rather than assuming a
GPU. If no discreet GPU is available, the CPU will likely run faster, but feel
free to experiment by chaning the device.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing

@dorodnic dorodnic merged commit 36cddfd into IntelRealSense:development Dec 8, 2019
@maloel maloel deleted the rs-dnn-vino branch December 9, 2019 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants