Skip to content

Commit

Permalink
Unite deep learning object detection samples
Browse files Browse the repository at this point in the history
  • Loading branch information
dkurt committed Mar 3, 2018
1 parent 667f5b6 commit e8d94ea
Show file tree
Hide file tree
Showing 14 changed files with 555 additions and 995 deletions.
30 changes: 8 additions & 22 deletions doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown
Expand Up @@ -18,40 +18,26 @@ VIDEO DEMO:
Source Code
-----------

The latest version of sample source code can be downloaded [here](https://github.com/opencv/opencv/blob/master/samples/dnn/yolo_object_detection.cpp).
Use a universal sample for object detection models written
[in C++](https://github.com/opencv/opencv/blob/master/samples/dnn/object_detection.cpp) and
[in Python](https://github.com/opencv/opencv/blob/master/samples/dnn/object_detection.py) languages

@include dnn/yolo_object_detection.cpp

How to compile in command line with pkg-config
----------------------------------------------

@code{.bash}

# g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` yolo_object_detection.cpp -o yolo_object_detection

@endcode
Usage examples
--------------

Execute in webcam:

@code{.bash}

$ yolo_object_detection -camera_device=0 -cfg=[PATH-TO-DARKNET]/cfg/yolo.cfg -model=[PATH-TO-DARKNET]/yolo.weights -class_names=[PATH-TO-DARKNET]/data/coco.names

@endcode

Execute with image:

@code{.bash}

$ yolo_object_detection -source=[PATH-IMAGE] -cfg=[PATH-TO-DARKNET]/cfg/yolo.cfg -model=[PATH-TO-DARKNET]/yolo.weights -class_names=[PATH-TO-DARKNET]/data/coco.names
$ example_dnn_object_detection --config=[PATH-TO-DARKNET]/cfg/yolo.cfg --model=[PATH-TO-DARKNET]/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392

@endcode

Execute in video file:
Execute with image or video file:

@code{.bash}

$ yolo_object_detection -source=[PATH-TO-VIDEO] -cfg=[PATH-TO-DARKNET]/cfg/yolo.cfg -model=[PATH-TO-DARKNET]/yolo.weights -class_names=[PATH-TO-DARKNET]/data/coco.names
$ example_dnn_object_detection --config=[PATH-TO-DARKNET]/cfg/yolo.cfg --model=[PATH-TO-DARKNET]/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392 --input[PATH-TO-IMAGE-OR-VIDEO-FILE]

@endcode

Expand Down
2 changes: 1 addition & 1 deletion modules/dnn/include/opencv2/dnn/dnn.hpp
Expand Up @@ -222,7 +222,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
/** @brief Returns index of output blob in output array.
* @see inputNameToIndex()
*/
virtual int outputNameToIndex(String outputName);
CV_WRAP virtual int outputNameToIndex(String outputName);

/**
* @brief Ask layer if it support specific backend for doing computations.
Expand Down
20 changes: 20 additions & 0 deletions samples/dnn/README.md
@@ -0,0 +1,20 @@
# OpenCV deep learning module samples

## Model Zoo

### Object detection

| Model | Scale | Size WxH| Mean subtraction | Channels order |
|---------------|-------|-----------|--------------------|-------|
| [MobileNet-SSD, Caffe](https://github.com/chuanqi305/MobileNet-SSD/) | `0.00784 (2/255)` | `300x300` | `127.5 127.5 127.5` | BGR |
| [OpenCV face detector](https://github.com/opencv/opencv/tree/master/samples/dnn/face_detector) | `1.0` | `300x300` | `104 177 123` | BGR |
| [SSDs from TensorFlow](https://github.com/tensorflow/models/tree/master/research/object_detection/) | `0.00784 (2/255)` | `300x300` | `127.5 127.5 127.5` | RGB |
| [YOLO](https://pjreddie.com/darknet/yolo/) | `0.00392 (1/255)` | `416x416` | `0 0 0` | RGB |
| [VGG16-SSD](https://github.com/weiliu89/caffe/tree/ssd) | `1.0` | `300x300` | `104 117 123` | BGR |
| [Faster-RCNN](https://github.com/rbgirshick/py-faster-rcnn) | `1.0` | `800x600` | `102.9801, 115.9465, 122.7717` | BGR |
| [R-FCN](https://github.com/YuwenXiong/py-R-FCN) | `1.0` | `800x600` | `102.9801 115.9465 122.7717` | BGR |

## References
* [Models downloading script](https://github.com/opencv/opencv_extra/blob/master/testdata/dnn/download_models.py)
* [Configuration files adopted for OpenCV](https://github.com/opencv/opencv_extra/tree/master/testdata/dnn)
* [How to import models from TensorFlow Object Detection API](https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API)
93 changes: 0 additions & 93 deletions samples/dnn/faster_rcnn.cpp

This file was deleted.

132 changes: 0 additions & 132 deletions samples/dnn/mobilenet_ssd_python.py

This file was deleted.

0 comments on commit e8d94ea

Please sign in to comment.