Banuba SDK
ocv_based.hpp
1 
2 #pragma once
3 
4 #include <bnb/types/base_types.hpp>
5 #include <bnb/spal/camera/base.hpp>
6 
7 #if !BNB_OS_MACOS && !BNB_OS_WINDOWS && !BNB_OS_EMSCRIPTEN
8  #include <opencv2/videoio.hpp>
9  #include <opencv2/videoio/videoio_c.h>
10 
11  #include <thread>
12  #include <mutex>
13 
14 namespace bnb
15 {
16  class BNB_EXPORT camera_ocv : public camera_base
17  {
18  public:
19  explicit camera_ocv(const camera_base::push_frame_cb_t& cb, size_t index);
20  ~camera_ocv() override;
21 
22  void set_device_by_index(uint32_t device_index) override;
23  void set_device_by_id(const std::string& device_id) override;
24  void start() override;
25 
26  private:
27  void thread_func();
28 
29  void update_image_content();
30 
31  cv::VideoCapture m_capture;
32 
33  std::thread m_thread;
34 
35  uint32_t m_frame_width{0};
36  uint32_t m_frame_height{0};
37  uint32_t m_frame_size = m_frame_width * m_frame_height;
38  uint32_t m_device_count{0};
39  std::mutex m_mutex;
40  };
41 } // namespace bnb
42 #endif
bnb::camera_ocv
Definition: ocv_based.hpp:16
bnb::camera_base
Definition: base.hpp:23