Skip to content

DnnAttribute

Moscowsky Anton edited this page Mar 31, 2021 · 11 revisions

DNN Attribute

An attribute that recognizes images using the dnn module from OpenCV. Minimum OpenCV version: 3.4.1 (while ROS Melodic comes with 3.2.0, Noetic is recommended) To use networks from other frameworks in this module, you do not need to install them.

Modes Accuracy assessment 3D-translation 3D-rotation Contour extraction Additional info
D D - ID and name in CNN

1. Modes

1.1. Detect

Returns areas with objects recognized by CNN and having a probability not lower than Probability.

1.2. Check

Not implemented

1.3. Extract

Not implemented

2. XML-description

2.1. Common parameters

  • Name (string, must be set) attribute unique name
  • Type (string, must be "Dnn") attribute type
  • Weight (double, default: 1) attribute weight
  • Probability (double, default: 0.75) acceptable detection accuracy, used in Detect mode.
  • Contour (bool, default: true) Returns the contour of the attribute if true.

2.2. Special parameters

  • framework (string, must be set) Framework options available: darknet, tensorflow.
  • weights (string, must be set) The path to the scale file. See the table below for more information.
  • config (string, must be set) The path to the configuration file. See the table below for more information.
  • labels (string, default: "") The path to the file with the names of the labels. Optional parameter, needed only if you need to fix the name of the object on the network.
  • forceCuda (int, default: 0) For some computers (for example, the Jetson series), you need to set 1 to enable network acceleration using CUDA and cuDNN.
  • inputWidth (int, default: 300) The width of the input image to the network. TODO: extract automatically from config
  • inputHeight (int, default: 300) The height of the input image to the network. TODO: extract automatically from config
  • obj_id (int, default: -1) Object identifier for recognition, if -1 then all network objects are returned.

2.3. Example

<?xml version="1.0" ?>

<AttributeLib>

    <Attribute Name="COCO_Dnn" Type="Dnn" framework="tensorflow" weights="ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb" config="ssd_mobilenet_v1_coco_2017_11_17/config.pbtxt" labels="ssd_mobilenet_v1_coco_2017_11_17/mscoco_label_map.pbtxt" inputWidth="300" inputHeight="300" Probability="0.75" obj_id="-1"/>

</AttributeLib>

<SimpleObjectBase>  
    
    <SimpleObject Name="COCO_dnn_object" ID="60">              
        <Attribute Type="Detect">COCO_Dnn</Attribute>                    
    </SimpleObject>
    
</SimpleObjectBase>

dnn example As you can see in the example, the name of the attribute is followed by the id and the name of the image on the network in curly and parentheses. The files for this example are included with the package.

3. Supported frameworks

Framework Weight File Config File Label File
DarkNet .weight file .cfg file
TensorFlow frozen_inference_graph.pb files generated .pbtxt file .pbtxt file
Clone this wiki locally