UnitreeCameraSDK  1.0.1
unitree stereo camra apis
StereoCameraCommon.hpp
Go to the documentation of this file.
1 
10 #ifndef __STEREO_CAMERA_COMMOM_HPP__
11 #define __STEREO_CAMERA_COMMOM_HPP__
12 
13 #include <string>
14 #include <thread>
15 #include <mutex>
16 #include <condition_variable>
17 #include <opencv2/opencv.hpp>
18 #include <chrono>
19 #include "SystemLog.hpp"
20 
28 typedef struct PCL {
29  cv::Vec3f pts;
30  cv::Vec3b clr;
31 }PCLType;
39 {
40 private:
47  typedef struct TimeFrame{
48  cv::Mat data1;
49  cv::Mat data2;
50  std::chrono::microseconds timeStamp;
51  }TimeFrameType;
52 
53 private:
54  int m_radius = 0;
55  int m_algorithm = 0;
56  int m_logLevel = 1;
57  int m_deviceNode = 0;
58  int m_posNumber = 0;
59  int m_serialNumber = 0;
60  int m_threshold = 120;
61  float m_frameRate = 30.0;
62  int m_ipLastSegment = 15;
63 
64  bool m_shareMemSupport = false;
65  bool m_udpH264Support = false;
66  bool m_isOpened = false;
67  bool m_isCompute = false;
68 
69  cv::Size m_frameSize;
70  cv::Size m_rectSize;
71 
72  TimeFrameType m_stampFrame, m_dispFrame;
73 
74  cv::Mat m_leftXi,m_leftRotation,m_leftIntrinsic,m_leftDistortion;
75  cv::Mat m_rightXi,m_rightRotation,m_rightIntrinsic,m_rightDistortion;
76  cv::Mat m_translation;
77 
78  cv::Mat m_kfe, m_fmap[2], m_lmap[2][2], m_lagerFmap[2];
79 
80  SystemLog *m_log = nullptr;
81  std::string m_logName = "StereoCamera";
82 
83  std::mutex m_capLock, m_dispLock;
84  std::condition_variable m_capTrigger, m_dispTrigger;
85 
86  cv::VideoCapture *m_videoCap = nullptr;
87 
88  std::thread *m_capWorker = nullptr;
89  std::thread *m_dispWorker = nullptr;
90 
91 public:
104  StereoCamera(void);
118  StereoCamera(std::string fileName);
132  StereoCamera(int deviceNode);
142  virtual ~StereoCamera();
143 
144 public:
159  virtual bool isOpened(void);
172  virtual bool setLogLevel(int level);
185  virtual bool setPosNumber(int posNumber);
198  virtual bool setSerialNumber(int serialNumber);
211  virtual bool setRawFrameRate(int frameRate);
225  virtual bool setRawFrameSize(cv::Size frameSize);
240  virtual bool setRectFrameSize(cv::Size frameSize);
257  virtual bool setCalibParams(std::vector<cv::Mat> paramsArray, bool flag = false);
270  virtual int getLogLevel(void) const;
283  virtual int getDeviceNode(void) const;
296  virtual int getPosNumber(void) const;
309  virtual int getSerialNumber(void) const;
321  virtual float getRawFrameRate(void) const;
333  virtual cv::Size getRawFrameSize(void) const;
349  virtual bool getRawFrame(cv::Mat &frame, std::chrono::microseconds &timeStamp);
370  virtual bool getStereoFrame(cv::Mat &left, cv::Mat &right, std::chrono::microseconds &timeStamp);
391  virtual bool getDepthFrame(cv::Mat& depth, bool color, std::chrono::microseconds &timeStamp);
412  virtual bool getPointCloud(std::vector<cv::Vec3f> &pcl, std::chrono::microseconds &timeStamp);
434  virtual bool getPointCloud(std::vector<PCLType>& pcl, std::chrono::microseconds& timeStamp);
453  virtual bool getCalibParams(std::vector<cv::Mat> &paramsArray, bool flag = false);
473  virtual bool getRectStereoFrame(cv::Mat &left, cv::Mat &right, cv::Mat &feim);
495  virtual bool getRectStereoFrame(cv::Mat &left, cv::Mat &right, cv::Mat &feim, std::chrono::microseconds &timeStamp);
511  virtual bool loadConfig(std::string fileName);
528  virtual bool loadCalibParams(std::string fileName);
541  virtual bool saveConfig(std::string fileName = "stereo_camera_config.yaml");
554  virtual bool saveCalibParams(std::string fileName = "stereo_camera_calibparams.yaml");
573  virtual bool startCapture(bool udpFlag = false, bool shmFlag = false);
588  virtual bool startStereoCompute(void);
603  virtual bool stopStereoCompute(void);
620  virtual bool stopCapture(void);
621 };
622 
623 #endif //__STEREO_CAMERA_COMMOM_HPP__
This file is part of UnitreeCameraSDK, which declare the APIs of log system.
this class integrate camera control and stereo vision algorithm
Definition: StereoCameraCommon.hpp:38
cv::Vec3f pts
points coordinates (x, y, z)
Definition: StereoCameraCommon.hpp:29
cv::Vec3b clr
points color (b, g, r)
Definition: StereoCameraCommon.hpp:30
Definition: SystemLog.hpp:18
this struct is used for RGB point cloud capture and display
Definition: StereoCameraCommon.hpp:28