Jetson Inference
DNN Vision Library

Object detection DNN (SSD, DetectNet) More...

Classes

class  detectNet
 Object recognition and localization networks with TensorRT support. More...
 

Macros

#define DETECTNET_DEFAULT_INPUT   "data"
 Name of default input blob for DetectNet caffe model. More...
 
#define DETECTNET_DEFAULT_COVERAGE   "coverage"
 Name of default output blob of the coverage map for DetectNet caffe model. More...
 
#define DETECTNET_DEFAULT_BBOX   "bboxes"
 Name of default output blob of the grid of bounding boxes for DetectNet caffe model. More...
 
#define DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD   0.5f
 Default value of the minimum detection threshold. More...
 
#define DETECTNET_DEFAULT_CLUSTERING_THRESHOLD   0.75f
 Default value of the clustering area-of-overlap threshold. More...
 
#define DETECTNET_DEFAULT_THRESHOLD   DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD
 Default value of the minimum detection threshold. More...
 
#define DETECTNET_DEFAULT_ALPHA   120
 Default alpha blending value used during overlay. More...
 
#define DETECTNET_MODEL_TYPE   "detection"
 The model type for detectNet in data/networks/models.json. More...
 
#define DETECTNET_USAGE_STRING
 Standard command-line options able to be passed to detectNet::Create() More...
 

Detailed Description

Object detection DNN (SSD, DetectNet)


Class Documentation

◆ detectNet

class detectNet

Object recognition and localization networks with TensorRT support.

Inheritance diagram for detectNet:
tensorNet

Public Types

enum  OverlayFlags {
  OVERLAY_NONE = 0, OVERLAY_BOX = (1 << 0), OVERLAY_LABEL = (1 << 1), OVERLAY_CONFIDENCE = (1 << 2),
  OVERLAY_TRACKING = (1 << 3), OVERLAY_LINES = (1 << 4), OVERLAY_DEFAULT = OVERLAY_BOX|OVERLAY_LABEL|OVERLAY_CONFIDENCE
}
 Overlay flags (can be OR'd together). More...
 

Public Member Functions

virtual ~detectNet ()
 Destory. More...
 
template<typename T >
int Detect (T *image, uint32_t width, uint32_t height, Detection **detections, uint32_t overlay=OVERLAY_DEFAULT)
 Detect object locations from an image, returning an array containing the detection results. More...
 
template<typename T >
int Detect (T *image, uint32_t width, uint32_t height, Detection *detections, uint32_t overlay=OVERLAY_DEFAULT)
 Detect object locations in an image, into an array of the results allocated by the user. More...
 
int Detect (void *input, uint32_t width, uint32_t height, imageFormat format, Detection **detections, uint32_t overlay=OVERLAY_DEFAULT)
 Detect object locations from an image, returning an array containing the detection results. More...
 
int Detect (void *input, uint32_t width, uint32_t height, imageFormat format, Detection *detections, uint32_t overlay=OVERLAY_DEFAULT)
 Detect object locations from an image, into an array of the results allocated by the user. More...
 
int Detect (float *input, uint32_t width, uint32_t height, Detection **detections, uint32_t overlay=OVERLAY_DEFAULT)
 Detect object locations from an RGBA image, returning an array containing the detection results. More...
 
int Detect (float *input, uint32_t width, uint32_t height, Detection *detections, uint32_t overlay=OVERLAY_DEFAULT)
 Detect object locations in an RGBA image, into an array of the results allocated by the user. More...
 
template<typename T >
bool Overlay (T *input, T *output, uint32_t width, uint32_t height, Detection *detections, uint32_t numDetections, uint32_t flags=OVERLAY_DEFAULT)
 Draw the detected bounding boxes overlayed on an RGBA image. More...
 
bool Overlay (void *input, void *output, uint32_t width, uint32_t height, imageFormat format, Detection *detections, uint32_t numDetections, uint32_t flags=OVERLAY_DEFAULT)
 Draw the detected bounding boxes overlayed on an RGBA image. More...
 
float GetThreshold () const
 Retrieve the minimum threshold for detection. More...
 
void SetThreshold (float threshold)
 Set the minimum threshold for detection. More...
 
float GetConfidenceThreshold () const
 Retrieve the minimum threshold for detection. More...
 
void SetConfidenceThreshold (float threshold)
 Set the minimum threshold for detection. More...
 
float GetClusteringThreshold () const
 Retrieve the overlapping area % threshold for clustering. More...
 
void SetClusteringThreshold (float threshold)
 Set the overlapping area % threshold for clustering. More...
 
objectTrackerGetTracker () const
 Get the object tracker being used. More...
 
void SetTracker (objectTracker *tracker)
 Set the object tracker to be used. More...
 
uint32_t GetMaxDetections () const
 Retrieve the maximum number of simultaneous detections the network supports. More...
 
uint32_t GetNumClasses () const
 Retrieve the number of object classes supported in the detector. More...
 
const char * GetClassLabel (uint32_t index) const
 Retrieve the description of a particular class. More...
 
const char * GetClassDesc (uint32_t index) const
 Retrieve the description of a particular class. More...
 
const char * GetClassSynset (uint32_t index) const
 Retrieve the class synset category of a particular class. More...
 
const char * GetClassPath () const
 Retrieve the path to the file containing the class descriptions. More...
 
float4 GetClassColor (uint32_t classIndex) const
 Retrieve the RGBA visualization color a particular class. More...
 
void SetClassColor (uint32_t classIndex, const float4 &color)
 Set the visualization color of a particular class of object. More...
 
void SetClassColor (uint32_t classIndex, float r, float g, float b, float a=255.0f)
 Set the visualization color of a particular class of object. More...
 
float GetLineWidth () const
 Retrieve the line width used during overlay when OVERLAY_LINES is used. More...
 
void SetLineWidth (float width)
 Set the line width used during overlay when OVERLAY_LINES is used. More...
 
float GetOverlayAlpha () const
 Retrieve the overlay alpha blending value for classes that don't have it explicitly set (between 0-255). More...
 
void SetOverlayAlpha (float alpha)
 Set overlay alpha blending value for all classes (between 0-255). More...
 
- Public Member Functions inherited from tensorNet
virtual ~tensorNet ()
 Destory. More...
 
bool LoadNetwork (const char *prototxt, const char *model, const char *mean=NULL, const char *input_blob="data", const char *output_blob="prob", uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true, nvinfer1::IInt8Calibrator *calibrator=NULL, cudaStream_t stream=NULL)
 Load a new network instance. More...
 
bool LoadNetwork (const char *prototxt, const char *model, const char *mean, const char *input_blob, const std::vector< std::string > &output_blobs, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true, nvinfer1::IInt8Calibrator *calibrator=NULL, cudaStream_t stream=NULL)
 Load a new network instance with multiple output layers. More...
 
bool LoadNetwork (const char *prototxt, const char *model, const char *mean, const std::vector< std::string > &input_blobs, const std::vector< std::string > &output_blobs, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true, nvinfer1::IInt8Calibrator *calibrator=NULL, cudaStream_t stream=NULL)
 Load a new network instance with multiple input layers. More...
 
bool LoadNetwork (const char *prototxt, const char *model, const char *mean, const char *input_blob, const Dims3 &input_dims, const std::vector< std::string > &output_blobs, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true, nvinfer1::IInt8Calibrator *calibrator=NULL, cudaStream_t stream=NULL)
 Load a new network instance (this variant is used for UFF models) More...
 
bool LoadNetwork (const char *prototxt, const char *model, const char *mean, const std::vector< std::string > &input_blobs, const std::vector< Dims3 > &input_dims, const std::vector< std::string > &output_blobs, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true, nvinfer1::IInt8Calibrator *calibrator=NULL, cudaStream_t stream=NULL)
 Load a new network instance with multiple input layers (used for UFF models) More...
 
bool LoadEngine (const char *engine_filename, const std::vector< std::string > &input_blobs, const std::vector< std::string > &output_blobs, nvinfer1::IPluginFactory *pluginFactory=NULL, deviceType device=DEVICE_GPU, cudaStream_t stream=NULL)
 Load a network instance from a serialized engine plan file. More...
 
bool LoadEngine (char *engine_stream, size_t engine_size, const std::vector< std::string > &input_blobs, const std::vector< std::string > &output_blobs, nvinfer1::IPluginFactory *pluginFactory=NULL, deviceType device=DEVICE_GPU, cudaStream_t stream=NULL)
 Load a network instance from a serialized engine plan file. More...
 
bool LoadEngine (nvinfer1::ICudaEngine *engine, const std::vector< std::string > &input_blobs, const std::vector< std::string > &output_blobs, deviceType device=DEVICE_GPU, cudaStream_t stream=NULL)
 Load network resources from an existing TensorRT engine instance. More...
 
bool LoadEngine (const char *filename, char **stream, size_t *size)
 Load a serialized engine plan file into memory. More...
 
void EnableLayerProfiler ()
 Manually enable layer profiling times. More...
 
void EnableDebug ()
 Manually enable debug messages and synchronization. More...
 
bool AllowGPUFallback () const
 Return true if GPU fallback is enabled. More...
 
deviceType GetDevice () const
 Retrieve the device being used for execution. More...
 
precisionType GetPrecision () const
 Retrieve the type of precision being used. More...
 
bool IsPrecision (precisionType type) const
 Check if a particular precision is being used. More...
 
cudaStream_t GetStream () const
 Retrieve the stream that the device is operating on. More...
 
cudaStream_t CreateStream (bool nonBlocking=true)
 Create and use a new stream for execution. More...
 
void SetStream (cudaStream_t stream)
 Set the stream that the device is operating on. More...
 
const char * GetPrototxtPath () const
 Retrieve the path to the network prototxt file. More...
 
const char * GetModelPath () const
 Retrieve the full path to model file, including the filename. More...
 
const char * GetModelFilename () const
 Retrieve the filename of the file, excluding the directory. More...
 
modelType GetModelType () const
 Retrieve the format of the network model. More...
 
bool IsModelType (modelType type) const
 Return true if the model is of the specified format. More...
 
uint32_t GetInputLayers () const
 Retrieve the number of input layers to the network. More...
 
uint32_t GetOutputLayers () const
 Retrieve the number of output layers to the network. More...
 
Dims3 GetInputDims (uint32_t layer=0) const
 Retrieve the dimensions of network input layer. More...
 
uint32_t GetInputWidth (uint32_t layer=0) const
 Retrieve the width of network input layer. More...
 
uint32_t GetInputHeight (uint32_t layer=0) const
 Retrieve the height of network input layer. More...
 
uint32_t GetInputSize (uint32_t layer=0) const
 Retrieve the size (in bytes) of network input layer. More...
 
float * GetInputPtr (uint32_t layer=0) const
 Get the CUDA pointer to the input layer's memory. More...
 
Dims3 GetOutputDims (uint32_t layer=0) const
 Retrieve the dimensions of network output layer. More...
 
uint32_t GetOutputWidth (uint32_t layer=0) const
 Retrieve the width of network output layer. More...
 
uint32_t GetOutputHeight (uint32_t layer=0) const
 Retrieve the height of network output layer. More...
 
uint32_t GetOutputSize (uint32_t layer=0) const
 Retrieve the size (in bytes) of network output layer. More...
 
float * GetOutputPtr (uint32_t layer=0) const
 Get the CUDA pointer to the output memory. More...
 
float GetNetworkFPS ()
 Retrieve the network frames per second (FPS). More...
 
float GetNetworkTime ()
 Retrieve the network runtime (in milliseconds). More...
 
const char * GetNetworkName () const
 Retrieve the network name (it's filename). More...
 
float2 GetProfilerTime (profilerQuery query)
 Retrieve the profiler runtime (in milliseconds). More...
 
float GetProfilerTime (profilerQuery query, profilerDevice device)
 Retrieve the profiler runtime (in milliseconds). More...
 
void PrintProfilerTimes ()
 Print the profiler times (in millseconds). More...
 

Static Public Member Functions

static uint32_t OverlayFlagsFromStr (const char *flags)
 Parse a string sequence into OverlayFlags enum. More...
 
static detectNetCreate (const char *network="ssd-mobilenet-v2", float threshold=DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true)
 Load a pre-trained model. More...
 
static detectNetCreate (const char *prototxt_path, const char *model_path, float mean_pixel=0.0f, const char *class_labels=NULL, float threshold=DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD, const char *input=DETECTNET_DEFAULT_INPUT, const char *coverage=DETECTNET_DEFAULT_COVERAGE, const char *bboxes=DETECTNET_DEFAULT_BBOX, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true)
 Load a custom network instance. More...
 
static detectNetCreate (const char *prototxt_path, const char *model_path, float mean_pixel, const char *class_labels, const char *class_colors, float threshold=DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD, const char *input=DETECTNET_DEFAULT_INPUT, const char *coverage=DETECTNET_DEFAULT_COVERAGE, const char *bboxes=DETECTNET_DEFAULT_BBOX, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true)
 Load a custom network instance. More...
 
static detectNetCreate (const char *model_path, const char *class_labels, float threshold, const char *input, const Dims3 &inputDims, const char *output, const char *numDetections, uint32_t maxBatchSize=DEFAULT_MAX_BATCH_SIZE, precisionType precision=TYPE_FASTEST, deviceType device=DEVICE_GPU, bool allowGPUFallback=true)
 Load a custom network instance of a UFF model. More...
 
static detectNetCreate (int argc, char **argv)
 Load a new network instance by parsing the command line. More...
 
static detectNetCreate (const commandLine &cmdLine)
 Load a new network instance by parsing the command line. More...
 
static const char * Usage ()
 Usage string for command line arguments to Create() More...
 
- Static Public Member Functions inherited from tensorNet
static bool LoadClassLabels (const char *filename, std::vector< std::string > &descriptions, int expectedClasses=-1)
 Load class descriptions from a label file. More...
 
static bool LoadClassLabels (const char *filename, std::vector< std::string > &descriptions, std::vector< std::string > &synsets, int expectedClasses=-1)
 Load class descriptions and synset strings from a label file. More...
 
static bool LoadClassColors (const char *filename, float4 *colors, int expectedClasses, float defaultAlpha=255.0f)
 Load class colors from a text file. More...
 
static bool LoadClassColors (const char *filename, float4 **colors, int expectedClasses, float defaultAlpha=255.0f)
 Load class colors from a text file. More...
 
static float4 GenerateColor (uint32_t classID, float alpha=255.0f)
 Procedurally generate a color for a given class index with the specified alpha value. More...
 
static precisionType SelectPrecision (precisionType precision, deviceType device=DEVICE_GPU, bool allowInt8=true)
 Resolve a desired precision to a specific one that's available. More...
 
static precisionType FindFastestPrecision (deviceType device=DEVICE_GPU, bool allowInt8=true)
 Determine the fastest native precision on a device. More...
 
static std::vector< precisionTypeDetectNativePrecisions (deviceType device=DEVICE_GPU)
 Detect the precisions supported natively on a device. More...
 
static bool DetectNativePrecision (const std::vector< precisionType > &nativeTypes, precisionType type)
 Detect if a particular precision is supported natively. More...
 
static bool DetectNativePrecision (precisionType precision, deviceType device=DEVICE_GPU)
 Detect if a particular precision is supported natively. More...
 

Protected Member Functions

 detectNet (float meanPixel=0.0f)
 
bool allocDetections ()
 
bool loadClassInfo (const char *filename)
 
bool loadClassColors (const char *filename)
 
bool init (const char *prototxt_path, const char *model_path, const char *class_labels, const char *class_colors, float threshold, const char *input, const char *coverage, const char *bboxes, uint32_t maxBatchSize, precisionType precision, deviceType device, bool allowGPUFallback)
 
bool preProcess (void *input, uint32_t width, uint32_t height, imageFormat format)
 
int postProcess (void *input, uint32_t width, uint32_t height, imageFormat format, Detection *detections)
 
int postProcessSSD_UFF (Detection *detections, uint32_t width, uint32_t height)
 
int postProcessSSD_ONNX (Detection *detections, uint32_t width, uint32_t height)
 
int postProcessDetectNet (Detection *detections, uint32_t width, uint32_t height)
 
int postProcessDetectNet_v2 (Detection *detections, uint32_t width, uint32_t height)
 
int clusterDetections (Detection *detections, int n)
 
void sortDetections (Detection *detections, int numDetections)
 
- Protected Member Functions inherited from tensorNet
 tensorNet ()
 Constructor. More...
 
bool ProcessNetwork (bool sync=true)
 Execute processing of the network. More...
 
bool ProfileModel (const std::string &deployFile, const std::string &modelFile, const std::vector< std::string > &inputs, const std::vector< Dims3 > &inputDims, const std::vector< std::string > &outputs, uint32_t maxBatchSize, precisionType precision, deviceType device, bool allowGPUFallback, nvinfer1::IInt8Calibrator *calibrator, char **engineStream, size_t *engineSize)
 Create and output an optimized network model. More...
 
bool ConfigureBuilder (nvinfer1::IBuilder *builder, uint32_t maxBatchSize, uint32_t workspaceSize, precisionType precision, deviceType device, bool allowGPUFallback, nvinfer1::IInt8Calibrator *calibrator)
 Configure builder options. More...
 
bool ValidateEngine (const char *model_path, const char *cache_path, const char *checksum_path)
 Validate that the model already has a built TensorRT engine that exists and doesn't need updating. More...
 
void PROFILER_BEGIN (profilerQuery query)
 Begin a profiling query, before network is run. More...
 
void PROFILER_END (profilerQuery query)
 End a profiling query, after the network is run. More...
 
bool PROFILER_QUERY (profilerQuery query)
 Query the CUDA part of a profiler query. More...
 

Protected Attributes

objectTrackermTracker
 
float mConfidenceThreshold
 
float mClusteringThreshold
 
float mMeanPixel
 
float mLineWidth
 
float mOverlayAlpha
 
float4 * mClassColors
 
std::vector< std::string > mClassDesc
 
std::vector< std::string > mClassSynset
 
std::string mClassPath
 
uint32_t mNumClasses
 
DetectionmDetectionSets
 
uint32_t mDetectionSet
 
uint32_t mMaxDetections
 
- Protected Attributes inherited from tensorNet
tensorNet::Logger gLogger
 
tensorNet::Profiler gProfiler
 
std::string mPrototxtPath
 
std::string mModelPath
 
std::string mModelFile
 
std::string mMeanPath
 
std::string mCacheEnginePath
 
std::string mCacheCalibrationPath
 
std::string mChecksumPath
 
deviceType mDevice
 
precisionType mPrecision
 
modelType mModelType
 
cudaStream_t mStream
 
cudaEvent_t mEventsGPU [PROFILER_TOTAL *2]
 
timespec mEventsCPU [PROFILER_TOTAL *2]
 
nvinfer1::IRuntime * mInfer
 
nvinfer1::ICudaEngine * mEngine
 
nvinfer1::IExecutionContext * mContext
 
float2 mProfilerTimes [PROFILER_TOTAL+1]
 
uint32_t mProfilerQueriesUsed
 
uint32_t mProfilerQueriesDone
 
uint32_t mWorkspaceSize
 
uint32_t mMaxBatchSize
 
bool mEnableProfiler
 
bool mEnableDebug
 
bool mAllowGPUFallback
 
void ** mBindings
 
std::vector< layerInfomInputs
 
std::vector< layerInfomOutputs
 

Static Protected Attributes

static const uint32_t mNumDetectionSets = 16
 

Member Enumeration Documentation

◆ OverlayFlags

Overlay flags (can be OR'd together).

Enumerator
OVERLAY_NONE 

No overlay.

OVERLAY_BOX 

Overlay the object bounding boxes (filled)

OVERLAY_LABEL 

Overlay the class description labels.

OVERLAY_CONFIDENCE 

Overlay the detection confidence values.

OVERLAY_TRACKING 

Overlay tracking information (like track ID)

OVERLAY_LINES 

Overlay the bounding box lines (unfilled)

OVERLAY_DEFAULT 

The default choice of overlay.

Constructor & Destructor Documentation

◆ ~detectNet()

virtual detectNet::~detectNet ( )
virtual

Destory.

◆ detectNet()

detectNet::detectNet ( float  meanPixel = 0.0f)
protected

Member Function Documentation

◆ allocDetections()

bool detectNet::allocDetections ( )
protected

◆ clusterDetections()

int detectNet::clusterDetections ( Detection detections,
int  n 
)
protected

◆ Create() [1/6]

static detectNet* detectNet::Create ( const char *  model_path,
const char *  class_labels,
float  threshold,
const char *  input,
const Dims3 inputDims,
const char *  output,
const char *  numDetections,
uint32_t  maxBatchSize = DEFAULT_MAX_BATCH_SIZE,
precisionType  precision = TYPE_FASTEST,
deviceType  device = DEVICE_GPU,
bool  allowGPUFallback = true 
)
static

Load a custom network instance of a UFF model.

Parameters
model_pathFile path to the UFF model
class_labelsFile path to list of class name labels
thresholddefault minimum threshold for detection
inputName of the input layer blob.
inputDimsDimensions of the input layer blob.
outputName of the output layer blob containing the bounding boxes, ect.
numDetectionsName of the output layer blob containing the detection count.
maxBatchSizeThe maximum batch size that the network will support and be optimized for.

◆ Create() [2/6]

static detectNet* detectNet::Create ( const char *  network = "ssd-mobilenet-v2",
float  threshold = DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD,
uint32_t  maxBatchSize = DEFAULT_MAX_BATCH_SIZE,
precisionType  precision = TYPE_FASTEST,
deviceType  device = DEVICE_GPU,
bool  allowGPUFallback = true 
)
static

Load a pre-trained model.

Parameters
networkthe pre-trained model to load (
See also
DETECTNET_USAGE_STRING for models)
Parameters
thresholddefault minimum threshold for detection
maxBatchSizeThe maximum batch size that the network will support and be optimized for.

◆ Create() [3/6]

static detectNet* detectNet::Create ( const char *  prototxt_path,
const char *  model_path,
float  mean_pixel,
const char *  class_labels,
const char *  class_colors,
float  threshold = DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD,
const char *  input = DETECTNET_DEFAULT_INPUT,
const char *  coverage = DETECTNET_DEFAULT_COVERAGE,
const char *  bboxes = DETECTNET_DEFAULT_BBOX,
uint32_t  maxBatchSize = DEFAULT_MAX_BATCH_SIZE,
precisionType  precision = TYPE_FASTEST,
deviceType  device = DEVICE_GPU,
bool  allowGPUFallback = true 
)
static

Load a custom network instance.

Parameters
prototxt_pathFile path to the deployable network prototxt
model_pathFile path to the caffemodel
mean_pixelInput transform subtraction value (use 0.0 if the network already does this)
class_labelsFile path to list of class name labels
class_colorsFile path to list of class colors
thresholddefault minimum threshold for detection
inputName of the input layer blob.
coverageName of the output coverage classifier layer blob, which contains the confidence values for each bbox.
bboxesName of the output bounding box layer blob, which contains a grid of rectangles in the image.
maxBatchSizeThe maximum batch size that the network will support and be optimized for.

◆ Create() [4/6]

static detectNet* detectNet::Create ( const char *  prototxt_path,
const char *  model_path,
float  mean_pixel = 0.0f,
const char *  class_labels = NULL,
float  threshold = DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD,
const char *  input = DETECTNET_DEFAULT_INPUT,
const char *  coverage = DETECTNET_DEFAULT_COVERAGE,
const char *  bboxes = DETECTNET_DEFAULT_BBOX,
uint32_t  maxBatchSize = DEFAULT_MAX_BATCH_SIZE,
precisionType  precision = TYPE_FASTEST,
deviceType  device = DEVICE_GPU,
bool  allowGPUFallback = true 
)
static

Load a custom network instance.

Parameters
prototxt_pathFile path to the deployable network prototxt
model_pathFile path to the caffemodel
mean_pixelInput transform subtraction value (use 0.0 if the network already does this)
class_labelsFile path to list of class name labels
thresholddefault minimum threshold for detection
inputName of the input layer blob.
coverageName of the output coverage classifier layer blob, which contains the confidence values for each bbox.
bboxesName of the output bounding box layer blob, which contains a grid of rectangles in the image.
maxBatchSizeThe maximum batch size that the network will support and be optimized for.

◆ Create() [5/6]

static detectNet* detectNet::Create ( const commandLine cmdLine)
static

Load a new network instance by parsing the command line.

◆ Create() [6/6]

static detectNet* detectNet::Create ( int  argc,
char **  argv 
)
static

Load a new network instance by parsing the command line.

◆ Detect() [1/6]

int detectNet::Detect ( float *  input,
uint32_t  width,
uint32_t  height,
Detection **  detections,
uint32_t  overlay = OVERLAY_DEFAULT 
)

Detect object locations from an RGBA image, returning an array containing the detection results.

Deprecated:
this overload of Detect() provides legacy compatibility with float* type (RGBA32F).
Parameters
[in]inputfloat4 RGBA input image in CUDA device memory.
[in]widthwidth of the input image in pixels.
[in]heightheight of the input image in pixels.
[out]detectionspointer that will be set to array of detection results (residing in shared CPU/GPU memory)
[in]overlaybitwise OR combination of overlay flags (
See also
OverlayFlags and
Overlay()), or OVERLAY_NONE.
Returns
The number of detected objects, 0 if there were no detected objects, and -1 if an error was encountered.

◆ Detect() [2/6]

int detectNet::Detect ( float *  input,
uint32_t  width,
uint32_t  height,
Detection detections,
uint32_t  overlay = OVERLAY_DEFAULT 
)

Detect object locations in an RGBA image, into an array of the results allocated by the user.

Deprecated:
this overload of Detect() provides legacy compatibility with float* type (RGBA32F).
Parameters
[in]inputfloat4 RGBA input image in CUDA device memory.
[in]widthwidth of the input image in pixels.
[in]heightheight of the input image in pixels.
[out]detectionspointer to user-allocated array that will be filled with the detection results.
See also
GetMaxDetections() for the number of detection results that should be allocated in this buffer.
Parameters
[in]overlaybitwise OR combination of overlay flags (
See also
OverlayFlags and
Overlay()), or OVERLAY_NONE.
Returns
The number of detected objects, 0 if there were no detected objects, and -1 if an error was encountered.

◆ Detect() [3/6]

template<typename T >
int detectNet::Detect ( T *  image,
uint32_t  width,
uint32_t  height,
Detection **  detections,
uint32_t  overlay = OVERLAY_DEFAULT 
)
inline

Detect object locations from an image, returning an array containing the detection results.

Parameters
[in]inputinput image in CUDA device memory (uchar3/uchar4/float3/float4)
[in]widthwidth of the input image in pixels.
[in]heightheight of the input image in pixels.
[out]detectionspointer that will be set to array of detection results (residing in shared CPU/GPU memory)
[in]overlaybitwise OR combination of overlay flags (
See also
OverlayFlags and
Overlay()), or OVERLAY_NONE.
Returns
The number of detected objects, 0 if there were no detected objects, and -1 if an error was encountered.

◆ Detect() [4/6]

template<typename T >
int detectNet::Detect ( T *  image,
uint32_t  width,
uint32_t  height,
Detection detections,
uint32_t  overlay = OVERLAY_DEFAULT 
)
inline

Detect object locations in an image, into an array of the results allocated by the user.

Parameters
[in]inputinput image in CUDA device memory (uchar3/uchar4/float3/float4)
[in]widthwidth of the input image in pixels.
[in]heightheight of the input image in pixels.
[out]detectionspointer to user-allocated array that will be filled with the detection results.
See also
GetMaxDetections() for the number of detection results that should be allocated in this buffer.
Parameters
[in]overlaybitwise OR combination of overlay flags (
See also
OverlayFlags and
Overlay()), or OVERLAY_NONE.
Returns
The number of detected objects, 0 if there were no detected objects, and -1 if an error was encountered.

◆ Detect() [5/6]

int detectNet::Detect ( void *  input,
uint32_t  width,
uint32_t  height,
imageFormat  format,
Detection **  detections,
uint32_t  overlay = OVERLAY_DEFAULT 
)

Detect object locations from an image, returning an array containing the detection results.

Parameters
[in]inputinput image in CUDA device memory (uchar3/uchar4/float3/float4)
[in]widthwidth of the input image in pixels.
[in]heightheight of the input image in pixels.
[out]detectionspointer that will be set to array of detection results (residing in shared CPU/GPU memory)
[in]overlaybitwise OR combination of overlay flags (
See also
OverlayFlags and
Overlay()), or OVERLAY_NONE.
Returns
The number of detected objects, 0 if there were no detected objects, and -1 if an error was encountered.

◆ Detect() [6/6]

int detectNet::Detect ( void *  input,
uint32_t  width,
uint32_t  height,
imageFormat  format,
Detection detections,
uint32_t  overlay = OVERLAY_DEFAULT 
)

Detect object locations from an image, into an array of the results allocated by the user.

Parameters
[in]inputinput image in CUDA device memory (uchar3/uchar4/float3/float4)
[in]widthwidth of the input image in pixels.
[in]heightheight of the input image in pixels.
[out]detectionspointer to user-allocated array that will be filled with the detection results.
See also
GetMaxDetections() for the number of detection results that should be allocated in this buffer.
Parameters
[in]overlaybitwise OR combination of overlay flags (
See also
OverlayFlags and
Overlay()), or OVERLAY_NONE.
Returns
The number of detected objects, 0 if there were no detected objects, and -1 if an error was encountered.

◆ GetClassColor()

float4 detectNet::GetClassColor ( uint32_t  classIndex) const
inline

Retrieve the RGBA visualization color a particular class.

◆ GetClassDesc()

const char* detectNet::GetClassDesc ( uint32_t  index) const
inline

Retrieve the description of a particular class.

◆ GetClassLabel()

const char* detectNet::GetClassLabel ( uint32_t  index) const
inline

Retrieve the description of a particular class.

◆ GetClassPath()

const char* detectNet::GetClassPath ( ) const
inline

Retrieve the path to the file containing the class descriptions.

◆ GetClassSynset()

const char* detectNet::GetClassSynset ( uint32_t  index) const
inline

Retrieve the class synset category of a particular class.

◆ GetClusteringThreshold()

float detectNet::GetClusteringThreshold ( ) const
inline

Retrieve the overlapping area % threshold for clustering.

◆ GetConfidenceThreshold()

float detectNet::GetConfidenceThreshold ( ) const
inline

Retrieve the minimum threshold for detection.

◆ GetLineWidth()

float detectNet::GetLineWidth ( ) const
inline

Retrieve the line width used during overlay when OVERLAY_LINES is used.

◆ GetMaxDetections()

uint32_t detectNet::GetMaxDetections ( ) const
inline

Retrieve the maximum number of simultaneous detections the network supports.

Knowing this is useful for allocating the buffers to store the output detection results.

◆ GetNumClasses()

uint32_t detectNet::GetNumClasses ( ) const
inline

Retrieve the number of object classes supported in the detector.

◆ GetOverlayAlpha()

float detectNet::GetOverlayAlpha ( ) const
inline

Retrieve the overlay alpha blending value for classes that don't have it explicitly set (between 0-255).

◆ GetThreshold()

float detectNet::GetThreshold ( ) const
inline

Retrieve the minimum threshold for detection.

Deprecated:
please use GetConfidenceThreshold() instead

◆ GetTracker()

objectTracker* detectNet::GetTracker ( ) const
inline

Get the object tracker being used.

◆ init()

bool detectNet::init ( const char *  prototxt_path,
const char *  model_path,
const char *  class_labels,
const char *  class_colors,
float  threshold,
const char *  input,
const char *  coverage,
const char *  bboxes,
uint32_t  maxBatchSize,
precisionType  precision,
deviceType  device,
bool  allowGPUFallback 
)
protected

◆ loadClassColors()

bool detectNet::loadClassColors ( const char *  filename)
protected

◆ loadClassInfo()

bool detectNet::loadClassInfo ( const char *  filename)
protected

◆ Overlay() [1/2]

template<typename T >
bool detectNet::Overlay ( T *  input,
T *  output,
uint32_t  width,
uint32_t  height,
Detection detections,
uint32_t  numDetections,
uint32_t  flags = OVERLAY_DEFAULT 
)
inline

Draw the detected bounding boxes overlayed on an RGBA image.

Note
Overlay() will automatically be called by default by Detect(), if the overlay parameter is true
Parameters
inputinput image in CUDA device memory.
outputoutput image in CUDA device memory.
detectionsArray of detections allocated in CUDA device memory.

◆ Overlay() [2/2]

bool detectNet::Overlay ( void *  input,
void *  output,
uint32_t  width,
uint32_t  height,
imageFormat  format,
Detection detections,
uint32_t  numDetections,
uint32_t  flags = OVERLAY_DEFAULT 
)

Draw the detected bounding boxes overlayed on an RGBA image.

Note
Overlay() will automatically be called by default by Detect(), if the overlay parameter is true
Parameters
inputinput image in CUDA device memory.
outputoutput image in CUDA device memory.
detectionsArray of detections allocated in CUDA device memory.

◆ OverlayFlagsFromStr()

static uint32_t detectNet::OverlayFlagsFromStr ( const char *  flags)
static

Parse a string sequence into OverlayFlags enum.

Valid flags are "none", "box", "label", and "conf" and it is possible to combine flags (bitwise OR) together with commas or pipe (|) symbol. For example, the string sequence "box,label,conf" would return the flags OVERLAY_BOX|OVERLAY_LABEL|OVERLAY_CONFIDENCE.

◆ postProcess()

int detectNet::postProcess ( void *  input,
uint32_t  width,
uint32_t  height,
imageFormat  format,
Detection detections 
)
protected

◆ postProcessDetectNet()

int detectNet::postProcessDetectNet ( Detection detections,
uint32_t  width,
uint32_t  height 
)
protected

◆ postProcessDetectNet_v2()

int detectNet::postProcessDetectNet_v2 ( Detection detections,
uint32_t  width,
uint32_t  height 
)
protected

◆ postProcessSSD_ONNX()

int detectNet::postProcessSSD_ONNX ( Detection detections,
uint32_t  width,
uint32_t  height 
)
protected

◆ postProcessSSD_UFF()

int detectNet::postProcessSSD_UFF ( Detection detections,
uint32_t  width,
uint32_t  height 
)
protected

◆ preProcess()

bool detectNet::preProcess ( void *  input,
uint32_t  width,
uint32_t  height,
imageFormat  format 
)
protected

◆ SetClassColor() [1/2]

void detectNet::SetClassColor ( uint32_t  classIndex,
const float4 &  color 
)
inline

Set the visualization color of a particular class of object.

◆ SetClassColor() [2/2]

void detectNet::SetClassColor ( uint32_t  classIndex,
float  r,
float  g,
float  b,
float  a = 255.0f 
)
inline

Set the visualization color of a particular class of object.

◆ SetClusteringThreshold()

void detectNet::SetClusteringThreshold ( float  threshold)
inline

Set the overlapping area % threshold for clustering.

◆ SetConfidenceThreshold()

void detectNet::SetConfidenceThreshold ( float  threshold)
inline

Set the minimum threshold for detection.

◆ SetLineWidth()

void detectNet::SetLineWidth ( float  width)
inline

Set the line width used during overlay when OVERLAY_LINES is used.

◆ SetOverlayAlpha()

void detectNet::SetOverlayAlpha ( float  alpha)

Set overlay alpha blending value for all classes (between 0-255).

◆ SetThreshold()

void detectNet::SetThreshold ( float  threshold)
inline

Set the minimum threshold for detection.

Deprecated:
please use SetConfidenceThreshold() instead

◆ SetTracker()

void detectNet::SetTracker ( objectTracker tracker)
inline

Set the object tracker to be used.

◆ sortDetections()

void detectNet::sortDetections ( Detection detections,
int  numDetections 
)
protected

◆ Usage()

static const char* detectNet::Usage ( )
inlinestatic

Usage string for command line arguments to Create()

Member Data Documentation

◆ mClassColors

float4* detectNet::mClassColors
protected

◆ mClassDesc

std::vector<std::string> detectNet::mClassDesc
protected

◆ mClassPath

std::string detectNet::mClassPath
protected

◆ mClassSynset

std::vector<std::string> detectNet::mClassSynset
protected

◆ mClusteringThreshold

float detectNet::mClusteringThreshold
protected

◆ mConfidenceThreshold

float detectNet::mConfidenceThreshold
protected

◆ mDetectionSet

uint32_t detectNet::mDetectionSet
protected

◆ mDetectionSets

Detection* detectNet::mDetectionSets
protected

◆ mLineWidth

float detectNet::mLineWidth
protected

◆ mMaxDetections

uint32_t detectNet::mMaxDetections
protected

◆ mMeanPixel

float detectNet::mMeanPixel
protected

◆ mNumClasses

uint32_t detectNet::mNumClasses
protected

◆ mNumDetectionSets

const uint32_t detectNet::mNumDetectionSets = 16
staticprotected

◆ mOverlayAlpha

float detectNet::mOverlayAlpha
protected

◆ mTracker

objectTracker* detectNet::mTracker
protected

Macro Definition Documentation

◆ DETECTNET_DEFAULT_ALPHA

#define DETECTNET_DEFAULT_ALPHA   120

Default alpha blending value used during overlay.

◆ DETECTNET_DEFAULT_BBOX

#define DETECTNET_DEFAULT_BBOX   "bboxes"

Name of default output blob of the grid of bounding boxes for DetectNet caffe model.

◆ DETECTNET_DEFAULT_CLUSTERING_THRESHOLD

#define DETECTNET_DEFAULT_CLUSTERING_THRESHOLD   0.75f

Default value of the clustering area-of-overlap threshold.

◆ DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD

#define DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD   0.5f

Default value of the minimum detection threshold.

◆ DETECTNET_DEFAULT_COVERAGE

#define DETECTNET_DEFAULT_COVERAGE   "coverage"

Name of default output blob of the coverage map for DetectNet caffe model.

◆ DETECTNET_DEFAULT_INPUT

#define DETECTNET_DEFAULT_INPUT   "data"

Name of default input blob for DetectNet caffe model.

◆ DETECTNET_DEFAULT_THRESHOLD

#define DETECTNET_DEFAULT_THRESHOLD   DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD

Default value of the minimum detection threshold.

Deprecated:
please use DETECTNET_DEFAULT_CONFIDENCE_THRESHOLD instead

◆ DETECTNET_MODEL_TYPE

#define DETECTNET_MODEL_TYPE   "detection"

The model type for detectNet in data/networks/models.json.

◆ DETECTNET_USAGE_STRING

#define DETECTNET_USAGE_STRING
Value:
"detectNet arguments: \n" \
" --network=NETWORK pre-trained model to load, one of the following:\n" \
" * ssd-mobilenet-v1\n" \
" * ssd-mobilenet-v2 (default)\n" \
" * ssd-inception-v2\n" \
" * peoplenet\n" \
" * peoplenet-pruned\n" \
" * dashcamnet\n" \
" * trafficcamnet\n" \
" * facedetect\n" \
" --model=MODEL path to custom model to load (caffemodel, uff, or onnx)\n" \
" --prototxt=PROTOTXT path to custom prototxt to load (for .caffemodel only)\n" \
" --labels=LABELS path to text file containing the labels for each class\n" \
" --input-blob=INPUT name of the input layer (default is '" DETECTNET_DEFAULT_INPUT "')\n" \
" --output-cvg=COVERAGE name of the coverage/confidence output layer (default is '" DETECTNET_DEFAULT_COVERAGE "')\n" \
" --output-bbox=BOXES name of the bounding output layer (default is '" DETECTNET_DEFAULT_BBOX "')\n" \
" --mean-pixel=PIXEL mean pixel value to subtract from input (default is 0.0)\n" \
" --confidence=CONF minimum confidence threshold for detection (default is 0.5)\n" \
" --clustering=CLUSTER minimum overlapping area threshold for clustering (default is 0.75)\n" \
" --alpha=ALPHA overlay alpha blending value, range 0-255 (default: 120)\n" \
" --overlay=OVERLAY detection overlay flags (e.g. --overlay=box,labels,conf)\n" \
" valid combinations are: 'box', 'lines', 'labels', 'conf', 'none'\n" \
" --profile enable layer profiling in TensorRT\n\n" \

Standard command-line options able to be passed to detectNet::Create()

DETECTNET_DEFAULT_COVERAGE
#define DETECTNET_DEFAULT_COVERAGE
Name of default output blob of the coverage map for DetectNet caffe model.
Definition: detectNet.h:40
DETECTNET_DEFAULT_INPUT
#define DETECTNET_DEFAULT_INPUT
Name of default input blob for DetectNet caffe model.
Definition: detectNet.h:34
DETECTNET_DEFAULT_BBOX
#define DETECTNET_DEFAULT_BBOX
Name of default output blob of the grid of bounding boxes for DetectNet caffe model.
Definition: detectNet.h:46