Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
Loading...
Searching...
No Matches
camera_control.hpp
1#pragma once
2
3#include <functional>
4#include <memory>
5#include <optional>
6#include <string>
7#include <variant>
8#include <vector>
9
10namespace auterion {
15class CameraControlImpl;
16
18 public:
19 using Value = std::variant<int64_t, double, std::string>;
20
21 enum class Mode {
22 Readable,
23 Writable,
24 ReadWrite,
25 };
26
28 enum class ControlId {
29 Exposure,
30 Gain,
32 };
33
34 static std::string toString(ControlId control) {
35 switch (control) {
37 return "ExposureTimeAb";
38 case ControlId::Gain:
39 return "Gain";
41 return "AeMode";
42 }
43 return "Unknown";
44 }
45
46 struct Control {
47 std::string name;
48 Mode mode;
49 std::optional<Value> default_value;
50 };
51
52 CameraControl(std::unique_ptr<CameraControlImpl> impl);
53 ~CameraControl() = default;
54
55 CameraControl(const CameraControl& other) = delete;
56 CameraControl& operator=(const CameraControl& other) = delete;
57 CameraControl(CameraControl&& other) = delete;
58 CameraControl& operator=(CameraControl&& other) = delete;
59
63 std::vector<Control> enumerate() const;
64
65 std::vector<std::optional<Value>> get(const std::vector<std::string>& control_names) const;
66 std::optional<Value> get(const std::string& control_name) const;
67 std::optional<Value> get(const ControlId& control) const { return get(toString(control)); }
68
73 bool set(const std::vector<std::string>& control_names, const std::vector<Value>& values) const;
74 bool set(const std::string& control_name, const Value& value) const;
75 bool set(const ControlId& control, const Value& value) const {
76 return set(toString(control), value);
77 }
78
88 using EnumerateCallback =
89 std::function<void(const std::optional<std::vector<Control>>& controls)>;
90 using GetCallback = std::function<void(const std::vector<std::optional<Value>>& values)>;
91 using SetCallback = std::function<void(const std::vector<bool>& accepted)>;
92
94 bool available() const;
96 void enumerate(EnumerateCallback callback) const;
98 void get(const std::vector<std::string>& control_names, GetCallback callback) const;
101 void set(const std::vector<std::string>& control_names, const std::vector<Value>& values,
102 SetCallback callback) const;
105 private:
106 std::unique_ptr<CameraControlImpl> _impl;
107};
108
110} // namespace auterion
Definition camera_control.hpp:17
std::vector< Control > enumerate() const
Get a list of all supported controls by this camera.
void get(const std::vector< std::string > &control_names, GetCallback callback) const
callback gets a value per control, nullopt where a control failed
void enumerate(EnumerateCallback callback) const
callback gets the controls, or nullopt if the reply could not be parsed
void set(const std::vector< std::string > &control_names, const std::vector< Value > &values, SetCallback callback) const
bool set(const std::vector< std::string > &control_names, const std::vector< Value > &values) const
Set controls, applied in the given order.
bool available() const
Whether the camera's control services are available.
ControlId
Well-known controls.
Definition camera_control.hpp:28
@ AutoExposureMode
Auto exposure mode, device-specific (typically 0 = manual, 1 = auto)
@ Exposure
Absolute exposure time, unit: 100us, 1 stands for 1/10'000 of a second.
Definition camera_control.hpp:46