Reference¶
Devices¶
- class qamlib.Device¶
Base class for a V4L2 device
- get_control(*args, **kwargs)¶
Overloaded function.
get_control(self: qamlib.Device, name: str) -> int
Get current value of control by name
This is only for non-extended controls (eg. integer, menu, etc.)
- Parameters:
name – Full name of the control, case is ignored.
- Returns:
The integer value of the given control.
get_control(self: qamlib.Device, id: typing.SupportsInt) -> int
Get current value of control by id.
This is only for non-extended controls (eg. integer, menu, etc.)
- Parameters:
id – ID of the control, there is no check if a control with that ID actually exists.
- Returns:
The integer value of the given control
- get_controls(self: qamlib.Device, names: collections.abc.Sequence[str], default_value: bool = False) dict[str, qamlib.ControlValue]¶
Get current values of a list of (extended) control names
- Parameters:
names – List of full control names, case is ignored
default_value – If
Truethe default value of the control is returned.
- Returns:
A dictionary with lower-case control names as keys, and a
ControlValuewith the value of the given control.
- get_ext_control(self: qamlib.Device, name: str, default_value: bool = False) qamlib.ControlValue¶
Get current value of an (extended) control
- Parameters:
name – Full name of the control, case is ignored.
default_value – If
Truethe default value of the control is returned.
- Returns:
A
ControlValuewith the value of the given control
- list_controls(self: qamlib.Device) dict[str, qamlib.Control]¶
List all the controls for the device
- Returns:
A list of all controls and their information.
- set_control(*args, **kwargs)¶
Overloaded function.
set_control(self: qamlib.Device, name: str, value: typing.SupportsInt) -> None
Set a normal named control to desired value.
- Parameters:
name – Full name of the control, case is ignored.
value – Integer value to set.
set_control(self: qamlib.Device, id: typing.SupportsInt, value: typing.SupportsInt) -> None
Set a normal control, by id to desired value
- Parameters:
id – ID of the control, there is no check if a control with that ID actually exists.
value –
Integer value to set.
NOTE: This function does not do any checks of the control ID or value
- set_controls(self: qamlib.Device, values: collections.abc.Mapping[str, qamlib.ControlValue]) None¶
Set values of (extended) controls by name
- Parameters:
values – A dictionary of control names as keys (case is ignored), and a
ControlValuederived class with the value to be set for the control.
- set_ext_control(self: qamlib.Device, name: str, ctrl_val: qamlib.ControlValue) None¶
Set value of an (extended) control
- Parameters:
name – Full name of the control, case is ignored.
ctrl_val – A
ControlValuederived class with the value to set for the control.
- property device_info¶
DeviceInfoobject
- class qamlib.StreamingDevice¶
Base class for devices that support streaming, inherits from
Device- __enter__(self: qamlib.StreamingDevice) None¶
Enter runtime context, starts the device stream
- __exit__(self: qamlib.StreamingDevice, arg0: object, arg1: object, arg2: object) None¶
Exit runtime context, stops the stream
- get_crop(self: qamlib.StreamingDevice) list[qamlib.Rectangle]¶
Get current crop selection (left, top, width, height)
- get_crop_bounds(self: qamlib.StreamingDevice) qamlib.Rectangle¶
Get crop selection bounds (left, top, width, height)
- get_crop_default(self: qamlib.StreamingDevice) qamlib.Rectangle¶
Get default crop selection (left, top, width, height)
- list_formats(self: qamlib.StreamingDevice) dict[str, qamlib.ImageFormat]¶
List all available formats for the device
- set_crop(*args, **kwargs)¶
Overloaded function.
set_crop(self: qamlib.StreamingDevice, left: typing.SupportsInt, top: typing.SupportsInt, width: typing.SupportsInt, height: typing.SupportsInt) -> None
Set crop selection using V4L2s selection API. This function will change the resolution if needed.
set_crop(self: qamlib.StreamingDevice, rectangles: qamlib.Rectangle) -> None
Set crop selection using V4L2s selection API. This function will change the resolution if needed.
set_crop(self: qamlib.StreamingDevice, rectangles: collections.abc.Sequence[qamlib.Rectangle]) -> None
Set crop selections, using V4L2s selection API, there are some driver and logic limitations to multi-crop, because of this, the rectangles cannot overlap in the height dimension. This function will change the resolution if needed.
- start(self: qamlib.StreamingDevice) None¶
Starts the device stream
- stop(self: qamlib.StreamingDevice) None¶
Stops the device stream
- class qamlib.Camera¶
Class for a V4L2 capture device, inherits from
StreamingDevice- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: qamlib.Camera, path: str, buffers: typing.SupportsInt | None = None, overflow_exception: bool = True) -> None
Open V4L2 device at
path.- Parameters:
path – Path to the V4L2 capture device
buffers – The size of the userspace ring-buffer.
qamlibwill request a small amount>buffersso the driver always has a buffer ready. Seeget_framefor when and how the buffer is used.overflow_exception – Whether to throw
DroppedFrameExceptionwhen frames are dropped inget_frame(buffered=True)
__init__(self: qamlib.Camera, device_num: typing.SupportsInt, buffers: typing.SupportsInt | None = None, overflow_exception: bool = True) -> None
Open V4L2 device number:
device_num.- Parameters:
device_num – Video device number. (
/dev/videoX)buffers – The size of the userspace ring-buffer.
qamlibwill request a small amount>buffersso the driver always has a buffer ready. Seeget_framefor when and how the buffer is used.overflow_exception – Whether to throw
DroppedFrameExceptionwhen frames are dropped inget_frame(buffered=True)
__init__(self: qamlib.Camera, overflow_exception: bool = True) -> None
Opens
/dev/qtec/video0- Parameters:
overflow_exception – Whether to throw
DroppedFrameExceptionwhen frames are dropped inget_frame(buffered=True)
- get_format(self: qamlib.Camera) qamlib.Format¶
Get the currently set format
- get_frame(self: qamlib.Camera, timeout: SupportsFloat | None = None, buffered: bool = False) tuple[qamlib.FrameMetadata, numpy.ndarray]¶
Get frame from camera.
- Parameters:
timeout – Time in seconds to wait before throwing a:class:TimeoutException if no frame is ready. Negative timeouts are allowed, and results in immediate timeout if no frame is ready.
buffered – If
Truethen the next frame in the buffer is returned, otherwise the newest frame in the buffer is returned.
- Returns:
The
FrameMetadatafor the frame and the frame as a NumPyndarray- Raises:
TimeoutException – If the
timeoutis reached.DroppedFrameException – If
buffered=Trueand the buffer has overrun.
- get_framerate(self: qamlib.Camera) float¶
Get current framerate in frames per second (FPS)
- get_framerates(*args, **kwargs)¶
Overloaded function.
get_framerates(self: qamlib.Camera) -> qamlib.FrameRate
Get possible framerates for current resolution and format
- Returns:
A
FrameRatederived object with the possible framerates.
get_framerates(self: qamlib.Camera, width: typing.SupportsInt, height: typing.SupportsInt) -> qamlib.FrameRate
Get possible framerates for current format at the given resolution
- Parameters:
width – Frame width.
height – Frame height.
- Returns:
A
FrameRatederived object with the possible framerates.
get_framerates(self: qamlib.Camera, width: typing.SupportsInt, height: typing.SupportsInt, pixelformat: str, big_endian: bool = False) -> qamlib.FrameRate
Get possible framerates for the given format at the given resolution
- Parameters:
width – Frame width.
height – Frame height.
pixelformat – FourCC name of the format (eg. “RGB”)
big_endian – Whether the format is big endian. This is also true if the
pixelformatname has “_BE” appended to it
- Returns:
A
FrameRatederived object with the possible framerates.
- get_resolution(self: qamlib.Camera) tuple[int, int]¶
Get current resolution
- set_format(*args, **kwargs)¶
Overloaded function.
set_format(self: qamlib.Camera, format: qamlib.Format) -> qamlib.Format
Set image format
set_format(self: qamlib.Camera, format: str, big_endian: bool = False) -> qamlib.Format
Set image format by format name, this function alsoscales selection for the new format
- set_framerate(self: qamlib.Camera, framerate: SupportsFloat) float¶
Tries to set the desired framerate, returns the actual framerate that we got
- set_resolution(self: qamlib.Camera, width: SupportsInt, height: SupportsInt) tuple[int, int]¶
Try to set the desired resolution, and returns the resolution that was set
- class qamlib.EventDevice¶
Class for getting events from a V4L2 device
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: qamlib.EventDevice) -> None
__init__(self: qamlib.EventDevice, arg0: str) -> None
__init__(self: qamlib.EventDevice, arg0: typing.SupportsInt) -> None
- set_callback(self: qamlib.EventDevice, arg0: collections.abc.Callable[[qamlib::BaseEvent], None]) None¶
Set the callback function
- start(self: qamlib.EventDevice) None¶
Start capturing events
- stop(self: qamlib.EventDevice) None¶
Stop capturing events
- subscribe(self: qamlib.EventDevice, type: SupportsInt, id: SupportsInt = 0) None¶
Subscribe to event
- unsubscribe(self: qamlib.EventDevice, type: SupportsInt, id: SupportsInt = 0) None¶
Unsubscribe from event
Controls¶
- class qamlib.Control¶
This class represents the information about a camera control.
- to_json(self: qamlib.Control) json¶
- property dimensions¶
The dimensions of the element array
- property element_size¶
The size of the control elements
- property elements¶
The number of control elemets
- property flags¶
Class representing the control flags
- property id¶
ID of the camera control
- property name¶
Name of the camera control
- property type¶
Type of the camera control
- class qamlib.ValueControl¶
Inherits from Control, represents a normal control with a single value
- to_json(self: qamlib.ValueControl) json¶
- property default_value¶
The default value of the camera control
- property max¶
The maximum value of the camera control
- property min¶
The minimum value of the camera control
- property step¶
The step size of the camera control
- class qamlib.MenuControl¶
Inherits from ValueControl. Represents a menu control, with the names of the items
- to_json(self: qamlib.MenuControl) json¶
- property items¶
Names of the menu items
- class qamlib.IntegerMenuControl¶
Inherits from ValueControl. Reprenests an integer menu control, with the values of the items
- to_json(self: qamlib.IntegerMenuControl) json¶
- property items¶
Values of the menu items
- class qamlib.ControlFlags¶
Class that represents the flags of a control. For more information about their meaning see here.
- to_json(self: qamlib.ControlFlags) json¶
- property disabled¶
- property dynamic_array¶
- property execute_on_write¶
- property grabbed¶
- property has_payload¶
- property inactive¶
- property is_volatile¶
- property modify_layout¶
- property raw_flags¶
The integer containing the V4L2 control flags
- property read_only¶
- property slider¶
- property update¶
- property write_only¶
ControlValue classes¶
- class qamlib.ControlValue¶
Base class for extended control values
- class qamlib.IntegerControlValue¶
Class that represents a integer control value
- __init__(self: qamlib.IntegerControlValue, value: SupportsInt) None¶
- to_json(self: qamlib.IntegerControlValue) json¶
- property value¶
- class qamlib.StringControlValue¶
Class that represents a string control value
- __init__(self: qamlib.StringControlValue, value: str) None¶
- to_json(self: qamlib.StringControlValue) json¶
- property value¶
- class qamlib.ArrayControlValue¶
Class that represents an array control value
- __init__(self: qamlib.ArrayControlValue, array: numpy.ndarray) None¶
- to_json(self: qamlib.ArrayControlValue) json¶
- property value¶
- class qamlib.TriggerSequenceValue¶
Class that represents the values of a trigger sequence
NOTE: Qtec specific control at the moment. The trigger sequence control is not implemented for all Qtec cameras and/or sensors configurations.
- __init__(self: qamlib.TriggerSequenceValue) None¶
- add_exposure(self: qamlib.TriggerSequenceValue, exposure_time: SupportsInt, flash_time: SupportsInt, frame_delay: SupportsInt, trigger_delay: SupportsInt, flash_time_delay: bool = False) None¶
Add an exposure to the sequence
- clear(self: qamlib.TriggerSequenceValue) None¶
Clear the sequences
- to_json(self: qamlib.TriggerSequenceValue) json¶
- property value¶
The list of sequences
Formats¶
- class qamlib.ImageFormat¶
Class that represents an image format
- to_json(self: qamlib.ImageFormat) json¶
- property description¶
- property flags¶
- property index¶
- property pixelformat¶
- class qamlib.ImageFormatFlags¶
Class that represents the flags for an image format. For more information see here.
- to_json(self: qamlib.ImageFormatFlags) json¶
- property compressed¶
- property continuous_bytestream¶
- property csc_colorspace¶
- property csc_hsv_enc¶
- property csc_quantization¶
- property csc_xfer_func¶
- property csc_ycbcr_enc¶
- property dyn_resolution¶
- property emulated¶
- property enc_cap_frame_interval¶
- class qamlib.SinglePlaneFormat¶
Class that represents a single plane pixel format
- to_json(self: qamlib.SinglePlaneFormat) json¶
- property bytesperline¶
- property colorspace¶
- property field¶
- property flags¶
- property height¶
- property pixelformat¶
- property priv¶
- property quantization¶
- property sizeimage¶
- property width¶
- property xfer_func¶
- class qamlib.PixelFormat¶
Class that represents a V4L2 fourcc code
- get_code(self: qamlib.PixelFormat) int¶
- property big_endian¶
- property fourcc¶
- class qamlib.PixelFormatFlags¶
Class that represents the flags for a pixel format. For more information see here.
- to_json(self: qamlib.PixelFormatFlags) json¶
Framerates¶
- class qamlib.DiscreteFrameRate¶
Represents a list of discrete framerates
- to_json(self: qamlib.DiscreteFrameRate) json¶
- property values¶
FPS values
- class qamlib.ContinuousFrameRate¶
Represents a continous framerate
- to_json(self: qamlib.ContinuousFrameRate) json¶
- property max¶
Maximum FPS
- property min¶
Minimum FPS
- class qamlib.StepwiseFrameRate¶
Inherits from ContinuousFrameRate. Represents a stepwise framerate
- to_json(self: qamlib.StepwiseFrameRate) json¶
- property step¶
FPS step size
Events¶
- class qamlib.BaseEvent¶
Base class for Event types
- property id¶
Control ID associated with the event source. If the event does not have an associated ID, this value is 0.
- property pending¶
Number of pending events
- property sequence¶
Event sequence number
- property timestamp¶
Event timestamp
- property type¶
Type of the event
- class qamlib.ControlEvent¶
Class that represents a control event
- property changes¶
Flags that show what has changed for the control
- property control_type¶
Type of the control
- property default_value¶
Potentially new default_value of the control
- property flags¶
Potentially new flags of the control
- property max¶
Potentially new maximum of the control
- property min¶
Potentially new minimum of the control
- property step¶
Potentially new step of the control
- property value¶
Potentially new value of the control
- class qamlib.EventType¶
Members:
ALL
VSYNC
EOS
CTRL
FRAME_SYNC
SOURCE_CHANGE
MOTION_DET
- ALL = <EventType.ALL: 0>¶
- CTRL = <EventType.CTRL: 3>¶
- EOS = <EventType.EOS: 2>¶
- FRAME_SYNC = <EventType.FRAME_SYNC: 4>¶
- MOTION_DET = <EventType.MOTION_DET: 6>¶
- SOURCE_CHANGE = <EventType.SOURCE_CHANGE: 5>¶
- VSYNC = <EventType.VSYNC: 1>¶
- property name¶
- property value¶
Misc¶
- class qamlib.FrameMetadata¶
This class contains the frame metadata.
- property clock¶
CLOCKID for which kernel clock was used
- property sequence¶
The sequence number of the frame
- property time¶
Kernel time for when the frame was taken
Exceptions¶
- exception qamlib.V4L2Exception¶
- exception qamlib.TimeoutException¶
- exception qamlib.DroppedFrameException¶