SDK Driver Camera Class
-
class
Metavision
::
Camera
Main class for the camera interface.
Public Functions
-
Camera
() Constructor.
Creates an uninitialized camera instance.
-
Camera
(Camera &camera) = delete Copy constructor.
A Camera object can not be copy-constructed, but it can be move-constructed.
See also
-
Camera
(Camera &&camera) Move constructor.
A Camera can not be copied, but it can be move-constructed from another instance.
-
Camera &
operator=
(Camera &camera) = delete Copy assignment.
A Camera object can not be copy-assigned, but it can be move-assigned.
See also
Camera & operator=(Camera &&camera);
-
Camera &
operator=
(Camera &&camera) Move assignment.
A Camera can not be copied, but it can be move-assigned from another instance.
-
~Camera
() Destructor.
-
RawData &
raw_data
() Gets class to handle RAW data from the camera.
- Throws
CameraException – if the camera has not been initialized.
-
CD &
cd
() Gets class to handle CD events.
- Throws
CameraException – if the camera has not been initialized.
-
ExtTrigger &
ext_trigger
() Gets class to handle External Triggers events.
- Throws
CameraException – if the camera has not been initialized.
-
TriggerOut &
trigger_out
() Gets class to handle trigger out signal.
- Throws
CameraException – if the camera has not been initialized.
CameraException – in case of failure (for example if camera runs from an offline source).
-
Roi &
roi
() Gets class to handle Roi on the sensor.
- Throws
CameraException – in case of failure (for instance if the camera is not initialized or the camera is running from an offline source).
-
AntiFlickerModule &
antiflicker_module
() Gets class to handle AFK on the hardware side.
- Throws
CameraException – in case of failure (for instance if the camera is not initialized or the camera is running from an offline source).
-
ErcModule &
erc_module
() Gets class to handle Event Rater Controller on the hardware side.
- Throws
CameraException – in case of failure (for instance if the camera is not initialized or the camera is running from an offline source).
-
NoiseFilterModule &
noise_filter_module
() Gets class to handle STC or TRAIL Noise Filter Module on the hardware side.
- Throws
CameraException – in case of failure (for instance if the camera is not initialized or the camera is running from an offline source).
-
CallbackId
add_runtime_error_callback
(RuntimeErrorCallback error_callback) Registers a callback that will be called when a runtime error occurs.
When a camera runtime error occurs, the camera thread is left and events are no longer sent. You are notified by this callback whenever this happens.
See also
RuntimeErrorCallback
Warning
It is forbidden to call the Camera::stop from a runtime error callback.
- Throws
CameraException – if the camera has not been initialized.
- Parameters
error_callback – The error callback to call
- Returns
ID of the added callback
-
bool
remove_runtime_error_callback
(CallbackId callback_id) Removes a previously registered callback.
See also
See also
- Parameters
callback_id – Callback ID
- Returns
true if the callback has been unregistered correctly, false otherwise.
-
CallbackId
add_status_change_callback
(StatusChangeCallback status_change_callback) Registers a callback that will be called when the camera status changes.
The callback will be called with the new status of the Camera as a parameter, when the camera is started or stopped (by a call to Camera::stop or when no more events are available in a recording).
See also
StatusChangeCallback
Warning
It is forbidden to call the Camera::stop from the status callback.
- Parameters
status_change_callback – The status change callback to call
- Returns
ID of the added callback
-
bool
remove_status_change_callback
(CallbackId callback_id) Removes a previously registered callback.
- Parameters
callback_id – Callback ID
- Returns
true if the callback has been unregistered correctly, false otherwise.
-
Biases &
biases
() Gets class to handle camera biases.
- Throws
CameraException – in case of failure (for example if camera runs from an offline source).
-
OfflineStreamingControl &
offline_streaming_control
() Gets class to control offline streaming.
- Throws
CameraException – if the camera has not been initialized or if the feature is not available.
-
const Geometry &
geometry
() const Gets the device’s geometry.
- Throws
CameraException – if the camera has not been initialized.
-
const CameraGeneration &
generation
() const Gets the device’s generation.
- Throws
CameraException – if the camera has not been initialized.
-
bool
start
() Starts the camera from the given input source.
It will start polling events from the source and calling specified events callbacks.
It has no effect if the start function has been already called and not the
stop function.See also
See also
- Throws
CameraException – if the camera has not been initialized.
- Returns
true if the camera started successfully, false otherwise. Also returns false, if the camera is already started.
-
bool
is_running
() Checks if the camera is running or there are data remaining from an offline source.
If the source is online, it always returns true unless the stop
function has been called.
If the input is offline (from a file), it returns false whenever no data are remaining in the input file.
- Returns
true if the camera is running or there are data remaining from an offline source, false otherwise.
-
bool
stop
() Stops polling events from the camera or from the file.
Stops ongoing streaming.
- Throws
CameraException – if the camera has not been initialized.
- Returns
true if the camera instance has been stopped successfully, false otherwise. If the camera was not running, this function returns false.
-
void
start_recording
(const std::string &rawfile_path) Records data from camera to a file with .raw extension.
The call to this function stops ongoing recording.
The function creates a new file at the given path or overwrites the already existing file.
In case of an offline input source, the function can be used to split the RAW file. In case of not having rights to write at the provided path, the function will not record anything.- Throws
CameraException – if the camera has not been initialized.
- Parameters
rawfile_path – Path to the RAW file used for data recording.
-
void
stop_recording
() Stops an ongoing recording.
- Throws
CameraException – if the camera has not been initialized.
-
const CameraConfiguration &
get_camera_configuration
() Returns CameraConfiguration of the camera that holds the camera properties (dimensions, camera biases, …)
Read-only structure.
See also
-
timestamp
get_last_timestamp
() const Gets the last decoded timestamp.
Warning
If no event decoding callback has been set, this functions returns -1
- Returns
timestamp Last decoded timestamp
-
Device &
get_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())
- Returns
The Device used internally by the class Camera
-
Private &
get_pimpl
() For internal use.
-
Camera
(Private*) For internal use.
Public Static Functions
-
static AvailableSourcesList
list_online_sources
() Lists available sources for the online mode.
- Returns
AvailableSourcesList structure containing available cameras (plugged on the system) along with their serial numbers.
-
static Camera
from_first_available
() 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 Camera::from_source function, or else specify the serial number and use the Camera::from_serialfunction.
Serial numbers and types of available sources can be found with
Camera::list_online_sources function.- Throws
CameraException – in case of initialization failure.
-
static Camera
from_source
(OnlineSourceType input_source_type, uint32_t source_index = 0) Initializes a camera instance from an OnlineSourceType and a source index.
Open the source_index camera of online input_source_type if available from list_online_sources
.
By default, it opens the first available camera listed by
list_online_sourcesof type input_source_type.
Serial numbers and types of available sources can be found with
Camera::list_online_sources function.- Throws
CameraException – if the camera corresponding to the input source type and the source index has not been found.
- Parameters
input_source_type – OnlineSourceType
source_index – Index of the source in the list of available online sources
- Returns
Camera instance initialized from the source
-
static Camera
from_serial
(const std::string &serial) Initializes a camera instance from a ‘serial’ number.
Serial numbers of available sources can be found by with Camera::list_online_sources
function.
If ‘serial’ is an empty string, the function works as the main constructor.
- Throws
CameraException – if the camera with the input serial number has not been found.
- Parameters
serial – Serial number of the camera
- Returns
Camera instance initialized from the serial number
-
static Camera
from_file
(const std::string &rawfile, bool realtime_playback_speed = true, const RawFileConfig &file_config = RawFileConfig()) Initializes a camera instance from a RAW file.
Note
Since 2.1.0, the
realtime_playback_speed
is only taken into account if at least one event callback is registered (CD or ExtTrigger), it will have no effect if only a RawData callback is registered.- Throws
CameraException – in case of initialization failure.
- Parameters
rawfile – Path to the RAW file
realtime_playback_speed – If true, the RAW file will be read at the same speed as was sent by the camera when the file was recorded, and the events will be available after the same amount of time it took for them to be received when recording the RAW file. If false, the file will be read as fast as possible and the events will be available as soon as possible as well. The max_event_lifespan will only be taken into account when reproducing the camera behavior.
file_config – Configuration describing how to read the file (see RawFileConfig)
- Returns
Camera instance initialized from the input RAW file
- Returns
Camera instance initialized from the input RAW file
-
static Camera
from_file
(const std::string &rawfile, bool realtime_playback_speed, const Future::RawFileConfig &file_config) Initializes a camera instance from a RAW file.
Note
Since 2.1.0, the
realtime_playback_speed
is only taken into account if at least one event callback is registered (CD or ExtTrigger), it will have no effect if only a RawData callback is registered.- Throws
CameraException – in case of initialization failure.
- Parameters
rawfile – Path to the RAW file
realtime_playback_speed – If true, the RAW file will be read at the same speed as was sent by the camera when the file was recorded, and the events will be available after the same amount of time it took for them to be received when recording the RAW file. If false, the file will be read as fast as possible and the events will be available as soon as possible as well. The max_event_lifespan will only be taken into account when reproducing the camera behavior.
file_config – Configuration describing how to read the file (see Future::RawFileConfig)
- Returns
Camera instance initialized from the input RAW file
-
-
enum class
Metavision
::
OnlineSourceType
: short Online camera type input sources: USB, embedded, remote.
Values:
-
enumerator
EMBEDDED
Data from an embedded event-based camera.
-
enumerator
USB
Data from an USB event-based camera.
-
enumerator
REMOTE
Data from a remote event-based camera.
-
enumerator
-
enum class
Metavision
::
CameraStatus
: short Values:
-
enumerator
STARTED
Camera is started, see Camera::start and Camera::is_running.
-
enumerator
STOPPED
Camera is stopped, see Camera::stop and Camera::is_running.
-
enumerator
-
struct
Metavision
::
CameraConfiguration
Struct with the current camera configuration.
Public Members
-
std::string
serial_number
= "" Serial number of the camera.
In case of an online source, it is the serial number of the current online source.
In case of an offline source, it is the serial number of the online source used to record the data.
-
std::string