NVIDIA DeepStream SDK API Reference

6.4 Release
Emotions.h
Go to the documentation of this file.
1 /*###############################################################################
2 #
3 # Copyright(c) 2021 NVIDIA CORPORATION. All Rights Reserved.
4 #
5 # NVIDIA CORPORATION and its licensors retain all intellectual property
6 # and proprietary rights in and to this software, related documentation
7 # and any modifications thereto. Any use, reproduction, disclosure or
8 # distribution of this software and related documentation without an express
9 # license agreement from NVIDIA CORPORATION is strictly prohibited.
10 #
11 ###############################################################################*/
12 
13 #ifndef CVCORE_EMOTIONS_H_
14 #define CVCORE_EMOTIONS_H_
15 
16 #include <memory>
17 
18 #include <cuda_runtime.h>
19 
20 #include <cv/core/Array.h>
21 #include <cv/core/BBox.h>
22 #include <cv/core/MathTypes.h>
23 #include <cv/core/Model.h>
24 #include <cv/core/Tensor.h>
25 
26 namespace cvcore { namespace emotions {
27 
32 
37 
42 
46 class Emotions
47 {
48  public:
52  static constexpr std::size_t NUM_FACIAL_LANDMARKS = 68;
53 
57  static constexpr std::size_t TOP_EMOTIONS = 10;
58 
62  Emotions() = delete;
63 
71  Emotions(const ImagePreProcessingParams & preProcessorParams,
72  const ModelInputParams & modelInputParams,
73  const ModelInferenceParams & inferenceParams,
74  size_t numEmotions = 6);
75 
79  ~Emotions();
80 
88  void execute(Array<ArrayN<float, Emotions::TOP_EMOTIONS>> & emotionLikelihoods,
90  const Array<ArrayN<Vector2f, NUM_FACIAL_LANDMARKS>> & inputLandmarks,
91  cudaStream_t stream = 0);
92 
93  private:
94  struct EmotionsImpl;
95 
96  std::unique_ptr<EmotionsImpl> m_pImpl;
97 };
98 
103 {
104  public:
108  EmotionsPreProcessor() = delete;
109 
115  EmotionsPreProcessor(const ImagePreProcessingParams & preProcessorParams,
116  const ModelInputParams & modelInputParams);
117 
122 
129  void execute(Tensor<CL, CX, F32> & preProcessedLandmarkBatch,
131  cudaStream_t stream = 0);
132 
133  private:
134  struct EmotionsPreProcessorImpl;
135 
136  std::unique_ptr<EmotionsPreProcessorImpl> m_pImpl;
137 };
138 
143 {
144  public:
148  EmotionsPostProcessor() = delete;
149 
155  EmotionsPostProcessor(const ModelInputParams & modelInputParams, size_t numEmotions);
156 
161 
169  void execute(Array<ArrayN<float, Emotions::TOP_EMOTIONS>> & emotionLikelihoods,
171  const Tensor<CL, CX, F32> & emotionsRaw,
172  cudaStream_t stream = 0);
173 
174  private:
175  struct EmotionsPostProcessorImpl;
176 
177  std::unique_ptr<EmotionsPostProcessorImpl> m_pImpl;
178 };
179 
180 }} // namespace cvcore::emotions
181 
182 #endif // CVCORE_EMOTIONS_H_
cvcore::emotions::Emotions::NUM_FACIAL_LANDMARKS
static constexpr std::size_t NUM_FACIAL_LANDMARKS
Number of input facial landmarks.
Definition: Emotions.h:52
Model.h
cvcore::ModelInferenceParams
Struct to describe the model.
Definition: Model.h:34
cvcore::emotions::EmotionsPreProcessor::execute
void execute(Tensor< CL, CX, F32 > &preProcessedLandmarkBatch, const Array< ArrayN< Vector2f, Emotions::NUM_FACIAL_LANDMARKS >> &inputLandmarks, cudaStream_t stream=0)
Running preprocessing for a given set of facial landmarks.
cvcore::emotions::EmotionsPostProcessor::~EmotionsPostProcessor
~EmotionsPostProcessor()
Destructor for EmotionsPostProcessor.
cvcore
Definition: PnP.h:20
MathTypes.h
cvcore::emotions::defaultInferenceParams
const ModelInferenceParams defaultInferenceParams
Default inference Params for Emotions.
cvcore::emotions::EmotionsPostProcessor::execute
void execute(Array< ArrayN< float, Emotions::TOP_EMOTIONS >> &emotionLikelihoods, Array< ArrayN< std::size_t, Emotions::TOP_EMOTIONS >> &topEmotions, const Tensor< CL, CX, F32 > &emotionsRaw, cudaStream_t stream=0)
Running postprocessing for a given set of emotion likelihoods.
cvcore::emotions::EmotionsPostProcessor
Interface for running post-processing for Emotions.
Definition: Emotions.h:142
Array.h
cvcore::emotions::Emotions::execute
void execute(Array< ArrayN< float, Emotions::TOP_EMOTIONS >> &emotionLikelihoods, Array< ArrayN< size_t, Emotions::TOP_EMOTIONS >> &topEmotions, const Array< ArrayN< Vector2f, NUM_FACIAL_LANDMARKS >> &inputLandmarks, cudaStream_t stream=0)
Running Emotions for a given image.
cvcore::emotions::EmotionsPreProcessor::EmotionsPreProcessor
EmotionsPreProcessor()=delete
Removing the default constructor for EmotionsPreProcessor.
cvcore::emotions::defaultModelInputParams
const ModelInputParams defaultModelInputParams
Default Model Input Params for Emotions.
cvcore::emotions::EmotionsPreProcessor::~EmotionsPreProcessor
~EmotionsPreProcessor()
Destructor for EmotionsPreProcessor.
cvcore::emotions::Emotions
Interface for loading and running Emotions.
Definition: Emotions.h:46
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: nvbufsurftransform.h:29
cvcore::Tensor
Definition: Tensor.h:704
cvcore::Array
Implementation of Array class.
Definition: Array.h:133
cvcore::emotions::defaultPreProcessorParams
const ImagePreProcessingParams defaultPreProcessorParams
Default Image Processing Params for Emotions.
cvcore::ImagePreProcessingParams
Struct type for image preprocessing params.
Definition: Image.h:67
Tensor.h
cvcore::emotions::EmotionsPreProcessor
Interface for running pre-processing for Emotions.
Definition: Emotions.h:102
cvcore::emotions::Emotions::Emotions
Emotions()=delete
Removing the default constructor for Emotions.
cvcore::ModelInputParams
Struct to describe input type required by the model.
Definition: Model.h:23
BBox.h
cvcore::ArrayN
Implementation of ArrayN class.
Definition: Array.h:258
cvcore::emotions::Emotions::TOP_EMOTIONS
static constexpr std::size_t TOP_EMOTIONS
Top emotions classified in order of likelihood.
Definition: Emotions.h:57
cvcore::emotions::Emotions::~Emotions
~Emotions()
Destructor for Emotions.
cvcore::emotions::EmotionsPostProcessor::EmotionsPostProcessor
EmotionsPostProcessor()=delete
Removing the default constructor for EmotionsPostProcessor.