plugin  0.1.0
hpe_model_openpose.h
1 /*
2 // Copyright (C) 2020-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 <stddef.h>
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <opencv2/core.hpp>
25 
26 #include "models/image_model.h"
27 
28 namespace ov {
29 class InferRequest;
30 class Model;
31 } // namespace ov
32 struct HumanPose;
33 struct InferenceResult;
34 struct InputData;
35 struct InternalModelData;
36 struct ResultBase;
37 
38 class HPEOpenPose : public ImageModel {
39 public:
46  HPEOpenPose(const std::string& modelFileName,
47  double aspectRatio,
48  int targetSize,
49  float confidenceThreshold,
50  const std::string& layout = "");
51 
52  std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
53 
54  std::shared_ptr<InternalModelData> preprocess(const InputData& inputData, ov::InferRequest& request) override;
55 
56  static const size_t keypointsNumber = 18;
57 
58 protected:
59  void prepareInputsOutputs(std::shared_ptr<ov::Model>& model) override;
60 
61  static const int minJointsNumber = 3;
62  static const int stride = 8;
63  static const int upsampleRatio = 4;
64  static const cv::Vec3f meanPixel;
65  static const float minPeaksDistance;
66  static const float midPointsScoreThreshold;
67  static const float foundMidPointsRatioThreshold;
68  static const float minSubsetScore;
69  cv::Size inputLayerSize;
70  double aspectRatio;
71  int targetSize;
72  float confidenceThreshold;
73 
74  std::vector<HumanPose> extractPoses(const std::vector<cv::Mat>& heatMaps, const std::vector<cv::Mat>& pafs) const;
75  void resizeFeatureMaps(std::vector<cv::Mat>& featureMaps) const;
76 
77  void changeInputSize(std::shared_ptr<ov::Model>& model);
78 };
Definition: hpe_model_openpose.h:38
HPEOpenPose(const std::string &modelFileName, double aspectRatio, int targetSize, float confidenceThreshold, const std::string &layout="")
Definition: hpe_model_openpose.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