SDK Stream Python bindings API
- class metavision_sdk_stream.Camera
Main class for the camera interface.
- static from_file(file_path: os.PathLike, hints: metavision_sdk_stream.FileConfigHints = <metavision_sdk_stream.FileConfigHints object at 0x7f82d608c870>) metavision_sdk_stream.Camera
Initializes a camera instance from a file.
- CameraException
in case of initialization failure. :file_path: Path to the file
- hints
Hints expressing how the file should be read, for more details see FileConfigHints
- return
Camera instance initialized from the input file
- static from_first_available(*args, **kwargs)
Overloaded function.
from_first_available() -> metavision_sdk_stream.Camera
Initializes a camera instance from the first available camera plugged on the system.
Open the first available camera following at first EMBEDDED and then USB order.
Please note that remote cameras will not be opened with this function. To do that, please specify the OnlineSourceType and use the from_source function, or else specify the serial number and use the from_serial function.
Serial numbers and types of available sources can be found with list_online_sources function.
- CameraException
in case of initialization failure.
from_first_available(config: metavision_hal.DeviceConfig) -> metavision_sdk_stream.Camera
Initializes a camera instance from the first available camera plugged on the system.
Open the first available camera following at first EMBEDDED and then USB order.
Please note that remote cameras will not be opened with this function. To do that, please specify the OnlineSourceType and use the from_source function, or else specify the serial number and use the from_serial function.
Serial numbers and types of available sources can be found with list_online_sources function.
- CameraException
in case of initialization failure. :config: Configuration used to open the camera This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- static from_serial(*args, **kwargs)
Overloaded function.
from_serial(serial: str) -> metavision_sdk_stream.Camera
Initializes a camera instance from a ‘serial’ number.
Serial numbers of available sources can be found by with list_online_sources function.
If ‘serial’ is an empty string, the function works as the main constructor.
- CameraException
if the camera with the input serial number has not been found. :serial: Serial number of the camera
- return
Camera instance initialized from the serial number
from_serial(serial: str, config: metavision_hal.DeviceConfig) -> metavision_sdk_stream.Camera
Initializes a camera instance from a ‘serial’ number.
- CameraException
if the camera with the input serial number has not been found. :serial: Serial number of the camera
- config
Configuration used to open the camera
- return
Camera instance initialized from the serial number This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- get_device(self: metavision_sdk_stream.Camera) metavision_hal.Device
Gets corresponding Device in HAL library.
This Device retrieved can then be used to call the different facilities of the camera. for example: camera.get_device()->get_facility<Metavision::I_TriggerIn>()->enable(channel_id) or: camera.get_device()->get_facility<Metavision::I_Monitoring>()->get_temperature())
- return
The Device used internally by the class Camera
- height(self: metavision_sdk_stream.Camera) int
Returns the height of the camera
- load(self: metavision_sdk_stream.Camera, path: os.PathLike) bool
Loads the camera settings from a given file.
- path
The path of the file to load the camera settings from
- return
true on success
- move(self: metavision_sdk_stream.Camera) metavision_sdk_stream.RValueCamera
- save(self: metavision_sdk_stream.Camera, path: os.PathLike) bool
Saves the camera settings to a given file.
- path
The path of the file to save the camera settings to
- return
true on success
- width(self: metavision_sdk_stream.Camera) int
Returns the width of the camera
- class metavision_sdk_stream.FileConfigHints(self: metavision_sdk_stream.FileConfigHints) None
Class represented by a map of string key/value pair, used to control how a file is read by the Camera class.
- note
Some keys can be ignored when not applicable to the file format
Constructor.
By default, if applicable, the file will be read using a maximum memory footprint of 12Mo, with real time playback speed and time shifting enabled
- get(self: metavision_sdk_stream.FileConfigHints, key: str, def: str = '') str
Gets the (typed) value for a named key in the config dictionary if it exists and can be extracted from the corresponding value safely or the provided default value.
- T
type of the value to return as :key: Name of the config key
- def
Default value if the config key is not found
- return
Value of the config
- max_memory(*args, **kwargs)
Overloaded function.
max_memory(self: metavision_sdk_stream.FileConfigHints) -> int
Gets the maximum memory used (if applicable) setting.
- return
Maximum memory used
max_memory(self: metavision_sdk_stream.FileConfigHints, max_memory: int) -> metavision_sdk_stream.FileConfigHints
Named constructor for the max memory setting.
- max_memory
Maximum memory that should be used when reading the file (if applicable)
- return
FileConfigHints& Reference to the modified config
max_memory(self: metavision_sdk_stream.FileConfigHints, max_read_per_op: int) -> metavision_sdk_stream.FileConfigHints
Named constructor for the max read size per read operation.
- max_read_per_op
Maximum size of data read per read operation
- return
FileConfigHints& Reference to the modified config
- max_read_per_op(self: metavision_sdk_stream.FileConfigHints) int
Gets the maximum read size (if applicable) setting.
- return
Maximum read size in bytes
- real_time_playback(*args, **kwargs)
Overloaded function.
real_time_playback(self: metavision_sdk_stream.FileConfigHints) -> bool
Gets the real-time playback status.
- return
true if enabled, false otherwise
real_time_playback(self: metavision_sdk_stream.FileConfigHints, enabled: bool) -> metavision_sdk_stream.FileConfigHints
Named constructor for the real time playback status.
- enabled
true if the setting should be enabled, false otherwise
- return
FileConfigHints& Reference to the modified config
- set(self: metavision_sdk_stream.FileConfigHints, key: str, value: str) None
Sets a value for a named key in the config dictionary This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- time_shift(*args, **kwargs)
Overloaded function.
time_shift(self: metavision_sdk_stream.FileConfigHints) -> bool
Gets the timeshift status.
- return
true if enabled, false otherwise
time_shift(self: metavision_sdk_stream.FileConfigHints, enabled: bool) -> metavision_sdk_stream.FileConfigHints
Named constructor for the time shift status.
- enabled
true if the setting should be enabled, false otherwise
- return
FileConfigHints& Reference to the modified config
- class metavision_sdk_stream.HDF5EventFileWriter(self: metavision_sdk_stream.HDF5EventFileWriter, path: os.PathLike = '', metadata_map: dict[str, str] = {}) None
- add_cd_events(self: metavision_sdk_stream.HDF5EventFileWriter, events: numpy.ndarray[metavision_sdk_base._EventCD_decode]) None
Adds an array of EventCD to write to the file
- Parameters
events – numpy array of EventCD
- add_ext_trigger_events(self: metavision_sdk_stream.HDF5EventFileWriter, events: numpy.ndarray[metavision_sdk_base._EventExtTrigger_decode]) None
Adds an array of EventExtTrigger to write to the file
- Parameters
events – numpy array of EventExtTrigger
- add_metadata(self: metavision_sdk_stream.HDF5EventFileWriter, key: str, value: str) None
Adds metadata to the file.
- key
Metatadata key to be added
- value
Metadata value to be added
- warning
Calling this function after some data has been added may throw an exception in some implementation
- add_metadata_map_from_camera(self: metavision_sdk_stream.HDF5EventFileWriter, camera: metavision_sdk_stream.Camera) None
Adds metadata to the file from a Camera instance.
- camera
Camera instance to build metadata from
- warning
Calling this function after some data has been added may throw an exception in some implementation
- close(self: metavision_sdk_stream.HDF5EventFileWriter) None
Close the writer.
- flush(self: metavision_sdk_stream.HDF5EventFileWriter) None
Try to flush any data not yet written to disk.
The underlying implementation will do its best to flush any data not yet written but it’s not guaranteed that all data will be written after this call (a library or the OS might prevent completely flushing that data at this point). If no more data will be added, closing the writer is the only way to make sure the data is fully written to disk.
- is_open(self: metavision_sdk_stream.HDF5EventFileWriter) bool
Check that the writer is currently opened and ready to write data.
- return
true if the writer is opened and ready, false otherwise
- open(self: metavision_sdk_stream.HDF5EventFileWriter, path: os.PathLike) None
Open the writer with specified path.
- path
Path to the file to write
- class metavision_sdk_stream.RAWEvt2EventFileWriter(self: metavision_sdk_stream.RAWEvt2EventFileWriter, stream_width: int, stream_height: int, path: os.PathLike = PosixPath('.'), enable_trigger_support: bool = False, metadata_map: dict[str, str] = {}, max_events_add_latency: int = 9223372036854775807) None
EventFileWriter specialized class to write events to a RAW EVT2 file.
- Note
This class only supports writing CD and Trigger events
- add_cd_events(self: metavision_sdk_stream.RAWEvt2EventFileWriter, events: numpy.ndarray[metavision_sdk_base._EventCD_decode]) None
Adds an array of EventCD to write to the file
- Parameters
events – numpy array of EventCD
- add_ext_trigger_events(self: metavision_sdk_stream.RAWEvt2EventFileWriter, events: numpy.ndarray[metavision_sdk_base._EventExtTrigger_decode]) None
Adds an array of EventExtTrigger to write to the file
- Parameters
events – numpy array of EventExtTrigger
- add_metadata(self: metavision_sdk_stream.RAWEvt2EventFileWriter, key: str, value: str) None
Adds metadata to the file.
- key
Metatadata key to be added
- value
Metadata value to be added
- warning
Calling this function after some data has been added may throw an exception in some implementation
- close(self: metavision_sdk_stream.RAWEvt2EventFileWriter) None
Close the writer.
- flush(self: metavision_sdk_stream.RAWEvt2EventFileWriter) None
Try to flush any data not yet written to disk.
The underlying implementation will do its best to flush any data not yet written but it’s not guaranteed that all data will be written after this call (a library or the OS might prevent completely flushing that data at this point). If no more data will be added, closing the writer is the only way to make sure the data is fully written to disk.
- is_open(self: metavision_sdk_stream.RAWEvt2EventFileWriter) bool
Check that the writer is currently opened and ready to write data.
- return
true if the writer is opened and ready, false otherwise
- open(self: metavision_sdk_stream.RAWEvt2EventFileWriter, path: os.PathLike) None
Open the writer with specified path.
- path
Path to the file to write
- class metavision_sdk_stream.Slice(self: metavision_sdk_stream.Slice) None
Structure representing a slice of events and triggers.
Default constructor.
- property events
Events in the slice.
- property n_events
Number of CD events in the slice.
- property status
Status indicating how the slice was completed.
- property t
Timestamp of the slice.
- property triggers
Triggers in the slice.
- class metavision_sdk_stream.ReslicingConditionType(self: metavision_sdk_stream.ReslicingConditionType, value: int) None
Members:
IDENTITY
N_EVENTS
N_US
MIXED
- class metavision_sdk_stream.ReslicingConditionStatus(self: metavision_sdk_stream.ReslicingConditionStatus, value: int) None
Members:
NOT_MET
MET_AUTOMATIC
MET_N_EVENTS
MET_N_US
- class metavision_sdk_stream.SliceCondition(self: metavision_sdk_stream.SliceCondition) None
- is_tracking_duration(self: metavision_sdk_stream.SliceCondition) bool
- is_tracking_events_count(self: metavision_sdk_stream.SliceCondition) bool
- static make_identity() metavision_sdk_stream.SliceCondition
- static make_mixed(delta_ts: int, delta_n_events: int) metavision_sdk_stream.SliceCondition
- static make_n_events(delta_n_events: int) metavision_sdk_stream.SliceCondition
- static make_n_us(delta_ts: int) metavision_sdk_stream.SliceCondition
- class metavision_sdk_stream.CameraStreamSlicer(self: metavision_sdk_stream.CameraStreamSlicer, rvalue_camera: metavision_sdk_stream.RValueCamera, slice_condition: metavision_sdk_stream.SliceCondition = <metavision_sdk_stream.SliceCondition object at 0x7f82d5ccefb0>, max_queue_size: int = 5) None
Class that slices a stream of events and triggers according to a given condition.
Internally, a concurrent queue is used to store the slices produced by the background threads of the Camera class (i.e. in the callbacks). The size of this concurrent queue can be limited to prevent the background threads from producing too many slices (i.e. especially in offline mode) and consuming too much memory.
- begin(self: metavision_sdk_stream.CameraStreamSlicer) Metavision::SliceIteratorT<Metavision::Slice>
Starts the camera stream and returns an iterator to the first slice.
- camera(self: metavision_sdk_stream.CameraStreamSlicer) metavision_sdk_stream.Camera
Returns the underlying camera instance.
- class metavision_sdk_stream.SyncedSlice(self: metavision_sdk_stream.SyncedSlice) None
A slice of synchronized events from a master and slave cameras.
Default constructor.
- property master_events
Events in the master slice.
- property master_triggers
Triggers in the master slice.
- property n_events
Number of events in the master slice.
- property slave_events
Events in the slave slices.
- property status
Status indicating how the slice was completed.
- property t
Timestamp of the slice.
- class metavision_sdk_stream.SyncedCameraStreamsSlicer(self: metavision_sdk_stream.SyncedCameraStreamsSlicer, camera: metavision_sdk_stream.RValueCamera, Cameras: list, slice_condition: metavision_sdk_stream.SliceCondition = <metavision_sdk_stream.SliceCondition object at 0x7f82d5f4fdb0>, max_queue_size: int = 5) None
Class for slicing event streams from master and slave cameras based on a condition.
The slicing condition is applied to the master stream and the end of the slave streams are determined accordingly. Internally, a concurrent queue is used to store the slices produced by the background threads of the master Camera class (i.e. in the callbacks). The size of this concurrent queue can be limited to prevent the background threads from producing too many slices (i.e. especially in offline mode) and consuming too much memory.
- begin(self: metavision_sdk_stream.SyncedCameraStreamsSlicer) Metavision::SliceIteratorT<Metavision::SyncedSlice>
Starts the camera streams and returns an iterator to the first slice.
- master(self: metavision_sdk_stream.SyncedCameraStreamsSlicer) metavision_sdk_stream.Camera
Returns the underlying master camera instance.
- slave(self: metavision_sdk_stream.SyncedCameraStreamsSlicer, i: int) metavision_sdk_stream.Camera
Returns the underlying slave camera instance.
- slaves_count(self: metavision_sdk_stream.SyncedCameraStreamsSlicer) int
Returns the number of slave cameras.
- class metavision_sdk_stream.SyncedCameraSystemBuilder(self: metavision_sdk_stream.SyncedCameraSystemBuilder) None
Builder class to create a synced camera system.
Depending on the provided parameters, the builder will create a synced camera system with live cameras or with files.
- add_live_camera_parameters(self: metavision_sdk_stream.SyncedCameraSystemBuilder, serial_number: str, device_config: metavision_hal.DeviceConfig = <metavision_hal.DeviceConfig object at 0x7f82d5f50e30>, settings_file_path: Optional[os.PathLike] = None) None
Adds live camera parameters to the builder.
The first provided parameters will be used as the master camera parameters :parameters: Live camera parameters
- return
Reference to the builder
- add_record_path(self: metavision_sdk_stream.SyncedCameraSystemBuilder, record_path: os.PathLike) metavision_sdk_stream.SyncedCameraSystemBuilder
Adds a path to a record file.
The first provided path will be used as the master camera file path :record_path: Path to a record file
- return
Reference to the builder
- build(self: metavision_sdk_stream.SyncedCameraSystemBuilder) tuple[metavision_sdk_stream.Camera, list[metavision_sdk_stream.Camera]]
Builds the synced camera system.
- return
Tuple containing the master camera and the slave cameras :std::runtime_error: in case: - No camera parameters provided - Mixing live and offline parameters - Less than two live cameras provided - Less than two records provided
- set_file_config_hints(self: metavision_sdk_stream.SyncedCameraSystemBuilder, file_config_hints: metavision_sdk_stream.FileConfigHints) metavision_sdk_stream.SyncedCameraSystemBuilder
Sets the file config hints.
The hints will be used for all the records :file_config_hints: File config hints
- return
Reference to the builder
- set_record(self: metavision_sdk_stream.SyncedCameraSystemBuilder, record: bool) metavision_sdk_stream.SyncedCameraSystemBuilder
Sets whether the system should record the live events or not.
- record
True to record the events, false otherwise
- return
Reference to the builder
- set_record_dir(self: metavision_sdk_stream.SyncedCameraSystemBuilder, record_dir: os.PathLike) metavision_sdk_stream.SyncedCameraSystemBuilder
Sets the directory where the events will be recorded.
Setting this option will automatically enable recording :record_dir: Directory where the events will be recorded
- return
Reference to the builder
- class metavision_sdk_stream.SyncedCameraSystemFactory(self: metavision_sdk_stream.SyncedCameraSystemFactory) None
- class LiveCameraParameters(self: metavision_sdk_stream.SyncedCameraSystemFactory.LiveCameraParameters) None
Parameters to create a live camera.
- property device_config
Device configuration.
- property serial_number
Serial number of the camera.
- property settings_file_path
Optional path to a camera settings file.
- class LiveParameters(self: metavision_sdk_stream.SyncedCameraSystemFactory.LiveParameters) None
Parameters to create a synced live camera system.
- property master_parameters
Parameters for the master camera.
- property record
True to record the events, false otherwise.
- property record_dir
Optional directory where the events will be recorded.
- property slave_parameters
Parameters for the slave cameras.
- class OfflineParameters(self: metavision_sdk_stream.SyncedCameraSystemFactory.OfflineParameters) None
Parameters to create a synced offline camera system.
- property file_config_hints
Hints to configure the file reading.
- property master_file_path
Path to the master record.
- property slave_file_paths
Paths to the slave records.
- static build(*args, **kwargs)
Overloaded function.
build(parameters: Metavision::SyncedCameraSystemFactory::LiveParameters) -> tuple[metavision_sdk_stream.Camera, list[metavision_sdk_stream.Camera]]
Builds a synced camera system with live cameras.
- parameters
Parameters to create the synced camera system
- return
A tuple with the master camera and the slave cameras
build(parameters: Metavision::SyncedCameraSystemFactory::OfflineParameters) -> tuple[metavision_sdk_stream.Camera, list[metavision_sdk_stream.Camera]]
Builds a synced camera system with offline cameras.
- parameters
Parameters to create the synced camera system
- return
A tuple with the master camera and the slave cameras