Banuba SDK
Loading...
Searching...
No Matches
video_mocker.hpp
1
2#pragma once
3
4#include <chrono>
5#include <thread>
6#include <optional>
7
8#include <bnb/types/base_types.hpp>
9#include <bnb/spal/camera/base_mocker.hpp>
10#include <bnb/utils/defs.hpp>
11
12#if !BNB_OS_EMSCRIPTEN
13
14 #include <opencv2/core/core.hpp>
15 #include <opencv2/videoio.hpp>
16
17
18namespace bnb
19{
20 class BNB_EXPORT camera_video_mocker final : public camera_base_mocker
21 {
22 public:
23 typedef std::optional<cv::Rect> rect_t;
24
25 public:
26 camera_video_mocker(const camera_base::push_frame_cb_t& cb, uint32_t frame_rate, const std::string& input_file, const rect_t& clip_area);
27 camera_video_mocker(const camera_base::push_frame_cb_t& cb, const std::string& input_file, const rect_t& clip_area = std::nullopt);
29
30 void set_device_by_index(uint32_t device_index) override;
31 void set_device_by_id(const std::string& device_id) override;
32
33 private:
34 void update_image_content() final;
35
36 private:
37 uint32_t m_frame_width;
38 uint32_t m_frame_height;
39 uint32_t m_frame_size;
40
41 cv::VideoCapture m_capture;
42 std::optional<cv::Rect> m_clip_area;
43 };
44
45} // namespace bnb
46
47#endif