OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
handExtractor.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_HAND_HAND_EXTRACTOR_HPP
2 #define OPENPOSE_HAND_HAND_EXTRACTOR_HPP
3 
4 #include <atomic>
5 #include <thread>
6 #include <opencv2/core/core.hpp> // cv::Mat
10 #include <openpose/core/net.hpp>
12 
13 namespace op
14 {
19  {
20  public:
31  explicit HandExtractor(const Point<int>& netInputSize, const Point<int>& netOutputSize,
32  const std::string& modelFolder, const int gpuId,
33  const unsigned short numberScales = 1, const float rangeScales = 0.4f,
34  const std::vector<HeatMapType>& heatMapTypes = {},
35  const ScaleMode heatMapScale = ScaleMode::ZeroToOne);
36 
41  void initializationOnThread();
42 
54  void forwardPass(const std::vector<std::array<Rectangle<float>, 2>> handRectangles, const cv::Mat& cvInputData,
55  const float scaleInputToOutput);
56 
64  std::array<Array<float>, 2> getHandKeypoints() const;
65 
66  std::array<Array<float>, 2> getHeatMaps() const;
67 
68  private:
69  const std::pair<unsigned short, float> mMultiScaleNumberAndRange;
70  const Point<int> mNetOutputSize;
71  std::shared_ptr<Net> spNet;
72  std::shared_ptr<ResizeAndMergeCaffe<float>> spResizeAndMergeCaffe;
73  std::shared_ptr<MaximumCaffe<float>> spMaximumCaffe;
74  Array<float> mHandImageCrop;
75  std::array<Array<float>, 2> mHandKeypoints;
76  // HeatMaps parameters
77  const ScaleMode mHeatMapScaleMode;
78  const std::vector<HeatMapType> mHeatMapTypes;
79  std::array<Array<float>, 2> mHeatMaps;
80  // Init with thread
81  boost::shared_ptr<caffe::Blob<float>> spCaffeNetOutputBlob;
82  std::shared_ptr<caffe::Blob<float>> spHeatMapsBlob;
83  std::shared_ptr<caffe::Blob<float>> spPeaksBlob;
84  std::thread::id mThreadId;
85 
86  void checkThread() const;
87 
88  void detectHandKeypoints(Array<float>& handCurrent, const float scaleInputToOutput, const int person,
89  const cv::Mat& affineMatrix);
90 
91  Array<float> getHeatMapsFromLastPass() const;
92 
94  };
95 }
96 
97 #endif // OPENPOSE_HAND_HAND_EXTRACTOR_HPP
#define DELETE_COPY(className)
Definition: macros.hpp:25
Definition: handExtractor.hpp:18
ScaleMode
Definition: enumClasses.hpp:6
Definition: rectangle.hpp:10
#define OP_API
Definition: macros.hpp:5