Banuba SDK
Loading...
Searching...
No Matches
base.hpp
1#pragma once
2
3#include <bnb/types/full_image.hpp>
4#include <bnb/utils/event.hpp>
5#include <bnb/utils/defs.hpp>
6
7#include <functional>
8#include <atomic>
9#include <string>
10
11namespace cv
12{
13 class Mat;
14}
15
16namespace bnb
17{
19 {
20 std::string localized_name;
21 };
22
23 class BNB_EXPORT camera_base
24 {
25 public:
26 using push_frame_cb_t = std::function<void(bnb::full_image_t image)>;
27
28 enum class camera_format
29 {
30 RGBA,
31 YUV
32 };
33 inline static camera_format current_format = camera_format::RGBA;
34
35 /*
36 * Main thread
37 */
38 explicit camera_base(push_frame_cb_t cb)
39 : m_push_frame_cb(std::move(cb))
40 , m_is_abort_requested(false)
41 , m_device_index(0)
42 {
43 }
44
45 virtual void set_device_by_index(uint32_t index) = 0;
46 virtual void set_device_by_id(const std::string& device_id) = 0;
47 virtual void start() = 0;
48 const std::vector<camera_device_description> get_connected_devices() const
49 {
50 return m_connected_devices;
51 }
52 size_t get_current_device_index() const
53 {
54 return m_device_index;
55 }
56
57 virtual ~camera_base() = default;
58
59 protected:
60 /*
61 * Any Thread
62 */
63 virtual void abort()
64 {
65 m_is_abort_requested = true;
66 }
67
68 protected:
69 push_frame_cb_t m_push_frame_cb;
70 std::atomic_bool m_is_abort_requested;
71 std::vector<camera_device_description> m_connected_devices;
72 size_t m_device_index;
73 };
74
75 using camera_uptr = std::unique_ptr<camera_base>;
76 using camera_sptr = std::shared_ptr<camera_base>;
77
78 BNB_EXPORT camera_sptr create_camera_device(camera_base::push_frame_cb_t cb, size_t index);
79} // namespace bnb
basis is the base basis: for y/rgb basis use .basis or get_subchannel_basis_transform(1); for uv basi...