|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef REIDLIB_REID_HPP_
19 #define REIDLIB_REID_HPP_
26 #include <opencv2/core.hpp>
30 #include <NvOnnxParser.h>
31 #include "modules/ReID/IReID.hpp"
32 #include "modules/ReID/ReIDFeatureGallery.hpp"
33 #include "modules/ReID/ReIDFrameTransformTexture.hpp"
34 #include "modules/ReID/ReIDCropScaler.hpp"
35 #include "modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp"
36 #include "modules/NvMultiObjectTracker/NvTrackerParams.hpp"
37 #include "modules/FrameTransform/trtModule.hpp"
52 ReIDConfigParams(
const std::string &configFilePath,
const std::string moduleName,
const std::string submoduleName);
64 void read(
const YAML::Node &fn)
override;
89 bool m_useExternalImages;
90 std::string m_extImagePath;
103 ReID(
const std::string &configFilePath);
111 ReID(
const std::string &configFilePath,
const std::string &modelName,
const bool calDisMaha=
true);
124 const std::shared_ptr<NvTrackedObjectManager> &targetManager
143 const std::map<NvMOTStreamId, NvMOTFrame *>& inputMeta,
144 std::map<
NvMOTStreamId, std::deque<DetectedObjInfo>> &detectedObjects,
const bool isForReAssoc
181 #ifdef VIZ_DEBUG_REID
187 void vizImagePatches(
188 const std::map<
NvMOTStreamId, std::map<uint, cv::Mat > >& subImgs,
189 const std::map<NvMOTStreamId, NvMOTFrame *> &inputMeta
193 void loadExtImagePatchesBatch();
216 #ifdef VIZ_DEBUG_REID
265 const std::map<NvMOTStreamId, NvMOTFrame *>& inputMeta,
266 std::map<
NvMOTStreamId, std::deque<DetectedObjInfo>> &detectedObjects
274 std::map<
NvMOTStreamId, std::deque<DetectedObjInfo>> &detectedObjects
307 #endif // REIDLIB_REID_HPP_
cudaStream_t m_cuStream
Cuda stream to run all GPU tasks.
int m_maxReidProductSizePerStream
Max reid CUDA mat size for each stream.
void initializeRuntime(const SourceFrameInfo &frameInfo, const uint maxTargetsPerStream, const std::shared_ptr< NvTrackedObjectManager > &targetManager) override
Initialize variables and allocate memories.
void removeStream(const NvMOTStreamId videoStreamId) override
Remove a stream's reid features.
ReIDConfigParams m_params
Config params for reid module.
REID_TYPES m_reidType
Type of reid.
void doInference(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta, std::map< NvMOTStreamId, std::deque< DetectedObjInfo >> &detectedObjects, const bool isForReAssoc) override
Extract ReID features from input images and save them in m_reidFeaturesDet_d.
float * m_inputBuf_h
Input patches to reid network.
int * m_targetInds4Rois_h
Target ind for each roi input.
std::shared_ptr< ReIDCropScaler > m_subImageCropScaler
Image crop scaler. Uses VPI crop scaler.
void getFeatures2Host()
Copy ReID features from device memory to host memory.
int m_maxTargetsPerStream
Max number of targets to keep per stream.
float m_minVisibility4ReidOutput
Minimum visibility to output the reid features.
std::vector< void * > m_bindings
Pointers to TensorRT tensors.
int * m_targetWork_1_h
Work space storing each target's info, size: m_maxTargetsToTrack.
int m_reidFeatureSize
Size of each reid feature.
cublasHandle_t m_cublasHandle
Cublas handle.
int m_outputInd
The index of pointer to output tensor.
int * m_targetInds4Rois_d
TrtModule m_inference
TensorRT module that runs the reid network.
REID_TYPES
Types of ReID usage.
int2 * m_reidProductSize_d
std::map< NvMOTStreamId, std::vector< std::pair< uint, NvMotDataTypes::Rect2f > > > m_inputRoisInBatch
Reid input rois to crop.
size_t m_workspaceSize
Work space for reid network in MiB.
void normalizaReIDFeatures()
Normalize ReID network output to ensure l2 norm equals to 1.
int * m_targetWork_3_h
Work space storing each target's info, size: m_maxTargetsToTrack.
int m_channel
Input image patch channel.
virtual ~ReID()
Release resources owned by the ReID instance.
Holds Reid Vector information for an object.
void multiplyReIDFeatures(const int streamInd, const NvMOTStreamId videoStreamId)
Compute dot products between detection and gallery ReID features.
bool m_useSegmentationMask4Input
Multiply input patches with segmentation mask, so background is set as zero.
int m_maxBatchSize
Maximum batch size for reid network.
void initializeModel() override
Create TensorRT inference engine; if engine does not exist, serialize from model file.
bool isModelInitialized() override
Report whether the inference model is initialized.
ReID(const std::string &configFilePath)
Construct a ReID instance from configuration.
std::shared_ptr< NvTrackedObjectManager > m_targetManager
Target manager providing target status to update feature gallery.
int2 * m_reidProductSize_h
Actual number of re-id products in each stream; x: NumOfFeaturesInGalleryThisStream,...
NvBufSurfaceColorFormat m_colorFormat
Color format of input to reid network.
bool m_keepAspc
Keep original aspect ratio when rescaling.
int m_normFeatureCudaBlockSize
Cuda block size for reid feature normalization.
int m_height
Input image patch height.
void update() override
Update ReID feature gallery after data association.
bool isRuntimeInitialized() override
Report whether runtime resources are initialized.
int outputTargetReIDInd(NvMOTStreamId streamId, uint targetInd) override
Output a target's ReID vector index in the batch tensor.
int * m_targetReidFeatureInds_d
std::map< NvMOTStreamId, std::pair< float *, std::map< int, int > > > m_detObjReidFeatures
Mapping each detected object to its reid features : {streamId, <each stream's reid features beginning...
bool m_isModelInit
Reid status if reid model initialized.
bool m_useVPICropScaler
Use VPI crop scaler instead of in built crop scaler.
int * m_targetWork_2_h
Work space storing each target's info, size: m_maxTargetsToTrack.
bool m_isRuntimeInit
Reid status if runtime variables initialized.
TRT module to perform various deep learning inference.
std::map< NvMOTStreamId, std::map< int, int > > m_featureIndFrameNumMap
Frame number of each gallery reid feature, keyed by stream and global feature index.
int m_inputInd
The index of pointer to input tensor.
ReIDConfigParams()
Construct a ReIDConfigParams instance.
float4 * m_inputRoisInBatch_d
void read(const YAML::Node &fn) override
Load configuration values from a YAML node.
float m_minVisibility4GalleryUpdate
Add ReID embedding to the gallery only if the visibility is not lower than this.
Provides common loading helpers for tracker configuration parameters.
std::vector< float > m_offsets
List of mean values of color components to be subtracted from input.
int m_width
Input image patch width.
int m_debugVerboseLevel
Debug message verbose mode level.
ReID module to extract deep ReID features from input frames and detected bounding boxes and save them...
int m_inputOrder
Input dimension order: 0: NCHW, 1: NHWC.
float4 * m_inputRoisInBatch_h
Reid input rois to crop stored in a continuous array.
Holds the capabilities and requirements reported by the tracker library.
float * m_reidFeaturesDet_h
Output features in a batch from reid network.
int m_numBboxes
Number of detected boxes in the current batch tracker recieved.
float * m_reidProduct_h
Dot products between detection and gallery reid features of each stream.
const REID_TYPES getReIDType() override
Get the configured ReID implementation type.
void computeReIDFeatureDist(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta)
Compute reid feature distance between detection and trackers.
int m_maxTargetsToTrack
Max number of targets to keep for all streams.
std::shared_ptr< ReIDFeatureGallery > m_reidFeatureGallery
ReID feature gallery for target management.
void outputReIDTensor(NvDsReidTensorBatch &reidTensorBatch) override
Output the ReID tensor of a batch.
void generateImagePatchesWithSegmentationMask(std::map< NvMOTStreamId, std::deque< DetectedObjInfo >> &detectedObjects)
Multiply segmentation mask with image patches for ReID input.
Stores configuration for a ReID inference module.
void queryParams(NvMOTQuery ¶msQuery)
Populate the capabilities reported to the tracker.
void computeMahalanobisDist(DisMahalanobisIn in)
Compute Mahalanobis distance for NvDeepSORT tracker.
void removeTrackerReIDFeature(const NvMOTStreamId videoStreamId, const std::shared_ptr< NvTrackedObject > target)
Removed a target's all reid features.
Defines the interface for extracting and managing ReID features.
bool m_outputReidTensor
Whether to output reid tensor.
int * m_targetReidFeatureInds_h
Tracked objects' list of re-id feature gallery inds, size: m_maxTargetsToTrack x m_reidHistorySize.
Represents a two-dimensional integer size.
Information about the input source frames for the input frame batch.
std::shared_ptr< ReIDFrameTransformTexture > m_subImageCropper2
Image cropper, may share with visual tracker in the future.
int m_reidHistorySize
Max number of reid features per object.
std::pair< const std::map< NvMOTStreamId, NvMOTFrame * > *, std::map< NvMOTStreamId, std::deque< DetectedObjInfo > > * > DisMahalanobisIn
Input data structure to compute Mahalanobis distance.
int * m_nearestIndReidDetTargets_d
float * m_confidenceReidDetTargets_h
Re-id similarity between each target and detection after taking nearest neighbors,...
bool m_calDisMaha
If the module needs to compute Mahalanobis distance.
float * m_confidenceReidDetTargets_d
std::vector< int > m_inferDims
Reid input dimension.
void extractImagePatchesBatch(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta, std::map< NvMOTStreamId, std::deque< DetectedObjInfo >> &detectedObjects)
Crop input frames using detected bboxes and rescale them as ReID network input size.
int * m_nearestIndReidDetTargets_h
Targets' nearest neighbor index in reid features.
bool m_addFeatureNormalization
Whether to perform additional feature normalization for network output features.
float * m_reidFeaturesDet_d
NvBufSurfaceColorFormat
Defines color formats for NvBufSurface.
float m_netScaleFactor
Input normalization factor.
ReID tensor of the batch.
void outputTargetReIDObj(NvMOTStreamId streamId, uint targetInd, NvDsReidTensorBatch &reidTensorBatch, NvDsObjReid &reidObj) override
Output a target's ReID vector information.
int m_maxStreams
Max number of streams.
std::shared_ptr< NvTrackerMultiThreadWorker< DisMahalanobisIn > > m_disMahaThreadWorker
Mahalanobis distance thread.
NvMotDataTypes::Size m_srcImageSize
Tracker library frame size.