CVideoCapture.h 528 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <opencv2/opencv.hpp>
  3. #include <opencv2/dnn.hpp>
  4. //这个Worker只负责从摄像头读取图像数据,不负责进行任何处理
  5. class CVideoCapture
  6. {
  7. public:
  8. CVideoCapture();
  9. ~CVideoCapture();
  10. static CVideoCapture * GetInstance()
  11. {
  12. static CVideoCapture instance;
  13. return &instance;
  14. }
  15. void InitVideoCapture();
  16. bool GetFrame(cv::Mat& frame);
  17. private:
  18. int findAvailableCamera();
  19. private:
  20. bool m_is_video_capture_open = false;
  21. cv::VideoCapture m_cap;
  22. std::mutex m_init_mutex;
  23. };