OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
producer.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_PRODUCER_PRODUCER_HPP
2 #define OPENPOSE_PRODUCER_PRODUCER_HPP
3 
4 #include <opencv2/core/core.hpp> // cv::Mat
5 #include <opencv2/highgui/highgui.hpp> // capProperties of OpenCV
8 
9 namespace op
10 {
16  {
17  public:
23  explicit Producer(const ProducerType type);
24 
29  virtual ~Producer();
30 
35  cv::Mat getFrame();
36 
41  std::vector<cv::Mat> getFrames();
42 
47  virtual std::vector<cv::Mat> getCameraMatrices() = 0;
48 
53  virtual std::vector<cv::Mat> getCameraExtrinsics() = 0;
54 
59  virtual std::vector<cv::Mat> getCameraIntrinsics() = 0;
60 
66  virtual std::string getNextFrameName() = 0;
67 
73  void setProducerFpsMode(const ProducerFpsMode fpsMode);
74 
80  {
81  return mType;
82  }
83 
89  virtual bool isOpened() const = 0;
90 
95  virtual void release() = 0;
96 
104  virtual double get(const int capProperty) = 0;
105 
113  virtual void set(const int capProperty, const double value) = 0;
114 
119  double get(const ProducerProperty property);
120 
126  void set(const ProducerProperty property, const double value);
127 
128  protected:
135  void checkFrameIntegrity(cv::Mat& frame);
136 
141  void flipAndRotate(cv::Mat& cvMat) const;
142 
147  void ifEndedResetOrRelease();
148 
152  void keepDesiredFrameRate();
153 
158  virtual cv::Mat getRawFrame() = 0;
159 
165  virtual std::vector<cv::Mat> getRawFrames() = 0;
166 
167  private:
168  const ProducerType mType;
169  ProducerFpsMode mProducerFpsMode;
170  std::array<double, (int)ProducerProperty::Size> mProperties;
171  unsigned int mNumberEmptyFrames;
172  // For ProducerFpsMode::OriginalFps
173  bool mTrackingFps;
174  unsigned long long mFirstFrameTrackingFps;
175  unsigned long long mNumberFramesTrackingFps;
176  unsigned int mNumberSetPositionTrackingFps;
177  std::chrono::high_resolution_clock::time_point mClockTrackingFps;
178 
180  };
181 
185  OP_API std::shared_ptr<Producer> createProducer(
186  const ProducerType producerType = ProducerType::None, const std::string& producerString = "",
187  const Point<int>& cameraResolution = Point<int>{-1,-1}, const double webcamFps = 30.,
188  const std::string& cameraParameterPath = "models/cameraParameters/", const bool undistortImage = true,
189  const unsigned int imageDirectoryStereo = -1);
190 }
191 
192 #endif // OPENPOSE_PRODUCER_PRODUCER_HPP
#define DELETE_COPY(className)
Definition: macros.hpp:33
OP_API std::shared_ptr< Producer > createProducer(const ProducerType producerType=ProducerType::None, const std::string &producerString="", const Point< int > &cameraResolution=Point< int >{-1,-1}, const double webcamFps=30., const std::string &cameraParameterPath="models/cameraParameters/", const bool undistortImage=true, const unsigned int imageDirectoryStereo=-1)
ProducerFpsMode
Definition: enumClasses.hpp:6
ProducerProperty
Definition: enumClasses.hpp:14
Definition: producer.hpp:15
ProducerType getType()
Definition: producer.hpp:79
ProducerType
Definition: enumClasses.hpp:28
#define OP_API
Definition: macros.hpp:18
std::string string
Definition: cl2.hpp:574