OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
webcamReader.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_PRODUCER_WEBCAM_READER_HPP
2 #define OPENPOSE_PRODUCER_WEBCAM_READER_HPP
3 
4 #include <atomic>
5 #include <mutex>
8 
9 namespace op
10 {
16  {
17  public:
27  explicit WebcamReader(const int webcamIndex = 0, const Point<int>& webcamResolution = Point<int>{},
28  const bool throwExceptionIfNoOpened = true, const std::string& cameraParameterPath = "",
29  const bool undistortImage = false);
30 
31  virtual ~WebcamReader();
32 
33  std::string getNextFrameName();
34 
35  bool isOpened() const;
36 
37  double get(const int capProperty);
38 
39  void set(const int capProperty, const double value);
40 
41  private:
42  const int mIndex;
43  const bool mWebcamStarted;
44  long long mFrameNameCounter;
45  bool mThreadOpened;
46  Matrix mBuffer;
47  std::mutex mBufferMutex;
48  std::atomic<bool> mCloseThread;
49  std::thread mThread;
50  // Detect camera unplugged
51  double mLastNorm;
52  std::atomic<int> mDisconnectedCounter;
53  Point<int> mResolution;
54 
55  Matrix getRawFrame();
56 
57  std::vector<Matrix> getRawFrames();
58 
59  void bufferingThread();
60 
61  bool reset();
62 
64  };
65 }
66 
67 #endif // OPENPOSE_PRODUCER_WEBCAM_READER_HPP
WebcamReader(const int webcamIndex=0, const Point< int > &webcamResolution=Point< int >{}, const bool throwExceptionIfNoOpened=true, const std::string &cameraParameterPath="", const bool undistortImage=false)
double get(const int capProperty)
std::string getNextFrameName()
bool isOpened() const
void set(const int capProperty, const double value)
virtual ~WebcamReader()
#define OP_API
Definition: macros.hpp:18
#define DELETE_COPY(className)
Definition: macros.hpp:32