-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add rs-dnn-vino sample #5360
Conversation
* 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
There was a problem hiding this 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" ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
wrappers/openvino/dnn/readme.md
Outdated
|
||
This sample makes use of OpenCV. | ||
|
||
Though we are detecting general objects in the neural network, the inputs and |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 ) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
I'm working on renaming the |
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing
rs-dnn-vino
This example demonstrates OpenVINO™ toolkit integration with object detection, using
basic depth information to approximate distance.
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.