Skip to content

Commit 36cddfd

Browse files
authored
Merge pull request #5360 from maloel/rs-dnn-vino
Add rs-dnn-vino sample
2 parents b6ce063 + 9291fa3 commit 36cddfd

File tree

14 files changed

+574
-106
lines changed

14 files changed

+574
-106
lines changed

examples/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ For a detailed explanations and API documentation see our [Documentation](../doc
3333
|[Apriltag Pose](./pose-apriltag)|C++|Demonstrates how to compute [Apriltag](https://github.com/AprilRobotics/apriltag/tree/3.1.1) pose from T265 fisheye image stream. | :star::star: |[![Motion Tracking - T260 and SLAM](https://img.shields.io/badge/-Tracking-0e2356.svg)](../doc/t265.md#examples-and-tools)|
3434
|[AR-Basic](./ar-basic)|C++|Shows how to use pose and fisheye frames to display a simple virtual object on the fisheye image | :star::star: |[![Motion Tracking - T260 and SLAM](https://img.shields.io/badge/-Tracking-0e2356.svg)](../doc/t265.md#examples-and-tools)|
3535
|[DNN](../wrappers/opencv/dnn)| C++ & [OpenCV](https://github.com/IntelRealSense/librealsense/tree/master/wrappers/opencv#getting-started) | Intel RealSense camera used for real-time object-detection | :star::star: | [![Depth Sensing - Structured Light, Stereo and L500](https://img.shields.io/badge/-Depth-5bc3ff.svg)](./depth.md) |
36+
|[DNN](../wrappers/openvino/dnn)| C++ & [OpenVINO](https://github.com/IntelRealSense/librealsense/tree/master/wrappers/openvino) | Intel RealSense camera used for real-time object-detection | :star::star: | [![Depth Sensing - Structured Light, Stereo and L500](https://img.shields.io/badge/-Depth-5bc3ff.svg)](./depth.md) |
3637
|[Tracking and Depth](./tracking-and-depth)| C++ | Shows how to use the tracking camera T265 together with a depth camera to display a 3D pointcloud with respect to a static reference frame | :star::star: | [![Depth Sensing - Structured Light, Stereo and L500](https://img.shields.io/badge/-Depth-5bc3ff.svg)](./depth.md) [![Motion Tracking - T260 and SLAM](https://img.shields.io/badge/-Tracking-0e2356.svg)](../doc/t265.md#examples-and-tools)
3738
|[Trajectory](./trajectory)| C++ | Shows how to calculate and render 3D trajectory based on pose data from a tracking camera | :star::star::star: | [![Motion Tracking - T260 and SLAM](https://img.shields.io/badge/-Tracking-0e2356.svg)](../doc/t265.md#examples-and-tools)
3839
|[Software Device](./software-device)| C++ | Shows how to create a custom `rs2::device` | :star::star::star: | [![Depth Sensing - Structured Light, Stereo and L500](https://img.shields.io/badge/-Depth-5bc3ff.svg)](./depth.md) [![Motion Tracking - T260 and SLAM](https://img.shields.io/badge/-Tracking-0e2356.svg)](../doc/t265.md#examples-and-tools) |

wrappers/openvino/CMakeLists.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ include_directories( ${IE_ROOT_DIR}/src/extension )
2424
set(OPENVINO_FILES
2525
../rs-vino/base-detection.cpp
2626
../rs-vino/base-detection.h
27-
../rs-vino/face-detection.cpp
28-
../rs-vino/face-detection.h
29-
../rs-vino/detected-face.cpp
30-
../rs-vino/detected-face.h
27+
../rs-vino/object-detection.cpp
28+
../rs-vino/object-detection.h
29+
../rs-vino/detected-object.cpp
30+
../rs-vino/detected-object.h
3131
../rs-vino/openvino-helpers.h
3232
${IE_ROOT_DIR}/src/extension/ext_list.hpp
3333
)
@@ -52,12 +52,9 @@ function(dl_vino_model filename sha1)
5252
file(DOWNLOAD "${OPENVINO_MODEL_SRC_URL}/${filename}" "${path}"
5353
EXPECTED_HASH SHA1=${sha1}
5454
STATUS status)
55-
list(GET status 0 error_code)
56-
if (NOT ${error_code} EQUAL 0)
57-
message(FATAL_ERROR "Error (${status}) downloading: ${OPENVINO_MODEL_SRC_URL}/${filename}")
58-
endif()
5955
endif()
6056
endfunction()
6157

6258
# List all the specific examples for OpenVINO
6359
add_subdirectory(face)
60+
add_subdirectory(dnn)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
cmake_minimum_required(VERSION 3.1.0)
2+
3+
project(RealSenseVinoDnnExample)
4+
5+
6+
# OpenCV is required here. You can simply use the version that's supplied with
7+
# OpenVINO (${INTEL_OPENVINO_DIR}/opencv/cmake).
8+
if(NOT DEFINED OpenCV_DIR OR NOT IS_DIRECTORY ${OpenCV_DIR})
9+
set(OpenCV_DIR "" CACHE PATH "The path to the OpenCV Toolkit build directory")
10+
message( FATAL_ERROR "OpenVINO examples require OpenCV; specify OpenCV_DIR" )
11+
endif()
12+
find_package(OpenCV REQUIRED)
13+
get_property(deps VARIABLE PROPERTY DEPENDENCIES)
14+
set(DEPENDENCIES ${deps} ${OpenCV_LIBS})
15+
include_directories( ../../opencv )
16+
17+
18+
add_executable(rs-dnn-vino
19+
rs-dnn-vino.cpp
20+
${OPENVINO_FILES}
21+
${ELPP_FILES}
22+
)
23+
24+
source_group("OpenVINO" FILES ${OPENVINO_FILES})
25+
source_group("EasyLogging++" FILES ${ELPP_FILES})
26+
27+
set_property(TARGET rs-dnn-vino PROPERTY CXX_STANDARD 11)
28+
target_link_libraries(rs-dnn-vino ${DEPENDENCIES})
29+
set_target_properties (rs-dnn-vino PROPERTIES
30+
FOLDER "Examples/openvino"
31+
)
32+
33+
install(
34+
TARGETS
35+
36+
rs-dnn-vino
37+
38+
RUNTIME DESTINATION
39+
${CMAKE_INSTALL_PREFIX}/bin
40+
)
41+
42+
43+
# Download model files -- these will go into build/wrappers/openvino/dnn, which is also where the sample
44+
# is run from in Visual Studio
45+
dl_vino_model( "README.txt" "789e144d6cafa379c8437d2a6860829b6d935a8d" )
46+
dl_vino_model( "mobilenet-ssd.xml" "483ba684dd53ba138550377075e928b2008418bb" )
47+
dl_vino_model( "mobilenet-ssd.bin" "3b687f0b9519b0d296c23d5f038a8623b5aeb49b" )
48+
dl_vino_model( "mobilenet-ssd.labels" "b11e85afe8cff3172ad9b62d904bbc8013b3ddbf" )

wrappers/openvino/dnn/readme.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# rs-dnn-vino Sample
2+
3+
## Overview
4+
This example demonstrates OpenVINO™ toolkit integration with object detection, using
5+
basic depth information to approximate distance.
6+
7+
<p align="center"><img src="rs-dnn-vino.jpg" alt="screenshot"/></p>
8+
9+
The same exact neural network is used here as in the OpenCV DNN sample, for
10+
comparison.
11+
12+
13+
## Requirements
14+
15+
A camera with both depth and RGB sensors is required.
16+
17+
This sample makes use of OpenCV. You can use the OpenCV that is packaged
18+
with OpenVINO by pointing OpenCV_DIR to `${INTEL_OPENVINO_DIR}/opencv/cmake`.
19+
20+
21+
## Implementation
22+
23+
We can reuse the `openvino_helpers::object_detection` code we used in the
24+
[rs-face-vino example](../face), but we now provide it with a different model
25+
aimed at object rather than face detection. You can see it now recognizes a
26+
`person` rather than each face.
27+
28+
There is a single trained model with two Intermediate Representation files
29+
(`mobilenet-ssd.xml` and `.bin`) provided with the sample. The sample
30+
will, however, load any model present in the current directory and is able to
31+
switch between them at runtime, allowing some experimentation.
32+
33+
> The `object_detection` class does have requirements from the model: it is
34+
> expected to have **a single input and output!!!** (bounding box, classification,
35+
> confidence, etc.), and will be rejected otherwise.
36+
37+
> You can see the inputs and outputs of a model listed in the .xml file. Search
38+
> for a layer with `type="Input"` to find the inputs. Similarly, the expected
39+
> output layer is of `type="DetectionOutput"`.
40+
41+
> Some neural networks (e.g., the version of Faster R-CNN available with
42+
> OpenVINO) have two inputs, adding an additional layer for more information.
43+
> Some effort was made to support such models. Feel free to experiment.
44+
45+
Each model can optionally provide a `.labels` classification file to help map
46+
the output "label" integer into a human-recognizable name such as "person",
47+
"bottle", etc.
48+
These are not provided by the OpenVINO model zoo and need to be created
49+
manually according to the classes used when training the model.
50+
See the format in `mobilenet-ssd.labels` for an example: one line per
51+
classification, starting at 0 (which is expected to be the background).
52+
53+
54+
## Speed
55+
56+
The MobileNet models are intended for use on mobile devices and so their
57+
performance is high and they are suitable for use on the CPU. More advanced
58+
models can be more accurate or provide better classification but may require
59+
acceleration using a GPU or other device.

0 commit comments

Comments
 (0)