Back | Next | Contents
Object Detection
The [`detectNet`](../c/detectNet.h) object accepts an image as input, and outputs a list of coordinates of the detected bounding boxes along with their classes and confidence values. [`detectNet`](../c/detectNet.h) is available to use from [Python](https://rawgit.com/dusty-nv/jetson-inference/master/docs/html/python/jetson.inference.html#detectNet) and [C++](../c/detectNet.h). See below for various [pre-trained detection models](#pre-trained-detection-models-available) available for download. The default model used is a [91-class](../data/networks/ssd_coco_labels.txt) SSD-Mobilenet-v2 model trained on the MS COCO dataset, which achieves realtime inferencing performance on Jetson with TensorRT.
As examples of using the `detectNet` class, we provide sample programs for C++ and Python:
- [`detectnet.cpp`](../examples/detectnet/detectnet.cpp) (C++)
- [`detectnet.py`](../python/examples/detectnet.py) (Python)
These samples are able to detect objects in images, videos, and camera feeds. For more info about the various types of input/output streams supported, see the [Camera Streaming and Multimedia](aux-streaming.md) page.
### Detecting Objects from Images
First, let's try using the `detectnet` program to locates objects in static images. In addition to the input/output paths, there are some additional command-line options:
- optional `--network` flag which changes the [detection model](detectnet-console-2.md#pre-trained-detection-models-available) being used (the default is SSD-Mobilenet-v2).
- optional `--overlay` flag which can be comma-separated combinations of `box`, `lines`, `labels`, `conf`, and `none`
- The default is `--overlay=box,labels,conf` which displays boxes, labels, and confidence values
- The `box` option draws filled bounding boxes, while `lines` draws just the unfilled outlines
- optional `--alpha` value which sets the alpha blending value used during overlay (the default is `120`).
- optional `--threshold` value which sets the minimum threshold for detection (the default is `0.5`).
If you're using the [Docker container](aux-docker.md), it's recommended to save the output images to the `images/test` mounted directory. These images will then be easily viewable from your host device under `jetson-inference/data/images/test` (for more info, see [Mounted Data Volumes](aux-docker.md#mounted-data-volumes)).
Here are some examples of detecting pedestrians in images with the default SSD-Mobilenet-v2 model:
``` bash
# C++
$ ./detectnet --network=ssd-mobilenet-v2 images/peds_0.jpg images/test/output.jpg # --network flag is optional
# Python
$ ./detectnet.py --network=ssd-mobilenet-v2 images/peds_0.jpg images/test/output.jpg # --network flag is optional
```
``` bash
# C++
$ ./detectnet images/peds_1.jpg images/test/output.jpg
# Python
$ ./detectnet.py images/peds_1.jpg images/test/output.jpg
```
> **note**: the first time you run each model, TensorRT will take a few minutes to optimize the network.
Various images are found under `images/` for testing, such as `cat_*.jpg`, `dog_*.jpg`, `horse_*.jpg`, `peds_*.jpg`, ect.
### Processing a Directory or Sequence of Images
If you have multiple images that you'd like to process at one time, you can launch the `detectnet` program with the path to a directory that contains images or a wildcard sequence:
```bash
# C++
./detectnet "images/peds_*.jpg" images/test/peds_output_%i.jpg
# Python
./detectnet.py "images/peds_*.jpg" images/test/peds_output_%i.jpg
```
> **note:** when using wildcards, always enclose it in quotes (`"*.jpg"`). Otherwise, the OS will auto-expand the sequence and modify the order of arguments on the command-line, which may result in one of the input images being overwritten by the output.
For more info about loading/saving sequences of images, see the [Camera Streaming and Multimedia](aux-streaming.md#sequences) page.
### Processing Video Files
You can also process videos from disk. For more info about loading/saving videos, see [here](aux-streaming.md#video-files).
``` bash
# Download test video
wget https://nvidia.box.com/shared/static/veuuimq6pwvd62p9fresqhrrmfqz0e2f.mp4 -O pedestrians.mp4
# C++
./detectnet pedestrians.mp4 images/test/pedestrians_ssd.mp4
# Python
./detectnet.py pedestrians.mp4 images/test/pedestrians_ssd.mp4
```
``` bash
# Download test video
wget https://nvidia.box.com/shared/static/i5i81mkd9wdh4j7wx04th961zks0lfh9.avi -O parking.avi
# C++
./detectnet parking.avi images/test/parking_ssd.avi
# Python
./detectnet.py parking.avi images/test/parking_ssd.avi
```
Remember that you can use the `--threshold` setting to change the detection sensitivity up or down (the default is 0.5).
### Pre-trained Detection Models Available
Below is a table of the pre-trained object detection networks available to use, and the associated `--network` argument to `detectnet` used for loading the pre-trained models:
| Model | CLI argument | NetworkType enum | Object classes |
| ------------------------|--------------------|--------------------|----------------------|
| SSD-Mobilenet-v1 | `ssd-mobilenet-v1` | `SSD_MOBILENET_V1` | 91 ([COCO classes](../data/networks/ssd_coco_labels.txt)) |
| SSD-Mobilenet-v2 | `ssd-mobilenet-v2` | `SSD_MOBILENET_V2` | 91 ([COCO classes](../data/networks/ssd_coco_labels.txt)) |
| SSD-Inception-v2 | `ssd-inception-v2` | `SSD_INCEPTION_V2` | 91 ([COCO classes](../data/networks/ssd_coco_labels.txt)) |
| TAO PeopleNet | `peoplenet` | `PEOPLENET` | person, bag, face |
| TAO PeopleNet (pruned) | `peoplenet-pruned` | `PEOPLENET_PRUNED` | person, bag, face |
| TAO DashCamNet | `dashcamnet` | `DASHCAMNET` | person, car, bike, sign |
| TAO TrafficCamNet | `trafficcamnet` | `TRAFFICCAMNET` | person, car, bike, sign |
| TAO FaceDetect | `facedetect` | `FACEDETECT` | face |
Next | Running the Live Camera Detection Demo
Back | Multi-Label Classification for Image Tagging
© 2016-2019 NVIDIA | Table of Contents