Skip to content

Commit f53754a

Browse files
authored
C++ Demo - Object Detection (NanoDet) (#232)
* Functional and Refactored demo.cpp for MobileNet * Fix inference timer text, added timer reset. * Updated README.md, remove FPS text for single image processing * Add matching saved image message * Removing inference time printout for video inputs * Update FPS text to 2 decimal places * Update coding style for braces * Address PR comments. Adjusted to C++11 standard. * Addressed PR comments. Added C++11 cmake configuration, extracted classID and confidence function, and use NMSBoxesBatched now.
1 parent b1322ea commit f53754a

File tree

3 files changed

+559
-0
lines changed

3 files changed

+559
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
set(project_name "opencv_zoo_object_detection_nanodet")
3+
4+
PROJECT (${project_name})
5+
6+
set(OPENCV_VERSION "4.9.0")
7+
set(OPENCV_INSTALLATION_PATH "" CACHE PATH "Where to look for OpenCV installation")
8+
find_package(OpenCV ${OPENCV_VERSION} REQUIRED HINTS ${OPENCV_INSTALLATION_PATH})
9+
# Find OpenCV, you may need to set OpenCV_DIR variable
10+
# to the absolute path to the directory containing OpenCVConfig.cmake file
11+
# via the command line or GUI
12+
13+
file(GLOB SourceFile
14+
"demo.cpp")
15+
# If the package has been found, several variables will
16+
# be set, you can find the full list with descriptions
17+
# in the OpenCVConfig.cmake file.
18+
# Print some message showing some of them
19+
message(STATUS "OpenCV library status:")
20+
message(STATUS " config: ${OpenCV_DIR}")
21+
message(STATUS " version: ${OpenCV_VERSION}")
22+
message(STATUS " libraries: ${OpenCV_LIBS}")
23+
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
24+
25+
# Declare the executable target built from your sources
26+
add_executable(${project_name} ${SourceFile})
27+
28+
# Set C++ compilation standard to C++11
29+
set(CMAKE_CXX_STANDARD 11)
30+
31+
# Link your application with OpenCV libraries
32+
target_link_libraries(${project_name} PRIVATE ${OpenCV_LIBS})

models/object_detection_nanodet/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Note:
77

88
## Demo
99

10+
### Python
11+
1012
Run the following command to try the demo:
1113
```shell
1214
# detect on camera input
@@ -17,6 +19,23 @@ python demo.py --input /path/to/image -v
1719
Note:
1820
- image result saved as "result.jpg"
1921

22+
### C++
23+
24+
Install latest OpenCV and CMake >= 3.24.0 to get started with:
25+
26+
```shell
27+
# A typical and default installation path of OpenCV is /usr/local
28+
cmake -B build -D OPENCV_INSTALLATION_PATH=/path/to/opencv/installation .
29+
cmake --build build
30+
31+
# detect on camera input
32+
./build/opencv_zoo_object_detection_nanodet
33+
# detect on an image
34+
./build/opencv_zoo_object_detection_nanodet -i=/path/to/image
35+
# get help messages
36+
./build/opencv_zoo_object_detection_nanodet -h
37+
```
38+
2039

2140
## Results
2241

0 commit comments

Comments
 (0)