plugin  0.1.0
hpe_model_associative_embedding.h
1 /*
2 // Copyright (C) 2021-2024 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
17 #pragma once
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include <opencv2/core.hpp>
23 
24 #include <utils/image_utils.h>
25 
26 #include "models/image_model.h"
27 
28 namespace ov {
29 class InferRequest;
30 class Model;
31 class Shape;
32 } // namespace ov
33 struct HumanPose;
34 struct InferenceResult;
35 struct InputData;
36 struct InternalModelData;
37 struct ResultBase;
38 
40 public:
48  HpeAssociativeEmbedding(const std::string& modelFileName,
49  double aspectRatio,
50  int targetSize,
51  float confidenceThreshold,
52  const std::string& layout = "",
53  float delta = 0.0,
54  RESIZE_MODE resizeMode = RESIZE_KEEP_ASPECT);
55 
56  std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
57 
58  std::shared_ptr<InternalModelData> preprocess(const InputData& inputData, ov::InferRequest& request) override;
59 
60 protected:
61  void prepareInputsOutputs(std::shared_ptr<ov::Model>& model) override;
62 
63  cv::Size inputLayerSize;
64  double aspectRatio;
65  int targetSize;
66  float confidenceThreshold;
67  float delta;
68 
69  std::string embeddingsTensorName;
70  std::string heatmapsTensorName;
71  std::string nmsHeatmapsTensorName;
72 
73  static const int numJoints = 17;
74  static const int stride = 32;
75  static const int maxNumPeople = 30;
76  static const cv::Vec3f meanPixel;
77  static const float detectionThreshold;
78  static const float tagThreshold;
79 
80  void changeInputSize(std::shared_ptr<ov::Model>& model);
81 
82  std::string findTensorByName(const std::string& tensorName, const std::vector<std::string>& outputsNames);
83 
84  std::vector<cv::Mat> split(float* data, const ov::Shape& shape);
85 
86  std::vector<HumanPose> extractPoses(std::vector<cv::Mat>& heatMaps,
87  const std::vector<cv::Mat>& aembdsMaps,
88  const std::vector<cv::Mat>& nmsHeatMaps) const;
89 };
Definition: hpe_model_associative_embedding.h:39
HpeAssociativeEmbedding(const std::string &modelFileName, double aspectRatio, int targetSize, float confidenceThreshold, const std::string &layout="", float delta=0.0, RESIZE_MODE resizeMode=RESIZE_KEEP_ASPECT)
Definition: hpe_model_associative_embedding.cpp:45
Definition: image_model.h:32
Definition: results.h:113
Definition: results.h:53
Definition: input_data.h:20
Definition: internal_model_data.h:19
Definition: results.h:29