|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef VISUALTRACKERLIB_DCFTRACKER_HPP_
19 #define VISUALTRACKERLIB_DCFTRACKER_HPP_
22 #include <unordered_map>
23 #include "modules/cuDCFv2/cuDCF.h"
24 #include "modules/VisualTracker/IVisualTracker.hpp"
25 #include "modules/NvMultiObjectTracker/NvTrackerParams.hpp"
26 #include "modules/NvMultiObjectTracker/NvTrackedObject.hpp"
27 #include "modules/utility/dataTypes.hpp"
30 #include "vpi/Stream.h"
31 #include "vpi/Image.h"
32 #include "vpi/Array.h"
33 #include "vpi/algo/CropScaler.h"
34 #include "vpi/algo/DCFTracker.h"
36 #if defined(__aarch64__)
38 #include <EGL/eglext.h>
71 void read(
const YAML::Node &fn)
override;
162 DCFTracker(
const std::string &configFilePath);
176 const uint maxDetectorBboxesPerFrame,
const std::shared_ptr<NvTrackedObjectManager> &targetManager
191 const std::map<NvMOTStreamId, NvMOTFrame *> inputMeta,
192 const std::map<
NvMOTStreamId, std::deque<DetectedObjInfo>> &detectedObjects
199 void update(
const std::map<NvMOTStreamId, NvMOTFrame *> inputMeta)
override;
273 #if defined (VIZ_DEBUG)
274 uint8_t *m_vpiObjPatches_h;
298 #if defined(__aarch64__)
301 std::unordered_map<const NvBufSurfaceParams *, CUgraphicsResource> m_graphicsResourceAddrMap;
302 std::unordered_map<const NvBufSurfaceParams *, CUeglFrame> m_eglFrameAddrMap;
313 void checkInputOutput(
const std::map<NvMOTStreamId, NvMOTFrame*> &inputMeta);
359 const std::map<
NvMOTStreamId, std::deque<DetectedObjInfo>> &detectedObjects
384 void performCropAndScale(
const std::map<NvMOTStreamId, NvMOTFrame *> &inputMeta,
const bool isForLocalization);
394 std::map<NvMOTStreamId, cv::Mat> m_srcFramesAtHost;
395 uint8_t *m_idata_host;
398 std::map<NvMOTStreamId, std::map<uint, cv::Mat > > getImagePatches2Host_OCV_batch();
400 std::shared_ptr<TrackerVizOutput> m_vizOutput;
401 float *m_batchCudaArray_host;
402 std::map<uint, std::pair<NvMOTStreamId, uint> > m_targetNumInd2RoisInBatchMapper;
404 float2 *m_targetDisplacement2D_h;
410 std::vector<cv::Mat> fetchBatchDataToHost_perObj(
const float *deviceData);
413 std::map<NvMOTStreamId, cv::Mat> getSrcImagesAtHost();
419 void uploadDeviceData2HostMemories(
const std::map<NvMOTStreamId, NvMOTFrame*> &inputMeta);
422 const std::map<NvMOTStreamId, cv::Mat>& getSrcFramesAtHost()
const {
return m_srcFramesAtHost; }
428 #endif // VISUALTRACKERLIB_DCFTRACKER_HPP_
VPIImageData * m_vpiInputFrameDataList
Sequence of VPIImageData pointers to input frames.
cudaEvent_t m_eventStart
Event start point for GPU timers.
std::map< NvMOTStreamId, uint32_t > isDetectionDonePerStream
Indicates whether inference completed for each stream.
DCFTrackerConfigParams m_params
Config params for visual tracker module.
int singleFeatureChannelElementSize
Number of elements in a single feature matrix.
size_t srcImagePitch
Memory pitch of the source frame.
int m_vizJpegImageQuality
JPEG output quality in the range [1, 100].
int m_debugParamInt2
Third integer debugging parameter.
bool m_useGray
Enables the grayscale pixel-intensity feature.
VPIArrayData m_vpiChannelWeightsArrayData
VPIArrayData for m_channelWeights.
Defines the interface implemented by visual trackers.
cudaStream_t m_cudaStream
CUDA stream used for tracker operations.
VISUAL_TRACKER_TYPES m_visualTrackerType
The type of visual tracker.
float m_debugParamFloat2
Third floating-point debugging parameter.
VPIImageData m_vpiObjPatchesData
VPIImageData corresponding to m_vpiObjPatches_d.
void initialize(const SourceFrameInfo &frameInfo, const uint maxTargetsToTrack, const uint maxDetectorBboxesPerFrame, const std::shared_ptr< NvTrackedObjectManager > &targetManager) override
Initialize variables and allocate memories.
uint32_t * m_trackerAge_d
Tracker age.
int m_cufftHandleQuantFactor
Clustering size for cuFFT plans.
float * m_trackingConfidence_d
void makeBatchAndSendFloatMatToDevice(const NvMotDataTypes::RowMajorMatrixXf &srcMat, void *devMem, uint batchSize, float *workarea_host)
Duplicate one host matrix into a batched float buffer and copy it to the device.
bool isInitialized() override
Report whether tracker initialization completed.
float * m_maxCorrResponse_d
The max correlation response for targets (a Batch CUDA memory buffer).
bool m_isInit
Indicates whether the parameters have been initialized.
VPIArrayData m_vpiMaxCorrResponseArrayData
VPIArrayData for m_maxCorrResponse_d.
bool m_vizWriteAllTrajectoriesOnEveryFrame
Write the whole frame with trajectories of all targets in the scene.
uint maxStreams
Maximum number of supported video streams.
std::string m_vizOutDirectory
The directory to write the outputs.
int m_debugVerboseLevel_cufft
Debug verbosity level for cuFFT.
bool skipBatchUpdate
Indicates whether to skip the update for the whole batch.
void cudaFilterUpdate()
Create and update the DCF filter.
VPIStream m_vpiStream
VPI stream used for all VPI operations.
int m_vizDebugStreamId
Video stream ID selected for visualization debugging.
NvMotDataTypes::Size originalSrcImageSize
The size of the original video source image.
VPIPayload m_vpiDcfPayload
VPI payload for DCF Tracker.
uint maxDetectorBboxesPerFrame
Maximum number of detector bounding boxes per frame.
NvMotDataTypes::Size singleFeatureMatSize
Dimensions of a single feature matrix processed on the GPU.
float * m_confidenceAtDetectedPt_d
Tracking confidence at each detector bbox center.
float m_filterLr
Learning rate for DCF filter in exponential moving average.
std::vector< VPIDCFTrackedBoundingBox > m_vpiDCFBboxes
List of tracked objects.
int32_t * m_enabledSequences
An array marking the entries in input frame list as valid(1) or invalid(0).
uint8_t * m_vpiObjPatches_d
Int8 device memory for VPI output that contains cropped and scaled object patches.
int32_t m_vpiBboxesArraySize
Number of active entries in m_vpiDCFBboxes used for dynamic compute adjustment.
int m_debugVerboseLevel
Debug message verbose mode level.
VPIImage m_vpiObjPatches
Image of cropped and scaled object patches.
float m_featureFocusOffsetFactor_y
Vertical Hanning-window center offset relative to the feature height.
float * m_channelWeights
The adaptive filter weights for the channels on device (a Batch CUDA memory buffer).
#define NVBUF_MAX_PLANES
Defines the maximum number of planes.
bool m_vizWriteBirdsEyeView
Write the bird's-eye view.
VPIArrayData m_vpiDCFBboxesData
VPIArrayData for m_vpiDCFBboxes.
bool m_isInit
Indicates whether tracker initialization completed.
Detector bbox in correlation-response coordinates.
VPIDCFTrackerCreationParams m_vpiCreateParams
VPI DCF Tracker creation params.
bool m_useColorNames
Enables the ColorNames feature.
void updateLocalizationResults(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta)
Update target states from their correlation responses.
uint * m_detectorBboxes_size_h
int detectorInputInterval
Interval between external detector inputs.
void queryParams(NvMOTQuery ¶msQuery)
Populate the visual tracker's capability query.
NvMotDataTypes::Size templateSize
Size of the rescaled search-region template.
int m_featureChannelSize
Number of channels in a feature vector.
VPIImageData m_vpiMaskingWindow4ModelData
VPIImageData for m_maskingWindow4Model.
detectorBbox_t * m_detectorBboxes_d
The detector bbox center points to be looked up at each tracker's correlation response.
float * m_confidenceAtDetectedPt_h
VPIImage m_vpiMaskingWindow4ModelImage
VPIImage for m_maskingWindow4Model.
float m_featureImgSize
Maximum template length in one dimension.
int m_showGpuTiming
Controls whether GPU timing is displayed.
float m_filterChannelWeightsLr
Learning rate for DCF filter channel weights in exponential moving average.
float * m_corrResponses_d
The correlation response maps for targets (a Batch CUDA memory buffer).
cudaEvent_t m_eventStop
Event stop point for GPU timers.
NvMotDataTypes::Size srcImageSize
The size of the source image.
VPIImage m_vpiMaskingWindow4SrcImage
VPIImage for m_maskingWindow4Src.
Hold the information of single buffer in the batch.
bool m_vizWriteSrcImgPatchesAndCorrResp
Write the cropped/scaled image patches and correlation response.
VISUAL_TRACKER_TYPES
Visual tracker implementations that can be selected by configuration.
int m_debugParamInt0
First integer debugging parameter.
bool * m_trackerDoProcessing_d
True when this tracker is updated for this batch.
int m_debugVerboseLevel_gpumemory
GPU memory debug verbosity level.
float * m_maxCorrResponse_h
float * m_trackingConfidence_h
The tracking confidence derived from the instant and the moving average of the max corr resp.
DCFTrackerRunTimeParams m_paramsRt
Runtime params for visual tracker module.
void update(const std::map< NvMOTStreamId, NvMOTFrame * > inputMeta) override
Update each target's correlation-filter model from an input batch.
float * m_maskingWindow4Src
Masking window for input image feature (a CUDA memory buffer).
bool m_useHog
Enables the HOG feature.
Provides common loading helpers for tracker configuration parameters.
uint maxTargetsToTrack
Maximum number of targets tracked across all streams.
bool m_generateTrackerVisualization
Enables tracker visualization generation.
Tracks objects with the VPI discriminative correlation filter implementation.
std::map< NvMOTStreamId, std::vector< std::pair< uint, NvMotDataTypes::Rect2f > > > m_featureRoisInBatch
Trackers' search regions as ROI for feature extraction.
float * m_corrResponseAtDetectedPt_d
Correlation response at each detector bbox center.
VPIArrayData m_vpiDCFBboxesLocalizedData
VPIArrayData for m_vpiDCFBboxesLocalized.
void read(const YAML::Node &fn) override
Read visual tracker parameters from a YAML node.
float m_gaussianSigma
Sigma for Gaussian for desired response.
VPIBackend m_vpiBackend4DcfTracker
VPI backend for the DCF tracker.
float m_modelMaskingWindowFactor
Masking-window factor used for focused filter learning.
int m_deviceId
GPU device ID.
uint8_t * m_surfCudaMemPtr[NVBUF_MAX_PLANES]
Pointers to cuda memories of all the planes in a surface.
bool m_useHighPrecisionFeature
Enables high-precision 16-bit VPI output instead of low-precision 8-bit output.
Holds the capabilities and requirements reported by the tracker library.
int m_vpiMemFlags
Flags used for creating VPI Image/Array wrappers.
VPIPayload m_vpiCropPayload
VPI payload for Crop scaler.
uint32_t * m_trackerAge_h
Stores runtime dimensions and processing state for the VPI DCF tracker.
int m_hogCellSize
Cell size of HOG feature.
Eigen::Vector2f convertSrcImgCoordToCorrRespCoord(const NvMotDataTypes::Rect2f &roi, const Eigen::Vector2f pt_img) const
Map a source-image point into a tracker's correlation-response coordinates.
float * m_maxCorrResponse_ma_d
virtual ~DCFTracker()
Release VPI DCF tracker resources.
VPIImageData m_vpiMaskingWindow4SrcData
VPIImageData for m_maskingWindow4Src.
VPIArray m_vpiChannelWeightsArray
VPIArray for m_channelWeights.
void performCropAndScale(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta, const bool isForLocalization)
Crop and scale object regions for localization or model update.
std::shared_ptr< NvTrackedObjectManager > m_targetManager
Target manager.
void updateParams(const YAML::Node &fn)
Update any Dynamic Params as provided during runtime by the user.
uint * m_detectorBboxes_size_d
The number of detector bbox candidate for each target.
float * m_maskingWindow4Model
Masking window for the model for filter learning (a CUDA memory buffer).
void cudaCalculateResponse(void)
Given the cropped and scaled object patches and the learned filters, compute the correlation response...
void getDetectorBboxCorrelationResponses(const std::map< NvMOTStreamId, std::deque< DetectedObjInfo >> &detectedObjects)
Retrieve each tracker's correlation response at nearby detector bounding boxes.
int m_cudaKernelMaxBatchSize
Maximum CUDA batch size across feature channels and target trackers.
DCFTracker(const std::string &configFilePath)
Construct from a configuration file path.
Configuration parameters for the VPI DCF tracker.
void setVpiInputFrameSequence(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta)
Populate the VPI input frame sequence from MOT frames.
uint m_maxBufSurfAddrSize
Maximum number of stored EGL-mapped addresses.
VPIDCFTrackerParams m_vpiRuntimeParams
VPI DCF Tracker runtime params.
float m_lambda
Regularization factor used in DCF filter creation.
VPIArray m_vpiDCFBboxesLocalizedArray
VPIArray for m_vpiDCFBboxesLocalized.
float * m_corrResponseAtDetectedPt_h
void localize(const std::map< NvMOTStreamId, NvMOTFrame * > inputMeta, const std::map< NvMOTStreamId, std::deque< DetectedObjInfo >> &detectedObjects) override
Localize tracked targets and evaluate nearby detections across an input batch.
Represents a two-dimensional integer size.
VPIArray m_vpiMaxCorrResponseArray
VPIArray for m_maxCorrResponse_d.
Information about the input source frames for the input frame batch.
int getCufftPlanId(int num_target)
Select a cuFFT plan large enough for the requested target count.
int m_debugParamInt1
Second integer debugging parameter.
float getTemplateRescaleRatio(const NvMotDataTypes::Rect2f &roi) const
Compute the scale that maps a search region to the fixed feature-image size.
NvBufSurfaceColorFormat colorFormat
Input source image color format.
std::vector< VPIDCFTrackedBoundingBox > m_vpiDCFBboxesLocalized
List of localized objects.
void getCudaMemPointers(NvBufSurfaceParams *baseSurface)
Retrieve CUDA memory pointers for all planes of an NvBufSurface.
float * m_maxCorrResponse_ma_h
The moving average of the max corr resp.
DCFTrackerConfigParams()
Construct the default configuration.
VPIImage * m_vpiInputFrameSequence
Sequence of VPIImage pointers to input frames.
detectorBbox_t * m_detectorBboxes_h
bool m_useRgb
Enables the RGB feature.
std::vector< bool > m_isFrameCreated
List indicating whether each frame wrapper has been created.
VPIBackend m_vpiBackend4CropnScale
VPI backend for the crop scaler.
bool * m_trackerDoProcessing_h
bool m_vizWriteEachCompletedTrajectory
Write each completed trajectory.
VPIImage m_vpiCorrResponsesImage
VPIImage for m_corrResponses_d.
void allocateCudaMemories()
Pre-allocate required cuda memories on GPU.
void checkInputOutput(const std::map< NvMOTStreamId, NvMOTFrame * > &inputMeta)
Check the input and find the detection interval.
RowMajorMatrixX< float > RowMajorMatrixXf
VPIImageData m_vpiCorrResponsesData
VPIImageData for m_corrResponses_d.
VPIArray m_vpiDCFBboxesArray
VPIArray for m_vpiDCFBboxes.
Renders and writes visual tracker debugging output.
float m_peakCorrLr
Learning rate for peak correlation response in exponential moving average.
int m_vpiObjPatchesNumChannels
Object patches are of format VPI_IMAGE_FORMAT_RGBA8 for CUDA backend.
float m_debugParamFloat1
Second floating-point debugging parameter.
int detCorrRespSearchWindowSize
Correlation-response search radius used to tolerate detector jitter.
NvBufSurfaceColorFormat
Defines color formats for NvBufSurface.
const VISUAL_TRACKER_TYPES getVisualTrackerType() override
Return the configured visual tracker type.
int m_integrated_gpu
Indicates whether the tracker runs on an integrated GPU.
float m_debugParamFloat0
First floating-point debugging parameter.