NVIDIA DeepStream SDK API Reference

7.0 Release
BodyPose2D.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 
11 #ifndef NV_BODYPOSE_2D_H_
12 #define NV_BODYPOSE_2D_H_
13 
14 #include <map>
15 #include <memory>
16 
17 #include <cuda_runtime.h>
18 #include <cv/core/Array.h>
19 #include <cv/core/BBox.h>
20 #include <cv/core/Core.h>
21 #include <cv/core/Image.h>
22 #include <cv/core/MathTypes.h>
23 #include <cv/core/Model.h>
24 #include <cv/core/Tensor.h>
25 
26 namespace cvcore { namespace bodypose2d {
27 
31 struct BodyPart
32 {
33  int part_idx;
35  float score = 0.0f;
36 };
37 
41 struct Human
42 {
43  std::map<int, BodyPart> body_parts;
45  float score = 0.0f;
46 };
47 
52 {
53  size_t numJoints;
54  size_t nmsWindowSize;
56  float threshHeat;
61  std::vector<std::pair<uint32_t, uint32_t>>
63 };
64 
68 enum class HandType : uint32_t
69 {
70  LEFT_HAND = 0,
72 };
73 
78 {
87  /* Wrist and elbow indices are necessary for computing the hand bounding box*/
88  uint32_t wristIndex;
89  uint32_t elbowIndex;
90  /* Hip, nose and neck joint indices are optional.
91  * If these indices are not available, the index can be set to any
92  * invalid index value i.e index > numJoints */
93  uint32_t leftHipIndex;
94  uint32_t rightHipIndex;
95  uint32_t noseIndex;
96  uint32_t neckIndex;
98 };
99 
104 
109 
114 
119 
124 
129 {
130 public:
134  BodyPose2DPreProcessor() = delete;
135 
141  BodyPose2DPreProcessor(const ImagePreProcessingParams &preProcessorParams,
142  const ModelInputParams &modelInputParams);
143 
148 
155  void execute(Tensor<NHWC, C3, F32> &output, const Tensor<NHWC, C3, U8> &input, cudaStream_t stream = 0);
156 
163  void execute(Tensor<NCHW, C3, F32> &output, const Tensor<NHWC, C3, U8> &input, cudaStream_t stream = 0);
164 
165 private:
169  struct BodyPose2DPreProcessorImpl;
170  std::unique_ptr<BodyPose2DPreProcessorImpl> m_pImpl;
171 };
172 
177 {
178 public:
182  static constexpr int MAX_HUMAN_COUNT = 200;
183 
187  BodyPose2D() = delete;
188 
196  BodyPose2D(const ImagePreProcessingParams &preProcessorParams, const ModelInputParams &modelInputParams,
197  const ModelInferenceParams &inferenceParams, const BodyPose2DPostProcessorParams &postProcessorParams);
198 
202  ~BodyPose2D();
203 
210  void execute(Array<ArrayN<Human, MAX_HUMAN_COUNT>> &output, const Tensor<NHWC, C3, U8> &input,
211  cudaStream_t stream = 0);
212 
213 private:
217  struct BodyPose2DImpl;
218  std::unique_ptr<BodyPose2DImpl> m_pImpl;
219 };
220 
225 {
226 public:
230  BodyPose2DPostProcessor() = delete;
231 
237  BodyPose2DPostProcessor(const BodyPose2DPostProcessorParams &params, const ModelInputParams &modelInputParams);
238 
243 
247  void allocateStagingBuffers();
248 
257  void execute(Array<ArrayN<Human, BodyPose2D::MAX_HUMAN_COUNT>> &output, const Tensor<NCHW, CX, F32> &pafMap,
258  const Tensor<NCHW, CX, F32> &heatMap, int imageWidth, int imageHeight, cudaStream_t stream = 0);
259 
260 private:
264  struct BodyPose2DPostProcessorImpl;
265  std::unique_ptr<BodyPose2DPostProcessorImpl> m_pImpl;
266 };
267 
272 {
273 public:
274  static constexpr size_t MOVING_AVG_WINDOW_SIZE = 100;
278  HandBoundingBoxGenerator() = delete;
293  bool execute(BBox &box, const Human &pose, size_t imageWidth, size_t imageHeight);
294 
299 
300 private:
304  struct HandBoundingBoxGeneratorImpl;
305  std::unique_ptr<HandBoundingBoxGeneratorImpl> m_pImpl;
306 };
307 
308 }} // namespace cvcore::bodypose2d
309 #endif
cvcore::bodypose2d::HandBoundingBoxParams::handBoxScalingFactorTrainDims
Vector2d handBoxScalingFactorTrainDims
Definition: BodyPose2D.h:84
cvcore::bodypose2d::HandBoundingBoxParams
Data structure to describe the parameters tuned for bounding box detection from pose.
Definition: BodyPose2D.h:77
cvcore::bodypose2d::BodyPose2DPostProcessorParams::threshPartCnt
int threshPartCnt
model threshold for part count.
Definition: BodyPose2D.h:59
cvcore::bodypose2d::BodyPart::loc
Vector2i loc
x, y pixel location.
Definition: BodyPose2D.h:34
cvcore::bodypose2d::BodyPart::score
float score
part score.
Definition: BodyPose2D.h:35
cvcore::Vector2< int >
cvcore::bodypose2d::BodyPose2DPostProcessorParams::jointEdges
std::vector< std::pair< uint32_t, uint32_t > > jointEdges
Definition: BodyPose2D.h:62
Model.h
cvcore::ModelInferenceParams
Struct to describe the model.
Definition: Model.h:34
cvcore::bodypose2d::HandBoundingBoxParams::handBoxScalingFactorNeckHipCoeff
Vector2f handBoxScalingFactorNeckHipCoeff
Training factor used to determine the scaling factor.
Definition: BodyPose2D.h:85
cvcore::BBox
A struct.
Definition: BBox.h:24
cvcore
Definition: PnP.h:20
cvcore::bodypose2d::HandBoundingBoxParams::handBoxScalingFactorMinRange
float handBoxScalingFactorMinRange
Default scaling factor for bounding box.
Definition: BodyPose2D.h:82
cvcore::bodypose2d::BodyPose2DPostProcessorParams::featUpsamplingFactor
size_t featUpsamplingFactor
feature upsampleing factor.
Definition: BodyPose2D.h:55
cvcore::bodypose2d::HandBoundingBoxParams::handBoxNoseNeckHipRatio
float handBoxNoseNeckHipRatio
Definition: BodyPose2D.h:86
cvcore::bodypose2d::HandBoundingBoxParams::wristIndex
uint32_t wristIndex
Scale factor between neck and nose.
Definition: BodyPose2D.h:88
cvcore::bodypose2d::HandType
HandType
Enum listing the hand used for gestures.
Definition: BodyPose2D.h:68
MathTypes.h
cvcore::bodypose2d::HandBoundingBoxParams::neckIndex
uint32_t neckIndex
Nose index of the pose provided.
Definition: BodyPose2D.h:96
cvcore::bodypose2d::BodyPose2DPostProcessorParams::nmsWindowSize
size_t nmsWindowSize
window size for NMS operation.
Definition: BodyPose2D.h:54
cvcore::bodypose2d::HandBoundingBoxParams::leftHipIndex
uint32_t leftHipIndex
Left or right elbow index of the pose provided.
Definition: BodyPose2D.h:93
cvcore::bodypose2d::Human::boundingBox
BBox boundingBox
bounding box for person.
Definition: BodyPose2D.h:44
cvcore::bodypose2d::BodyPose2DPostProcessorParams::threshVectorScore
float threshVectorScore
model threshold for vector score.
Definition: BodyPose2D.h:57
Array.h
cvcore::bodypose2d::BodyPose2DPostProcessorParams::threshHumanScore
float threshHumanScore
model threshold for human score.
Definition: BodyPose2D.h:60
cvcore::bodypose2d::BodyPose2DPostProcessorParams::threshHeat
float threshHeat
model threshold for heatmap.
Definition: BodyPose2D.h:56
cvcore::bodypose2d::BodyPose2D
Interface for loading and running bodypose2d network.
Definition: BodyPose2D.h:176
cvcore::bodypose2d::HandBoundingBoxParams::defaultHandBoxScalingFactor
float defaultHandBoxScalingFactor
Definition: BodyPose2D.h:81
cvcore::bodypose2d::BodyPose2DPreProcessor
Interface for running pre-processing on bodypose2d network.
Definition: BodyPose2D.h:128
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: nvbufsurftransform.h:34
cvcore::bodypose2d::BodyPose2DPostProcessorParams
Data structure to describe the post processing for BodyPose2D.
Definition: BodyPose2D.h:51
cvcore::Tensor
Definition: Tensor.h:704
Image.h
cvcore::bodypose2d::HandBoundingBoxParams::rightHipIndex
uint32_t rightHipIndex
Left hip index of the pose provided.
Definition: BodyPose2D.h:94
cvcore::Array
Implementation of Array class.
Definition: Array.h:133
cvcore::bodypose2d::defaultHandParams
const CVCORE_API HandBoundingBoxParams defaultHandParams
Default parameters for computing hand bounding box from pose.
cvcore::bodypose2d::HandType::RIGHT_HAND
@ RIGHT_HAND
cvcore::ImagePreProcessingParams
Struct type for image preprocessing params.
Definition: Image.h:67
cvcore::bodypose2d::BodyPose2DPostProcessorParams::threshVectorCnt1
int threshVectorCnt1
model threshold for vector count.
Definition: BodyPose2D.h:58
cvcore::bodypose2d::BodyPose2DPostProcessor
Interface for running post-processing on bodypose2d network.
Definition: BodyPose2D.h:224
cvcore::bodypose2d::HandBoundingBoxParams::enableHandBoxDynamicScaling
bool enableHandBoxDynamicScaling
Enable using hand scale input.
Definition: BodyPose2D.h:80
CVCORE_API
#define CVCORE_API
Definition: Core.h:24
cvcore::bodypose2d::BodyPart
Data structure for storing body part location.
Definition: BodyPose2D.h:31
cvcore::bodypose2d::HandBoundingBoxParams::handBoxScalingFactorMaxRange
float handBoxScalingFactorMaxRange
Maximum scaling factor.
Definition: BodyPose2D.h:83
Tensor.h
cvcore::bodypose2d::HandBoundingBoxGenerator
Class to compute the bounding box of hand from pose.
Definition: BodyPose2D.h:271
cvcore::bodypose2d::defaultPostProcessorParams
const CVCORE_API BodyPose2DPostProcessorParams defaultPostProcessorParams
Default parameters for the post processing pipeline.
cvcore::bodypose2d::Human::body_parts
std::map< int, BodyPart > body_parts
body parts map.
Definition: BodyPose2D.h:43
cvcore::ModelInputParams
Struct to describe input type required by the model.
Definition: Model.h:23
BBox.h
cvcore::bodypose2d::defaultModelInputParams
const CVCORE_API ModelInputParams defaultModelInputParams
Default parameters to describe the input expected for the model.
cvcore::ArrayN
Implementation of ArrayN class.
Definition: Array.h:258
Core.h
cvcore::bodypose2d::HandBoundingBoxParams::handType
HandType handType
Left or Right hand.
Definition: BodyPose2D.h:79
cvcore::bodypose2d::defaultInferenceParams
const CVCORE_API ModelInferenceParams defaultInferenceParams
Default parameters to describe the model inference parameters.
cvcore::bodypose2d::BodyPart::part_idx
int part_idx
part index.
Definition: BodyPose2D.h:33
cvcore::bodypose2d::Human
Data structure for storing human info.
Definition: BodyPose2D.h:41
cvcore::bodypose2d::Human::score
float score
person score.
Definition: BodyPose2D.h:45
cvcore::bodypose2d::BodyPose2DPostProcessorParams::numJoints
size_t numJoints
Number of joints.
Definition: BodyPose2D.h:53
cvcore::bodypose2d::defaultPreProcessorParams
const CVCORE_API ImagePreProcessingParams defaultPreProcessorParams
Default parameters for the preprocessing pipeline.
cvcore::bodypose2d::HandBoundingBoxParams::noseIndex
uint32_t noseIndex
Right hip index of the pose provided.
Definition: BodyPose2D.h:95
cvcore::bodypose2d::HandBoundingBoxParams::elbowIndex
uint32_t elbowIndex
Left or right wrist index of the pose provided.
Definition: BodyPose2D.h:89
cvcore::bodypose2d::HandType::LEFT_HAND
@ LEFT_HAND