C++ reference¶
This is for the most part identical to the Python reference, so much of the descriptions are not here, The descriptions are mostly for the parts that differ from the Python interface.
Devices¶
Device¶
-
class Device¶
Subclassed by qamlib::StreamingDevice
Public Functions
-
virtual void set_control(const std::string &name, int value)¶
Set named control to
value
-
void set_control(uint32_t id, int value)¶
Set control of
idtovalue
-
int get_control(const std::string &name)¶
-
int get_control(uint32_t id)¶
-
void set_ext_control(const std::string &name, ControlValue &value)¶
-
std::unique_ptr<ControlValue> get_ext_control(const std::string &name, bool default_value = false)¶
-
std::map<std::string, std::unique_ptr<ControlValue>> get_controls(std::vector<std::string> names, bool default_value = false)¶
-
void set_controls(std::map<std::string, ControlValue*> values)¶
-
inline virtual ~Device()¶
Public Members
-
DeviceInfo device_info¶
-
virtual void set_control(const std::string &name, int value)¶
StreamingDevice¶
-
class StreamingDevice : public qamlib::Device¶
Subclassed by qamlib::Camera
Public Functions
-
virtual void start()¶
-
virtual void stop()¶
-
std::tuple<uint32_t, uint32_t> get_resolution()¶
-
std::tuple<uint32_t, uint32_t> set_resolution(uint32_t newWidth, uint32_t newHeight)¶
-
void set_crop(int left, int top, uint32_t width, uint32_t height)¶
-
std::map<std::string, ImageFormat> list_formats()¶
-
virtual void start()¶
Camera¶
-
class Camera : public qamlib::StreamingDevice¶
Class for interacting with a V4L2 capture device.
Public Functions
-
inline Camera(const std::string &device, std::optional<uint32_t> buffers = std::nullopt, bool overflow_exception = true)¶
-
inline Camera(uint32_t device_num, std::optional<uint32_t> buffers = std::nullopt, bool overflow_exception = true)¶
-
inline Camera(bool overflow_exception = true)¶
-
inline ~Camera() override¶
-
virtual void start() override¶
Start streaming from the camera
-
virtual void stop() override¶
Stop streaming from the camera
-
std::tuple<struct FrameMetadata, cv::Mat> get_frame(std::optional<double> timeout = std::nullopt, bool buffered = false)¶
Get latest frame from the camera as a OpenCV Mat object.
- Parameters:
timeout – Time in seconds to wait before throwing a TimeoutException. If 0 then there is no timeout.
buffered – If true then the first frame in the buffer is returned, if false then the latest frame is returned.
-
std::unique_ptr<FrameRate> get_framerates(uint32_t width, uint32_t height, const std::string &format, bool big_endian = false)¶
-
double get_framerate()¶
-
double set_framerate(double value)¶
-
inline Camera(const std::string &device, std::optional<uint32_t> buffers = std::nullopt, bool overflow_exception = true)¶
Controls¶
Control¶
ValueControl¶
-
class ValueControl : public qamlib::Control¶
Subclassed by qamlib::IntegerMenuControl, qamlib::MenuControl
ControlFlags¶
-
class ControlFlags¶
Public Functions
-
inline ControlFlags(uint32_t flags)¶
-
flag_function(disabled, V4L2_CTRL_FLAG_DISABLED)¶
-
flag_function(grabbed, V4L2_CTRL_FLAG_GRABBED)¶
-
flag_function(read_only, V4L2_CTRL_FLAG_READ_ONLY)¶
-
flag_function(update, V4L2_CTRL_FLAG_UPDATE)¶
-
flag_function(inactive, V4L2_CTRL_FLAG_INACTIVE)¶
-
flag_function(slider, V4L2_CTRL_FLAG_SLIDER)¶
-
flag_function(write_only, V4L2_CTRL_FLAG_WRITE_ONLY)¶
-
flag_function(is_volatile, V4L2_CTRL_FLAG_VOLATILE)¶
-
flag_function(has_payload, V4L2_CTRL_FLAG_HAS_PAYLOAD)¶
-
flag_function(execute_on_write, V4L2_CTRL_FLAG_EXECUTE_ON_WRITE)¶
-
flag_function(modify_layout, V4L2_CTRL_FLAG_MODIFY_LAYOUT)¶
-
flag_function(dynamic_array, V4L2_CTRL_FLAG_DYNAMIC_ARRAY)¶
-
std::string to_string() const¶
-
json to_json() const¶
Public Members
-
uint32_t flags¶
-
inline ControlFlags(uint32_t flags)¶
ControlValue classes¶
IntegerControlValue¶
-
class IntegerControlValue : public qamlib::ControlValue¶
Public Functions
-
inline IntegerControlValue(uint32_t type)¶
Internal
qamlibfunction not to be used otherwise
-
inline IntegerControlValue(int64_t value)¶
-
inline IntegerControlValue(int32_t value)¶
-
int64_t get_value() const¶
Internal
qamlibfunction not to be used otherwise
-
virtual void ready_control(v4l2_ext_control &ctrl) override¶
Internal
qamlibfunction not to be used otherwise
-
virtual void update_value(v4l2_ext_control &ctrl) override¶
Internal
qamlibfunction not to be used otherwise
-
virtual std::string to_string() const override¶
-
virtual json to_json() const override¶
-
inline IntegerControlValue(uint32_t type)¶
StringControlValue¶
-
class StringControlValue : public qamlib::ControlValue¶
Public Functions
-
inline StringControlValue(uint32_t max_size)¶
Internal
qamlibfunction not to be used otherwise
-
inline StringControlValue(std::string &val)¶
Internal
qamlibfunction not to be used otherwise
-
virtual void ready_control(v4l2_ext_control &ctrl) override¶
Internal
qamlibfunction not to be used otherwise
-
inline ~StringControlValue() override¶
-
virtual std::string to_string() const override¶
-
virtual json to_json() const override¶
-
inline StringControlValue(uint32_t max_size)¶
ArrayControlValue¶
-
class ArrayControlValue : public qamlib::ControlValue¶
Public Functions
-
inline ArrayControlValue(uint32_t elements, uint32_t element_size, std::vector<uint32_t> dims, bool sign = false)¶
-
inline ArrayControlValue(cv::Mat array)¶
-
cv::Mat get_array() const¶
Internal
qamlibfunction not to be used otherwise
-
virtual void ready_control(v4l2_ext_control &ctrl) override¶
Internal
qamlibfunction not to be used otherwise
-
inline ~ArrayControlValue() override¶
-
virtual std::string to_string() const override¶
-
virtual json to_json() const override¶
-
inline ArrayControlValue(uint32_t elements, uint32_t element_size, std::vector<uint32_t> dims, bool sign = false)¶
Formats¶
ImageFormat¶
-
class ImageFormat¶
Public Functions
-
inline ImageFormat(struct v4l2_fmtdesc *fmt)¶
-
std::string to_string() const¶
-
json to_json() const¶
Public Members
-
uint32_t index¶
-
ImageFormatFlags flags¶
-
std::string description¶
-
PixelFormat pixelformat¶
-
inline ImageFormat(struct v4l2_fmtdesc *fmt)¶
ImageFormatFlags¶
-
class ImageFormatFlags¶
Public Functions
-
inline ImageFormatFlags(uint32_t flags)¶
-
flag_function(compressed, V4L2_FMT_FLAG_COMPRESSED)¶
-
flag_function(emulated, V4L2_FMT_FLAG_EMULATED)¶
-
flag_function(continuous_bytestream, V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM)¶
-
flag_function(dyn_resolution, V4L2_FMT_FLAG_DYN_RESOLUTION)¶
-
flag_function(enc_cap_frame_interval, V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL)¶
-
flag_function(csc_colorspace, V4L2_FMT_FLAG_CSC_COLORSPACE)¶
-
flag_function(csc_xfer_func, V4L2_FMT_FLAG_CSC_XFER_FUNC)¶
-
flag_function(csc_ycbcr_enc, V4L2_FMT_FLAG_CSC_YCBCR_ENC)¶
-
flag_function(csc_hsv_enc, V4L2_FMT_FLAG_CSC_HSV_ENC)¶
-
flag_function(csc_quantization, V4L2_FMT_FLAG_CSC_QUANTIZATION)¶
-
std::string to_string() const¶
-
json to_json() const¶
Public Members
-
uint32_t flags¶
-
inline ImageFormatFlags(uint32_t flags)¶
Format¶
-
class Format¶
Subclassed by qamlib::SinglePlaneFormat
Public Members
-
v4l2_buf_type type¶
-
v4l2_buf_type type¶
SinglePlaneFormat¶
PixelFormat¶
-
class PixelFormat¶
Public Functions
-
inline PixelFormat(uint32_t code)¶
-
inline PixelFormat(const std::string &fourcc, bool big_endian)¶
-
inline PixelFormat(const std::string &fourcc)¶
-
std::string get_fourcc() const¶
-
void set_fourcc(std::string &new_name)¶
-
uint32_t get_code() const¶
-
std::string to_string() const¶
Public Members
-
bool big_endian = false¶
-
inline PixelFormat(uint32_t code)¶
PixelFormatFlags¶
Framerates¶
FrameRate¶
-
class FrameRate¶
Subclassed by qamlib::ContinuousFrameRate, qamlib::DiscreteFrameRate
Public Functions
-
virtual ~FrameRate() = default¶
Public Members
-
v4l2_frmivaltypes type¶
-
virtual ~FrameRate() = default¶
DiscreteFrameRate¶
ContinuousFrameRate¶
StepwiseFrameRate¶
Events¶
BaseEvent¶
-
class BaseEvent¶
Subclassed by qamlib::ControlEvent, qamlib::SourceEvent
ControlEvent¶
EventType¶
ControlChangesFlags¶
-
class ControlChangesFlags¶
Misc¶
FrameMetadata¶
-
class FrameMetadata¶
Metadata for a frame. time is in machine clock with clock specifying which clock is used sequence is the framenumber since the stream was started
Public Functions
-
std::string to_string()¶
Function to “pretty-print” the FrameMetadata struct
-
std::string to_string()¶
Rectangle¶
Exceptions¶
V4L2Exception¶
-
class V4L2Exception : public std::exception¶
Subclassed by qamlib::V4L2BusyException
TimeoutException¶
-
class TimeoutException : public std::exception¶
DroppedFrameException¶
-
class DroppedFrameException : public std::exception¶