NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef CUDCFLIB_CUDCF_H_
19 #define CUDCFLIB_CUDCF_H_
20 
21 #include <cuda_runtime.h>
22 #include <cufft.h>
23 #include <cufftXt.h>
24 #include <cuComplex.h>
25 #include "modules/NvMultiObjectTracker/localizer.hpp"
26 
27 typedef float ftype1;
28 typedef float2 ftype2;
29 
31 typedef struct
32 {
33  int x, y;
36 
37 namespace cuDCF
38 {
55  const cudaStream_t &stream, const int num_of_targets, const int maxTargetsPerStream,
56  const detectorBbox_t *detectedPts, const uint *detectedPts_size, const int detCorrRespSearchWindowSize,
57  const float *corr_responses, const float *maxCorrResponse_ma, const int img_element_size,
58  const int img_width, float *confidenceAtDetectedPt, float *corrRespAtDetectedPt
59 );
60 
77  const cudaStream_t &stream, const uint16_t *ftrs, const float *masking_window, const uint srcWidth,
78  const uint srcPitch, const uint srcHeight, const uint2 outBatchingGrid, const uint num_of_channels,
79  const uint num_of_targets, const bool useColorNames, const uint num_of_colorNames_channels, float *ftrs_masked
80 );
81 
97 void applyFilter2D_U8(
98  const cudaStream_t &stream, const uchar *ftrs, const float *masking_window, const uint srcWidth,
99  const uint srcPitch, const uint srcHeight, const uint2 outBatchingGrid, const uint num_of_channels,
100  const uint num_of_targets, const bool useColorNames, const uint num_of_colorNames_channels, float *ftrs_masked
101 );
102 
125 void createDcfFilter(
126  const cudaStream_t &stream, const cufftHandle &cufft_handle_C2R, const cufftHandle &cufft_handle_R2C,
127  const cuComplex *ftrs_F, const cuComplex *desiredResp_F, const float *masking_window_model, const int img_width,
128  const int img_element_size, const int batch_element_size, const float lambda, const int num_of_channels,
129  const int num_of_targets, cuComplex *work_F, float *work_I, const uint32_t *tracker_age,
130  const bool *trackerDoProcessing_d, const float learn_rate, cuComplex *learned_filter_F, cuComplex *result_filter_F
131 );
132 
149  const cudaStream_t &stream, const float *src_mask_frame_batch, const int src_frame_width,
150  const int src_frame_element_size, const int feat_width, const int feat_element_size,
151  const int batch_element_size, const int num_of_targets, const int num_of_channels,
152  const float4 *src_rois, const bool *trackerDoProcessing_d, float *dst_mask_patch_batch
153 );
154 
176  const cudaStream_t &stream, const cufftHandle &cufft_handle_many, const cuComplex *ftrs_F,
177  const int img_element_size, const int img_width, const int batch_element_size,
178  const int batch_size, const int num_of_channels, const int num_of_targets,
179  const cuComplex *new_filter_F, cuComplex *work_F, float *work_I, const uint32_t *tracker_age,
180  const bool *trackerDoProcessing_d, const float weights_lr, float *channel_weights, float *weight_sum
181 );
182 
195  const cudaStream_t &stream, const int num_of_channels, const int num_of_targets,
196  const float learn_rate, const float *channel_weights, const uint32_t *tracker_age,
197  const bool *trackerDoProcessing_d, float *maxCorrResponse_ma
198 );
199 
217 void calculateResponse(
218  const cudaStream_t &stream, const cufftHandle &cufft_handle_many_small, const int img_width,
219  const int img_element_size, const int batch_element_size, const int num_of_channels, const int num_of_targets,
220  const cuComplex *ftrs_F, const cuComplex *result_filter_F, const float *channel_weights,
221  cuComplex *work_F, float *corr_responses, float *maxResp, float2 *targetDisplacement
222 );
223 
233  const cudaStream_t &stream, const int num_of_targets, const float *maxCorrResponse_ma,
234  const float *maxCorrResponse, float *trackingConfidence
235 );
236 } // end of namespace cuDCF
237 
238 #endif // CUDCFLIB_CUDCF_H_
ftype1
float ftype1
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h:27
cuDCF
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h:37
cuDCF::calculateResponse
void calculateResponse(const cudaStream_t &stream, const cufftHandle &cufft_handle_many_small, const int img_width, const int img_element_size, const int batch_element_size, const int num_of_channels, const int num_of_targets, const cuComplex *ftrs_F, const cuComplex *result_filter_F, const float *channel_weights, cuComplex *work_F, float *corr_responses, float *maxResp, float2 *targetDisplacement)
Given the Fourier-transformed extracted features and the learned filters, compute the correlation res...
cuDCF::applyFilter2D_U16
void applyFilter2D_U16(const cudaStream_t &stream, const uint16_t *ftrs, const float *masking_window, const uint srcWidth, const uint srcPitch, const uint srcHeight, const uint2 outBatchingGrid, const uint num_of_channels, const uint num_of_targets, const bool useColorNames, const uint num_of_colorNames_channels, float *ftrs_masked)
Multiply a 2D high-precision feature by a masking window elementwise.
detectorBbox_t::dBboxInd
uint dBboxInd
Index to the corresponding detector bbox.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h:34
cuDCF::createDcfFilter
void createDcfFilter(const cudaStream_t &stream, const cufftHandle &cufft_handle_C2R, const cufftHandle &cufft_handle_R2C, const cuComplex *ftrs_F, const cuComplex *desiredResp_F, const float *masking_window_model, const int img_width, const int img_element_size, const int batch_element_size, const float lambda, const int num_of_channels, const int num_of_targets, cuComplex *work_F, float *work_I, const uint32_t *tracker_age, const bool *trackerDoProcessing_d, const float learn_rate, cuComplex *learned_filter_F, cuComplex *result_filter_F)
Create a DCF filter and update the learned filter with an exponential moving average.
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: includes/nvbufsurftransform.h:40
cuDCF::applyFilter2D_U8
void applyFilter2D_U8(const cudaStream_t &stream, const uchar *ftrs, const float *masking_window, const uint srcWidth, const uint srcPitch, const uint srcHeight, const uint2 outBatchingGrid, const uint num_of_channels, const uint num_of_targets, const bool useColorNames, const uint num_of_colorNames_channels, float *ftrs_masked)
Multiply a 2D low-precision feature by a masking window elementwise.
uchar
unsigned char uchar
Definition: sources/libs/nvmultiobjecttracker/include/modules/utility/dataTypes.hpp:29
detectorBbox_t
Detector bbox in correlation-response coordinates.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h:31
uint
unsigned int uint
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/helper_math.h:25
cuDCF::calcuateExpectedPeakCorrelation
void calcuateExpectedPeakCorrelation(const cudaStream_t &stream, const int num_of_channels, const int num_of_targets, const float learn_rate, const float *channel_weights, const uint32_t *tracker_age, const bool *trackerDoProcessing_d, float *maxCorrResponse_ma)
Compute the moving average of the max correlation response.
ftype2
float2 ftype2
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h:28
cuDCF::getDetectorBboxCorrelationResponses
void getDetectorBboxCorrelationResponses(const cudaStream_t &stream, const int num_of_targets, const int maxTargetsPerStream, const detectorBbox_t *detectedPts, const uint *detectedPts_size, const int detCorrRespSearchWindowSize, const float *corr_responses, const float *maxCorrResponse_ma, const int img_element_size, const int img_width, float *confidenceAtDetectedPt, float *corrRespAtDetectedPt)
Read the correlation response near each detector bbox and write the confidence and response.
detectorBbox_t::y
int y
Coordinates in the correlation-response matrix.
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/cuDCF.h:33
cuDCF::computeChannelWeights
void computeChannelWeights(const cudaStream_t &stream, const cufftHandle &cufft_handle_many, const cuComplex *ftrs_F, const int img_element_size, const int img_width, const int batch_element_size, const int batch_size, const int num_of_channels, const int num_of_targets, const cuComplex *new_filter_F, cuComplex *work_F, float *work_I, const uint32_t *tracker_age, const bool *trackerDoProcessing_d, const float weights_lr, float *channel_weights, float *weight_sum)
Compute and update the channel weights via exponential moving average.
cuDCF::createSegmentationFilterMask
void createSegmentationFilterMask(const cudaStream_t &stream, const float *src_mask_frame_batch, const int src_frame_width, const int src_frame_element_size, const int feat_width, const int feat_element_size, const int batch_element_size, const int num_of_targets, const int num_of_channels, const float4 *src_rois, const bool *trackerDoProcessing_d, float *dst_mask_patch_batch)
Crop and rescale each target's segmentation mask to the visual tracker region size.
cuDCF::calculateTrackingConfidence
void calculateTrackingConfidence(const cudaStream_t &stream, const int num_of_targets, const float *maxCorrResponse_ma, const float *maxCorrResponse, float *trackingConfidence)
Calculate tracking confidence from moving-average and instantaneous peak correlation responses.