DriveWorks SDK Reference

| 0.6.67 Release

ObjectDetector

Detailed Description

Defines ObjectDetector module for object detection.

Data Structures

struct  dwObjectDetectorDNNParams
 
struct  dwObjectDetectorParams
 

Macros

#define DW_OBJECT_DETECTOR_MAX_IMAGES   16
 Maximum number of images to run detector on. More...
 

Typedefs

typedef struct dwObjectDetectorObject * dwObjectDetectorHandle_t
 Handle to an object detector. More...
 

Functions

DW_API_PUBLIC dwStatus dwObjectDetector_getCoverageThreshold (float32_t *covThreshold, uint32_t classIdx, dwObjectDetectorHandle_t obj)
 Get coverage threshold for a given class. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_getCUDAStream (cudaStream_t *stream, dwObjectDetectorHandle_t obj)
 Gets the CUDA stream used. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_getDetectedObjects (dwObject *objectList, size_t *numObjects, uint32_t imageIdx, uint32_t classIdx, dwObjectDetectorHandle_t obj)
 Returns detected objects for one of the images given to dwObjectDetector_inferDeviceAsync. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_getROI (dwRect *ROI, dwTransformation2D *outputToObject, uint32_t imageIdx, dwObjectDetectorHandle_t obj)
 Returns the region of interest and the 2D transformation from the image coordinate system to object coordinate system at given index. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_inferDeviceAsync (const dwImageCUDA *const *imageArray, uint32_t numImages, dwObjectDetectorHandle_t obj)
 Runs inference using the provided DNN model. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_initDefaultParams (dwObjectDetectorDNNParams *dnnParams, dwObjectDetectorParams *detectorParams)
 Initializes ObjectDetector parameters with default values. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_initialize (dwObjectDetectorHandle_t *obj, dwContextHandle_t ctx, dwDNNHandle_t dnn, const dwObjectDetectorDNNParams *dnnParams, const dwObjectDetectorParams *detectorParams)
 Initializes ObjectDetector module with a preloaded DNN inference module. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_initializeFromDriveNet (dwObjectDetectorHandle_t *obj, dwContextHandle_t ctx, dwDriveNetHandle_t drivenet, const dwObjectDetectorParams *detectorParams)
 Initializes ObjectDetector module with a DriveNet module. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_interpretHost (uint32_t numImages, dwObjectDetectorHandle_t obj)
 Output of the inference (dwObjectDetector_inferDeviceAsync) is interpreted to get the list of object proposals. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_isFuseObjectsEnabled (dwBool *enabled, dwObjectDetectorHandle_t obj)
 Returns a boolean indicating whether object fusing is enabled. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_release (dwObjectDetectorHandle_t *obj)
 Releases the ObjectDetector module. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_reset (dwObjectDetectorHandle_t obj)
 Resets ObjectDetector. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_setCoverageThreshold (float32_t covThreshold, uint32_t classIdx, dwObjectDetectorHandle_t obj)
 Set coverage threshold for a given class. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_setCUDAStream (cudaStream_t stream, dwObjectDetectorHandle_t obj)
 Sets the CUDA stream used. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_setEnableFuseObjects (dwBool enable, dwObjectDetectorHandle_t obj)
 Enables or disables objectFusing. More...
 
DW_API_PUBLIC dwStatus dwObjectDetector_setROI (uint32_t imageIdx, const dwRect *ROI, const dwTransformation2D *outputToObject, dwObjectDetectorHandle_t obj)
 Sets the region of interest for an image at given index, and the 2D transformation from the image coordinate system to object coordinate system. More...
 

Data Structure Documentation

◆ dwObjectDetectorDNNParams

struct dwObjectDetectorDNNParams
Data Fields
const char * bottomVisBlobName Name of the bottom visibility layer. Default is empty string.
const char * boundingBoxBlobName Name of the bounding box layer. Default is empty string.
float32_t boxScaleX1 Scale coefficient for X coordinate of upper-left corner of the RAW bounding box from DNN output.

Default is 1.0.

float32_t boxScaleX2 Scale coefficient for X coordinate of lower-right corner of the RAW bounding box from DNN output.

Default is 1.0.

float32_t boxScaleY1 Scale coefficient for Y coordinates of upper-left corner of the RAW bounding box from DNN output.

Default is 1.0

float32_t boxScaleY2 Scale coefficient for Y coordinates of lower-right corner of the RAW bounding box from DNN output.

Default is 1.0.

const char * coverageBlobName Name of the coverage layer. Default is empty string.
float32_t coverageThreshold[DW_OBJECT_MAX_CLASSES] Threshold for coverage for each class. Default is 0.5f for all classes.
dwDataConditionerParams dataConditionerParams DataConditioner parameters.
dwBool enable2_5D Whether the network can predict object orientation.
const char * horizontalVisBlobName Name of the horizontal visibility layer. Default is empty string.
uint32_t maxProposalsPerClass Maximum number of RAW detections directly obtained from DNN. Default is 100.
const char * orientationYawBlobName Name of the orientation yaw layer. Default is empty string.

◆ dwObjectDetectorParams

struct dwObjectDetectorParams
Data Fields
dwBool enableBoundingBoxClipping If enableBoundingBoxClipping is set to DW_TRUE, the bounding boxes are clipped to the image edges.

Default is DW_TRUE since it has been used during training.

dwBool enableFuseObjects If enableFuseObjects is set to DW_TRUE, all the objects proposals coming from all the images are treated as a single list of proposals.

Clustering is applied to this entire list, which results in a single list of objects. Default is DW_FALSE.

uint32_t maxNumImages Maximum number of images (cannot be larger than DW_DETECTOR_MAX_IMAGES). Default is 1.
dwRect ROIs[DW_OBJECT_DETECTOR_MAX_IMAGES] Region of interest for each image at the corresponding index.

The image is cropped at the given ROI. The cropped region is then be scaled while keeping the aspect ratio and is padded to have the right size for DNN. Default ROI is the whole image.

dwTransformation2D transformations[DW_OBJECT_DETECTOR_MAX_IMAGES] List of transformations from each image coordinate system to object coordinate system at the corresponding image index.

By default, the transformation matrices are identity.

Macro Definition Documentation

◆ DW_OBJECT_DETECTOR_MAX_IMAGES

#define DW_OBJECT_DETECTOR_MAX_IMAGES   16

Maximum number of images to run detector on.

Definition at line 61 of file Detector.h.

Typedef Documentation

◆ dwObjectDetectorHandle_t

typedef struct dwObjectDetectorObject* dwObjectDetectorHandle_t

Handle to an object detector.

Definition at line 67 of file Detector.h.

Function Documentation

◆ dwObjectDetector_getCoverageThreshold()

DW_API_PUBLIC dwStatus dwObjectDetector_getCoverageThreshold ( float32_t covThreshold,
uint32_t  classIdx,
dwObjectDetectorHandle_t  obj 
)

Get coverage threshold for a given class.

Parameters
[out]covThresholdCoverage threshold in [0.0, 1.0]
[in]classIdxIndex of class for which the coverage threshold should be returned.
[in]objA pointer to the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT

◆ dwObjectDetector_getCUDAStream()

DW_API_PUBLIC dwStatus dwObjectDetector_getCUDAStream ( cudaStream_t *  stream,
dwObjectDetectorHandle_t  obj 
)

Gets the CUDA stream used.

Parameters
[out]streamThe CUDA stream used.
[in]objA pointer to the ObjectDetector handle.
Returns
DW_INVALID_ARGUMENT, DW_SUCCESS

◆ dwObjectDetector_getDetectedObjects()

DW_API_PUBLIC dwStatus dwObjectDetector_getDetectedObjects ( dwObject objectList,
size_t *  numObjects,
uint32_t  imageIdx,
uint32_t  classIdx,
dwObjectDetectorHandle_t  obj 
)

Returns detected objects for one of the images given to dwObjectDetector_inferDeviceAsync.

Parameters
[out]objectListObject list where the detected objects are copied into.
[out]numObjectsNumber of objects that are detected for this image and class.
[in]imageIdxIndex of the image the array as given to dwObjectDetector_inferDeviceAsync.
[in]classIdxClass index.
[in]objSpecifies the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT
Note
objectList must be allocated with maxProposalsPerClass elements.

◆ dwObjectDetector_getROI()

DW_API_PUBLIC dwStatus dwObjectDetector_getROI ( dwRect ROI,
dwTransformation2D *  outputToObject,
uint32_t  imageIdx,
dwObjectDetectorHandle_t  obj 
)

Returns the region of interest and the 2D transformation from the image coordinate system to object coordinate system at given index.

Parameters
[out]ROIRegion of interest to be fed as input to network.
[out]outputToObject2D Transformation from output of the network to object coordinate system.
[in]imageIdxIndex of the image for which to set ROI and transformation.
[in]objSpecifies the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT
Note
If multiple regions for a single image are to given, the image array that's given as an input to dwObjectDetector_inferDeviceAsync must include the same image at the corresponding indices.

◆ dwObjectDetector_inferDeviceAsync()

DW_API_PUBLIC dwStatus dwObjectDetector_inferDeviceAsync ( const dwImageCUDA *const *  imageArray,
uint32_t  numImages,
dwObjectDetectorHandle_t  obj 
)

Runs inference using the provided DNN model.

The inference pipeline is as follows:

  1. DataPreparation: Input images are prepared by scaling, padding and other transformations set in dataConditionerParams at initialization time in order to have the right properties required by the DNN. If the given DNN model expects batched input, the given images are divided into batches, where each batch has the expected batch size.
  2. Inference: Inference is run on the prepared images / batches.
Parameters
[in]imageArrayArray storing pointers to images where the detector is to be applied.
[in]numImagesNumber of images provided in the array.
[in]objSpecifies the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT
Note
numImages must be divisible by the batch size of the network.

◆ dwObjectDetector_initDefaultParams()

DW_API_PUBLIC dwStatus dwObjectDetector_initDefaultParams ( dwObjectDetectorDNNParams dnnParams,
dwObjectDetectorParams detectorParams 
)

Initializes ObjectDetector parameters with default values.

Parameters
[out]dnnParamsObjectDetector DNN parameters.
[out]detectorParamsObjectDetector parameters.
Returns
DW_SUCCESS, DW_INVALID_ARGUMENT

◆ dwObjectDetector_initialize()

DW_API_PUBLIC dwStatus dwObjectDetector_initialize ( dwObjectDetectorHandle_t obj,
dwContextHandle_t  ctx,
dwDNNHandle_t  dnn,
const dwObjectDetectorDNNParams dnnParams,
const dwObjectDetectorParams detectorParams 
)

Initializes ObjectDetector module with a preloaded DNN inference module.

Parameters
[out]objA pointer to ObjectDetector handle that is initialized from parameters.
[in]ctxSpecifies the handle to the context.
[in]dnnSpecifies the handle to the dnn module which is initialized with detector network.
[in]dnnParamsA pointer to ObjectDetectorDNN parameters.
[in]detectorParamsA pointer to ObjectDetector parameters.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT
Note
DNN model is expected to provide two output blobs: A blob for coverage and a blob for bounding box.

The number of channels in the coverage blob is equal to the number of classes that the network detects.

The number of channels in the bounding box blob is equal to the 4 times number of classes that the network detects.

For example, for detecting cars and pedestrians, the first channel of the coverage blob refers to the coverage of cars, and the first four channels of the bounding box blob refers to the top left and bottom right corners of car bounding boxes. The second channel of the coverage blob refers to the coverage of pedestrians, and the second four channels of the bounding box blob refers to the top left and bottom right corners of pedestrian bounding boxes.

Since it is unknown to the model which channel refers to which class, they are assigned class IDs instead, where class ID refers to the channel index of the network output. In the above example, the class ID of the car objects is 0, whereas the class ID of pedestrian objects is 1.

◆ dwObjectDetector_initializeFromDriveNet()

DW_API_PUBLIC dwStatus dwObjectDetector_initializeFromDriveNet ( dwObjectDetectorHandle_t obj,
dwContextHandle_t  ctx,
dwDriveNetHandle_t  drivenet,
const dwObjectDetectorParams detectorParams 
)

Initializes ObjectDetector module with a DriveNet module.

Parameters
[out]objA pointer to ObjectDetector handle that is initialized from parameters.
[in]ctxSpecifies the handle to the context.
[in]drivenetSpecifies the handle to the DriveNet module.
[in]detectorParamsA pointer to ObjectDetector parameters.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT

◆ dwObjectDetector_interpretHost()

DW_API_PUBLIC dwStatus dwObjectDetector_interpretHost ( uint32_t  numImages,
dwObjectDetectorHandle_t  obj 
)

Output of the inference (dwObjectDetector_inferDeviceAsync) is interpreted to get the list of object proposals.

If fusing is activated, proposals coming from different images is filled into a single list.

Parameters
[in]numImagesNumber of images provided in the array in dwObjectDetector_inferDeviceAsync call.
[in]objSpecifies the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT

◆ dwObjectDetector_isFuseObjectsEnabled()

DW_API_PUBLIC dwStatus dwObjectDetector_isFuseObjectsEnabled ( dwBool enabled,
dwObjectDetectorHandle_t  obj 
)

Returns a boolean indicating whether object fusing is enabled.

Parameters
[out]enabledBoolean indicating whether object fusing is enabled.
[in]objA pointer to the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT

◆ dwObjectDetector_release()

DW_API_PUBLIC dwStatus dwObjectDetector_release ( dwObjectDetectorHandle_t obj)

Releases the ObjectDetector module.

Parameters
[in]objA pointer to the object handle to release.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST
Note
This method renders the handle unusable.

◆ dwObjectDetector_reset()

DW_API_PUBLIC dwStatus dwObjectDetector_reset ( dwObjectDetectorHandle_t  obj)

Resets ObjectDetector.

Parameters
[in]objHandle to reset.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST

◆ dwObjectDetector_setCoverageThreshold()

DW_API_PUBLIC dwStatus dwObjectDetector_setCoverageThreshold ( float32_t  covThreshold,
uint32_t  classIdx,
dwObjectDetectorHandle_t  obj 
)

Set coverage threshold for a given class.

Parameters
[in]covThresholdCoverage threshold in [0.0, 1.0]
[in]classIdxIndex of class for which the coverage threshold should be set.
[in]objA pointer to the ObjectDetector handle that is updated
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST

◆ dwObjectDetector_setCUDAStream()

DW_API_PUBLIC dwStatus dwObjectDetector_setCUDAStream ( cudaStream_t  stream,
dwObjectDetectorHandle_t  obj 
)

Sets the CUDA stream used.

Parameters
[in]streamThe CUDA stream used.
[in]objA pointer to the ObjectDetector handle that is updated.
Returns
DW_INVALID_ARGUMENT, DW_SUCCESS

◆ dwObjectDetector_setEnableFuseObjects()

DW_API_PUBLIC dwStatus dwObjectDetector_setEnableFuseObjects ( dwBool  enable,
dwObjectDetectorHandle_t  obj 
)

Enables or disables objectFusing.

Parameters
[in]enableBoolean indicating whether object fusing should be enabled.
[in]objA pointer to the ObjectDetector handle that is updated.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST

◆ dwObjectDetector_setROI()

DW_API_PUBLIC dwStatus dwObjectDetector_setROI ( uint32_t  imageIdx,
const dwRect ROI,
const dwTransformation2D *  outputToObject,
dwObjectDetectorHandle_t  obj 
)

Sets the region of interest for an image at given index, and the 2D transformation from the image coordinate system to object coordinate system.

Parameters
[in]imageIdxIndex of the image for which to set ROI and transformation.
[in]ROIRegion of interest to be fed as input to network.
[in]outputToObject2D Transformation from output of the network to object coordinate system.
[in]objSpecifies the ObjectDetector handle.
Returns
DW_SUCCESS, DW_INVALID_HANDLE, DW_BAD_CAST, DW_INVALID_ARGUMENT
Note
If multiple regions for a single image are to be given, the image array that's given as an input to dwObjectDetector_inferDeviceAsync must include the same image at the corresponding indices.