SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
ma_camera.h
Go to the documentation of this file.
1 #ifndef _MA_CAMERA_H_
2 #define _MA_CAMERA_H_
3 
5 #include <core/ma_types.h>
6 
7 #include <string>
8 
9 #include "ma_sensor.h"
10 
11 namespace ma {
12 
13 class Camera : public Sensor {
14  public:
15  enum StreamMode : int {
19  };
20 
21  static std::string __repr__(StreamMode mode) noexcept {
22  switch (mode) {
23  case StreamMode::kRefreshOnReturn:
24  return "RefreshOnReturn";
25  case StreamMode::kRefreshOnRetrieve:
26  return "RefreshOnRetrieve";
27  default:
28  return "Unknown";
29  }
30  }
31 
32  enum CtrlType : int {
56  };
57 
58  enum CtrlMode : int {
61  };
62 
63  struct CtrlValue {
64  union {
65  uint8_t bytes[4];
66  uint16_t u16s[2];
67  int32_t i32;
68  float f32;
69  };
70  };
71 
72  public:
73  Camera(size_t id) noexcept : Sensor(id, Sensor::Type::kCamera), m_streaming(false), m_stream_mode(kUnknown) {}
74  virtual ~Camera() = default;
75 
76  [[nodiscard]] virtual ma_err_t startStream(StreamMode mode) noexcept = 0;
77  virtual void stopStream() noexcept = 0;
78 
79  [[nodiscard]] virtual ma_err_t commandCtrl(CtrlType ctrl, CtrlMode mode, CtrlValue& value) noexcept = 0;
80 
81  [[nodiscard]] virtual ma_err_t retrieveFrame(ma_img_t& frame, ma_pixel_format_t format) noexcept = 0;
82  virtual void returnFrame(ma_img_t& frame) noexcept = 0;
83 
84  [[nodiscard]] bool isStreaming() const noexcept { return m_streaming; }
85 
86  private:
87  Camera(const Camera&) = delete;
88  Camera& operator=(const Camera&) = delete;
89 
90  protected:
93 };
94 
95 } // namespace ma
96 
97 #endif
Definition: ma_camera.h:13
CtrlType
Definition: ma_camera.h:32
@ kWhiteBalance
Definition: ma_camera.h:36
@ kIris
Definition: ma_camera.h:41
@ kFormat
Definition: ma_camera.h:52
@ kFocus
Definition: ma_camera.h:37
@ kFps
Definition: ma_camera.h:54
@ kColorTemperature
Definition: ma_camera.h:49
@ kGain
Definition: ma_camera.h:35
@ kPan
Definition: ma_camera.h:39
@ kRegister
Definition: ma_camera.h:55
@ kChannel
Definition: ma_camera.h:53
@ kExposure
Definition: ma_camera.h:34
@ kHue
Definition: ma_camera.h:46
@ kGamma
Definition: ma_camera.h:48
@ kBacklightCompensation
Definition: ma_camera.h:50
@ kSaturation
Definition: ma_camera.h:45
@ kBrightness
Definition: ma_camera.h:43
@ kRotate
Definition: ma_camera.h:51
@ kTilt
Definition: ma_camera.h:40
@ kWindow
Definition: ma_camera.h:33
@ kZoom
Definition: ma_camera.h:38
@ kSharpness
Definition: ma_camera.h:47
@ kShutter
Definition: ma_camera.h:42
@ kContrast
Definition: ma_camera.h:44
virtual void returnFrame(ma_img_t &frame) noexcept=0
static std::string __repr__(StreamMode mode) noexcept
Definition: ma_camera.h:21
virtual void stopStream() noexcept=0
virtual ma_err_t startStream(StreamMode mode) noexcept=0
virtual ~Camera()=default
Camera(size_t id) noexcept
Definition: ma_camera.h:73
StreamMode m_stream_mode
Definition: ma_camera.h:92
StreamMode
Definition: ma_camera.h:15
@ kUnknown
Definition: ma_camera.h:16
@ kRefreshOnRetrieve
Definition: ma_camera.h:18
@ kRefreshOnReturn
Definition: ma_camera.h:17
virtual ma_err_t commandCtrl(CtrlType ctrl, CtrlMode mode, CtrlValue &value) noexcept=0
CtrlMode
Definition: ma_camera.h:58
@ kRead
Definition: ma_camera.h:59
@ kWrite
Definition: ma_camera.h:60
bool isStreaming() const noexcept
Definition: ma_camera.h:84
bool m_streaming
Definition: ma_camera.h:91
virtual ma_err_t retrieveFrame(ma_img_t &frame, ma_pixel_format_t format) noexcept=0
Definition: ma_sensor.h:12
Sensor(size_t id, Type type) noexcept
Definition: ma_sensor.h:41
ma_err_t
Definition: ma_types.h:21
ma_pixel_format_t
Definition: ma_types.h:103
Definition: ma_cv.cpp:7
Definition: ma_camera.h:63
float f32
Definition: ma_camera.h:68
uint16_t u16s[2]
Definition: ma_camera.h:66
int32_t i32
Definition: ma_camera.h:67
uint8_t bytes[4]
Definition: ma_camera.h:65
Definition: ma_types.h:124