InfraredManager.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <opencv2/opencv.hpp>
  2. #include <opencv2/core.hpp>
  3. #include <opencv2/videoio.hpp>
  4. #include <queue>
  5. #include <mutex>
  6. #define BUFFER_SIZE 50
  7. typedef std::pair<cv::Mat, double> InfraredImagePair;
  8. class InfraredManager
  9. {
  10. public:
  11. InfraredManager() = default;
  12. ~InfraredManager()= default;
  13. // init
  14. void init(std::string infraredStreamPath);
  15. // open the stream
  16. void openStream();
  17. // a thread to get the infrared image
  18. static void getInfraredImageThread(InfraredManager* infraredManager);
  19. private:
  20. std::string m_infraredStreamPath;
  21. // infrared stream
  22. cv::VideoCapture m_infraredStream;
  23. // infrared stream width
  24. int m_infraredStreamWidth;
  25. // infrared stream height
  26. int m_infraredStreamHeight;
  27. // infrared stream fps
  28. int m_infraredStreamFps;
  29. // get the timestamp of the infrared image
  30. double m_infraredImageTimestamp;
  31. // a buffer to store the timestamp of the infrared image
  32. std::queue<InfraredImagePair> m_infraredImageTimestampBuffer;
  33. cv::Mat m_infraredImage;
  34. // a mutex
  35. std::mutex m_mutex;
  36. // a switch to control the thread
  37. bool m_getInfraredImageThreadSwitch;
  38. };