NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/nvmultiobjecttracker/include/modules/ReID/ReIDFrameTransformTexture.hpp
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 ReIDFrameTransform_HPP_
19 #define ReIDFrameTransform_HPP_
20 
21 #if defined VIZ_DEBUG_REID || defined VIZ_DEBUG_SEG || defined VIZ_DEBUG_POSE
22 #include <opencv2/core.hpp>
23 #endif
24 
25 #include "modules/FrameTransform/FrameTransform.hpp"
26 
29 {
30 public:
33 
36 
50  void initialize(
51  const int debugVerboseLevel, const int maxStreamNum, const int maxBufSurfAddrSize, const int maxTargetNum,
52  const NvMotDataTypes::Size srcImgSize, const uint srcImgPitch, const NvBufSurfaceColorFormat colorFormatType,
53  const NvMotDataTypes::Size dstImgSize, const NvBufSurfaceColorFormat dstColorFormatType, const int dimOrder
54  );
55 
65  const std::map<NvMOTStreamId, std::vector<std::pair<uint, NvMotDataTypes::Rect2f> > > &roisInBatch,
66  const uint lastBboxInd, const float outputScaleFactor, const std::vector<float> outputOffsets
67  );
68 
78  const std::map<NvMOTStreamId, std::vector<std::pair<uint, NvMotDataTypes::Rect2f> > > &roisInBatch,
79  const uint lastBboxInd, const float outputScaleFactor, const std::vector<float> outputOffsets
80  );
81 
83  float* getOutputImagePatchPtrs() { return m_odata_d; }
84 
85  #if defined VIZ_DEBUG_REID || defined VIZ_DEBUG_SEG || defined VIZ_DEBUG_POSE
86 
92  std::map<NvMOTStreamId, std::map<uint, cv::Mat > > getImagePatches2Host_OCV_batch(
93  const float outputScaleFactor, const std::vector<float> outputOffsets
94  );
95  #endif
96 
97 private:
104  void initialize4Output(
105  const NvMotDataTypes::Size dstSize, const NvBufSurfaceColorFormat dstColorFormat, const int dimOrder
106  );
107 
109  void allocateOutputMemories();
110 
112  void deAllocateOutputMemories();
113 
114  bool m_isInit;
115 
116  // [Output configuration specific to ReID]
117  int m_width_out, m_height_out, m_channels_out;
118  int m_dimOrder;
119  NvBufSurfaceColorFormat m_dstColorFormatType;
120 
121  // [Output memory specific to ReID]
122  float *m_odata_d;
123  float *m_odata_host;
124  #if defined VIZ_DEBUG_REID || defined VIZ_DEBUG_SEG || defined VIZ_DEBUG_POSE
125  float *m_odata_host_nchw;
126  #endif
127 };
128 
129 #endif // ReIDFrameTransform_HPP_
ReIDFrameTransformTexture
Crops and rescales target regions through CUDA texture transforms.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReID/ReIDFrameTransformTexture.hpp:28
uint
unsigned int uint
Definition: sources/libs/nvmultiobjecttracker/include/modules/cuDCFv2/helper_math.h:25
ReIDFrameTransformTexture::frameTransformInBatch
bool frameTransformInBatch(const std::map< NvMOTStreamId, std::vector< std::pair< uint, NvMotDataTypes::Rect2f > > > &roisInBatch, const uint lastBboxInd, const float outputScaleFactor, const std::vector< float > outputOffsets)
Transform (crop, scale and color conversion) a set of bboxes for the given single frame,...
FrameTransformTexture
Provides common CUDA texture state for frame transformations.
Definition: sources/libs/nvmultiobjecttracker/include/modules/FrameTransform/FrameTransform.hpp:210
ReIDFrameTransformTexture::initialize
void initialize(const int debugVerboseLevel, const int maxStreamNum, const int maxBufSurfAddrSize, const int maxTargetNum, const NvMotDataTypes::Size srcImgSize, const uint srcImgPitch, const NvBufSurfaceColorFormat colorFormatType, const NvMotDataTypes::Size dstImgSize, const NvBufSurfaceColorFormat dstColorFormatType, const int dimOrder)
Initialize for image cropping and scaling.
ReIDFrameTransformTexture::ReIDFrameTransformTexture
ReIDFrameTransformTexture()
Construct a ReIDFrameTransformTexture instance.
ReIDFrameTransformTexture::~ReIDFrameTransformTexture
~ReIDFrameTransformTexture()
Release resources owned by the ReIDFrameTransformTexture instance.
NvMOTStreamId
uint64_t NvMOTStreamId
Definition: includes/nvdstracker.h:53
ReIDFrameTransformTexture::getOutputImagePatchPtrs
float * getOutputImagePatchPtrs()
Get the pointer to the output image patches on device memory with metadata.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReID/ReIDFrameTransformTexture.hpp:83
ReIDFrameTransformTexture::frameTransformInBatch_NV12
bool frameTransformInBatch_NV12(const std::map< NvMOTStreamId, std::vector< std::pair< uint, NvMotDataTypes::Rect2f > > > &roisInBatch, const uint lastBboxInd, const float outputScaleFactor, const std::vector< float > outputOffsets)
Transform (crop, scale and color conversion) a set of bboxes for the given single frame,...
NvMotDataTypes::Size
Represents a two-dimensional integer size.
Definition: sources/libs/nvmultiobjecttracker/include/modules/utility/dataTypes.hpp:52
NvBufSurfaceColorFormat
NvBufSurfaceColorFormat
Defines color formats for NvBufSurface.
Definition: includes/nvbufsurface.h:110