InitParametersOne Class Reference

Class containing the options used to initialize the sl.CameraOne object. More...

Functions

RESOLUTION camera_resolution (self)
 Default constructor. More...
 
int camera_fps (self)
 Requested camera frame rate. More...
 
bool svo_real_time_mode (self)
 Defines if sl.Camera object return the frame in real time mode. More...
 
UNIT coordinate_units (self)
 Unit of spatial data (depth, point cloud, tracking, mesh, etc.) for retrieval. More...
 
COORDINATE_SYSTEM coordinate_system (self)
 sl.COORDINATE_SYSTEM to be used as reference for positional tracking, mesh, point clouds, etc. More...
 
int sdk_verbose (self)
 Enable the ZED SDK verbose mode. More...
 
str sdk_verbose_log_file (self)
 File path to store the ZED SDK logs (if sdk_verbose is enabled). More...
 
str optional_settings_path (self)
 Optional path where the ZED SDK has to search for the settings file (SN<XXXX>.conf file). More...
 
float open_timeout_sec (self)
 Define a timeout in seconds after which an error is reported if the sl.Camera.open() method fails. More...
 
bool async_grab_camera_recovery (self)
 Define the behavior of the automatic camera recovery during sl.Camera.grab() method call. More...
 
None set_from_camera_id (self, uint id, BUS_TYPE bus_type=BUS_TYPE.AUTO)
 Defines the input source with a camera id to initialize and open an sl.Camera object from. More...
 
None set_from_serial_number (self, uint serial_number, BUS_TYPE bus_type=BUS_TYPE.AUTO)
 Defines the input source with a serial number to initialize and open an sl.Camera object from. More...
 
None set_from_svo_file (self, str svo_input_filename)
 Defines the input source with an SVO file to initialize and open an sl.Camera object from. More...
 
None set_from_stream (self, str sender_ip, port=30000)
 Defines the input source from a stream to initialize and open an sl.Camera object from. More...
 
None close (self)
 Close an opened camera. More...
 
ERROR_CODE open (self, InitParametersOne py_init=InitParametersOne())
 Opens the ZED camera from the provided InitParametersOne. More...
 
bool is_opened (self)
 Reports if the camera has been successfully opened. More...
 
ERROR_CODE grab (self)
 This method will grab the latest images from the camera, rectify them, and compute the measurements based on the RuntimeParameters provided (depth, point cloud, tracking, etc.) More...
 
ERROR_CODE retrieve_image (self, Mat py_mat, view=VIEW.LEFT, type=MEM.CPU, resolution=Resolution(0, 0))
 Retrieves images from the camera (or SVO file). More...
 
None set_svo_position (self, int frame_number)
 Sets the playback cursor to the desired frame number in the SVO file. More...
 
int get_svo_position (self)
 Returns the current playback position in the SVO file. More...
 
int get_svo_number_of_frames (self)
 Returns the number of frames in the SVO file. More...
 
ERROR_CODE set_camera_settings_range (self, VIDEO_SETTINGS settings, value_min=-1, value_max=-1)
 Sets the value of the requested camera setting that supports two values (min/max). More...
 
ERROR_CODE set_camera_settings_roi (self, VIDEO_SETTINGS settings, Rect roi, reset=False)
 Overloaded method for VIDEO_SETTINGS.AEC_AGC_ROI which takes a Rect as parameter. More...
 
(ERROR_CODE, int) get_camera_settings (self, VIDEO_SETTINGS setting)
 Returns the current value of the requested camera setting (gain, brightness, hue, exposure, etc.). More...
 
(ERROR_CODE, int, int) get_camera_settings_range (self, VIDEO_SETTINGS setting)
 Returns the values of the requested settings for VIDEO_SETTINGS that supports two values (min/max). More...
 
ERROR_CODE get_camera_settings_roi (self, VIDEO_SETTINGS setting, Rect roi)
 Returns the current value of the currently used ROI for the camera setting AEC_AGC_ROI. More...
 
bool is_camera_setting_supported (self, VIDEO_SETTINGS setting)
 Returns if the video setting is supported by the camera or not. More...
 
float get_current_fps (self)
 Returns the current framerate at which the grab() method is successfully called. More...
 
Timestamp get_timestamp (self, TIME_REFERENCE time_reference)
 Returns the timestamp in the requested TIME_REFERENCE. More...
 
int get_frame_dropped_count (self)
 Returns the number of frames dropped since grab() was called for the first time. More...
 
InitParametersOne get_init_parameters (self)
 Returns the InitParametersOne associated with the Camera object. More...
 
StreamingParameters get_streaming_parameters (self)
 Returns the StreamingParameters used. More...
 
ERROR_CODE get_sensors_data (self, SensorsData py_sensors_data, time_reference=TIME_REFERENCE.CURRENT)
 Retrieves the SensorsData (IMU, magnetometer, barometer) at a specific time reference. More...
 
ERROR_CODE enable_streaming (self, streaming_parameters=StreamingParameters())
 Creates a streaming pipeline. More...
 
None disable_streaming (self)
 Disables the streaming initiated by enable_streaming(). More...
 
bool is_streaming_enabled (self)
 Tells if the streaming is running. More...
 
ERROR_CODE enable_recording (self, RecordingParameters record)
 Creates an SVO file to be filled by enable_recording() and disable_recording(). More...
 
None disable_recording (self)
 Disables the recording initiated by enable_recording() and closes the generated file. More...
 
RecordingStatus get_recording_status (self)
 Get the recording information. More...
 
None pause_recording (self, value=True)
 Pauses or resumes the recording. More...
 

Static Functions

list[DevicePropertiesget_device_list ()
 List all the connected devices with their associated information. More...
 
ERROR_CODE reboot (int sn, bool full_reboot=True)
 Performs a hardware reset of the ZED 2 and the ZED 2i. More...
 
ERROR_CODE reboot_from_input (INPUT_TYPE input_type)
 Performs a hardware reset of all devices matching the InputType. More...
 

Detailed Description

Class containing the options used to initialize the sl.CameraOne object.

This class allows you to select multiple parameters for the sl.Camera such as the selected camera, resolution, depth mode, coordinate system, and units of measurement.
Once filled with the desired options, it should be passed to the sl.Camera.open() method.

import pyzed.sl as sl
def main() :
zed = sl.CameraOne() # Create a ZED camera object
init_params = sl.InitParametersOne() # Set initial parameters
init_params.sdk_verbose = 0 # Disable verbose mode
# Use the camera in LIVE mode
init_params.camera_resolution = sl.RESOLUTION.HD1080 # Use HD1080 video mode
init_params.camera_fps = 30 # Set fps at 30
# Or use the camera in SVO (offline) mode
#init_params.set_from_svo_file("xxxx.svo")
# Or use the camera in STREAM mode
#init_params.set_from_stream("192.168.1.12", 30000)
# Other parameters are left to their default values
# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
exit(-1)
# Close the camera
zed.close()
return 0
if __name__ == "__main__" :
main()
Definition: sl.pyx:1

With its default values, it opens the camera in live mode at sl.RESOLUTION.HD720
You can customize it to fit your application.

Note
The parameters can also be saved and reloaded using its save() and load() methods.

Functions

◆ camera_resolution()

RESOLUTION camera_resolution (   self)

Default constructor.

All the parameters are set to their default and optimized values.

Parameters
camera_resolution: Chosen camera_resolution
camera_fps: Chosen camera_fps
svo_real_time_mode: Activates svo_real_time_mode
coordinate_units: Chosen coordinate_units
coordinate_system: Chosen coordinate_system
sdk_verbose: Sets sdk_verbose
sdk_verbose_log_file: Chosen sdk_verbose_log_file
input_t: Chosen input_t (InputType )
optional_settings_path: Chosen optional_settings_path
sensors_required: Activates sensors_required
optional_opencv_calibration_file: Sets optional_opencv_calibration_file
open_timeout_sec: Sets open_timeout_sec
async_grab_camera_recovery: Sets async_grab_camera_recovery
grab_compute_capping_fps: Sets grab_compute_capping_fps
enable_image_validity_check: Sets enable_image_validity_check

Desired camera resolution.

Note
Small resolutions offer higher framerate and lower computation time.
In most situations, sl.RESOLUTION.HD720 at 60 FPS is the best balance between image quality and framerate.

Default:

Note
Available resolutions are listed here: sl.RESOLUTION.

◆ camera_fps()

int camera_fps (   self)

Requested camera frame rate.

If set to 0, the highest FPS of the specified camera_resolution will be used.
Default: 0

See sl.RESOLUTION for a list of supported frame rates.

Note
If the requested camera_fps is unsupported, the closest available FPS will be used.

Referenced by CameraConfiguration.fps().

◆ svo_real_time_mode()

bool svo_real_time_mode (   self)

Defines if sl.Camera object return the frame in real time mode.

When playing back an SVO file, each call to sl.Camera.grab() will extract a new frame and use it.
However, it ignores the real capture rate of the images saved in the SVO file.
Enabling this parameter will bring the SDK closer to a real simulation when playing back a file by using the images' timestamps.
Default: False

Note
sl.Camera.grab() will return an error when trying to play too fast, and frames will be dropped when playing too slowly.

◆ coordinate_units()

UNIT coordinate_units (   self)

Unit of spatial data (depth, point cloud, tracking, mesh, etc.) for retrieval.

Default: sl.UNIT.MILLIMETER

◆ coordinate_system()

COORDINATE_SYSTEM coordinate_system (   self)

sl.COORDINATE_SYSTEM to be used as reference for positional tracking, mesh, point clouds, etc.

This parameter allows you to select the sl.COORDINATE_SYSTEM used by the sl.Camera object to return its measures.
This defines the order and the direction of the axis of the coordinate system.
Default: sl.COORDINATE_SYSTEM.IMAGE

◆ sdk_verbose()

int sdk_verbose (   self)

Enable the ZED SDK verbose mode.

This parameter allows you to enable the verbosity of the ZED SDK to get a variety of runtime information in the console.
When developing an application, enabling verbose (sdk_verbose >= 1) mode can help you understand the current ZED SDK behavior.
However, this might not be desirable in a shipped version.
Default: 0 (no verbose message)

Note
The verbose messages can also be exported into a log file.
See sdk_verbose_log_file for more.

◆ sdk_verbose_log_file()

str sdk_verbose_log_file (   self)

File path to store the ZED SDK logs (if sdk_verbose is enabled).

The file will be created if it does not exist.
Default: ""

Note
Setting this parameter to any value will redirect all standard output print calls of the entire program.
This means that your own standard output print calls will be redirected to the log file.
Warning
The log file won't be cleared after successive executions of the application.
This means that it can grow indefinitely if not cleared.

◆ optional_settings_path()

str optional_settings_path (   self)

Optional path where the ZED SDK has to search for the settings file (SN<XXXX>.conf file).

This file contains the calibration information of the camera.
Default: ""

Note
The settings file will be searched in the default directory:
  • Linux: /usr/local/zed/settings/
  • Windows: C:/ProgramData/stereolabs/settings
If a path is specified and no file has been found, the ZED SDK will search the settings file in the default directory.
An automatic download of the settings file (through ZED Explorer or the installer) will still download the files on the default path.
init_params = sl.InitParametersOne() # Set initial parameters
home = "/path/to/home"
path = home + "/Documents/settings/" # assuming /path/to/home/Documents/settings/SNXXXX.conf exists. Otherwise, it will be searched in /usr/local/zed/settings/
init_params.optional_settings_path = path

◆ open_timeout_sec()

float open_timeout_sec (   self)

Define a timeout in seconds after which an error is reported if the sl.Camera.open() method fails.

Set to '-1' to try to open the camera endlessly without returning error in case of failure.
Set to '0' to return error in case of failure at the first attempt.
Default: 5.0

Note
This parameter only impacts the LIVE mode.

◆ async_grab_camera_recovery()

bool async_grab_camera_recovery (   self)

Define the behavior of the automatic camera recovery during sl.Camera.grab() method call.

When async is enabled and there's an issue with the communication with the sl.Camera object, sl.Camera.grab() will exit after a short period and return the sl.ERROR_CODE.CAMERA_REBOOTING warning.
The recovery will run in the background until the correct communication is restored.
When async_grab_camera_recovery is false, the sl.Camera.grab() method is blocking and will return only once the camera communication is restored or the timeout is reached.
Default: False

◆ set_from_camera_id()

None set_from_camera_id (   self,
uint  id,
BUS_TYPE   bus_type = BUS_TYPE.AUTO 
)

Defines the input source with a camera id to initialize and open an sl.Camera object from.

Parameters
id: Id of the desired camera to open.
bus_type: sl.BUS_TYPE of the desired camera to open.

◆ set_from_serial_number()

None set_from_serial_number (   self,
uint  serial_number,
BUS_TYPE   bus_type = BUS_TYPE.AUTO 
)

Defines the input source with a serial number to initialize and open an sl.Camera object from.

Parameters
serial_number: Serial number of the desired camera to open.
bus_type: sl.BUS_TYPE of the desired camera to open.

◆ set_from_svo_file()

None set_from_svo_file (   self,
str  svo_input_filename 
)

Defines the input source with an SVO file to initialize and open an sl.Camera object from.

Parameters
svo_input_filename: Path to the desired SVO file to open.

◆ set_from_stream()

None set_from_stream (   self,
str  sender_ip,
  port = 30000 
)

Defines the input source from a stream to initialize and open an sl.Camera object from.

Parameters
sender_ip: IP address of the streaming sender.
port: Port on which to listen. Default: 30000

◆ close()

None close (   self)

Close an opened camera.

If open() has been called, this method will close the connection to the camera (or the SVO file) and free the corresponding memory.

If open() wasn't called or failed, this method won't have any effect.

Note
If an asynchronous task is running within the Camera object, like save_area_map(), this method will wait for its completion.
To apply a new InitParametersOne, you will need to close the camera first and then open it again with the new InitParameters values.
Warning
Therefore you need to make sure to delete your GPU sl.Mat objects before the context is destroyed.

◆ open()

ERROR_CODE open (   self,
InitParametersOne   py_init = InitParametersOne() 
)

Opens the ZED camera from the provided InitParametersOne.

The method will also check the hardware requirements and run a self-calibration.

Parameters
py_init: A structure containing all the initial parameters. Default: a preset of InitParametersOne.
Returns
An error code giving information about the internal process. If ERROR_CODE.SUCCESS is returned, the camera is ready to use. Every other code indicates an error and the program should be stopped.

Here is the proper way to call this function:

zed = sl.CameraOne() # Create a ZED camera object
init_params = sl.InitParametersOne() # Set configuration parameters
init_params.camera_resolution = sl.RESOLUTION.HD720 # Use HD720 video mode
init_params.camera_fps = 60 # Set fps at 60
# Open the camera
err = zed.open(init_params)
if (err != sl.ERROR_CODE.SUCCESS) :
print(repr(err)) # Display the error
exit(-1)
Note
If you are having issues opening a camera, the diagnostic tool provided in the SDK can help you identify to problems.
  • Windows: C:\Program Files (x86)\ZED SDK\tools\ZED Diagnostic.exe
  • Linux: /usr/local/zed/tools/ZED Diagnostic
If this method is called on an already opened camera, close() will be called.

◆ is_opened()

bool is_opened (   self)

Reports if the camera has been successfully opened.

It has the same behavior as checking if open() returns ERROR_CODE.SUCCESS.

Returns
True if the ZED camera is already setup, otherwise false.

◆ grab()

ERROR_CODE grab (   self)

This method will grab the latest images from the camera, rectify them, and compute the measurements based on the RuntimeParameters provided (depth, point cloud, tracking, etc.)

As measures are created in this method, its execution can last a few milliseconds, depending on your parameters and your hardware.
The exact duration will mostly depend on the following parameters:

This method is meant to be called frequently in the main loop of your application.

Note
Since ZED SDK 3.0, this method is blocking. It means that grab() will wait until a new frame is detected and available.
If no new frames is available until timeout is reached, grab() will return ERROR_CODE.CAMERA_NOT_DETECTED since the camera has probably been disconnected.
Returns
ERROR_CODE.SUCCESS means that no problem was encountered.
Note
Returned errors can be displayed using str().
image = sl.Mat()
while True:
# Grab an image
if zed.grab() == sl.ERROR_CODE.SUCCESS: # A new image is available if grab() returns SUCCESS
zed.retrieve_image(image) # Get the left image
# Use the image for your application

◆ retrieve_image()

ERROR_CODE retrieve_image (   self,
Mat  py_mat,
  view = VIEW.LEFT,
  type = MEM.CPU,
  resolution = Resolution(0,0) 
)

Retrieves images from the camera (or SVO file).

Multiple images are available along with a view of various measures for display purposes.
Available images and views are listed here.
As an example, VIEW.DEPTH can be used to get a gray-scale version of the depth map, but the actual depth values can be retrieved using retrieve_measure() .

Pixels
Most VIEW modes output image with 4 channels as BGRA (Blue, Green, Red, Alpha), for more information see enum VIEW

Memory
By default, images are copied from GPU memory to CPU memory (RAM) when this function is called.
If your application can use GPU images, using the type parameter can increase performance by avoiding this copy.
If the provided sl.Mat object is already allocated and matches the requested image format, memory won't be re-allocated.

Image size
By default, images are returned in the resolution provided by get_camera_information().camera_configuration.resolution.
However, you can request custom resolutions. For example, requesting a smaller image can help you speed up your application.

Warning
A sl.Mat resolution higher than the camera resolution cannot be requested.
Parameters
py_mat[out]: The sl.Mat to store the image.
view[in]: Defines the image you want (see VIEW). Default: VIEW.LEFT.
type[in]: Defines on which memory the image should be allocated. Default: MEM.CPU (you cannot change this default value).
resolution[in]: If specified, defines the Resolution of the output sl.Mat. If set to Resolution(0,0), the camera resolution will be taken. Default: (0,0).
Returns
ERROR_CODE.SUCCESS if the method succeeded.
ERROR_CODE.INVALID_FUNCTION_PARAMETERS if the view mode requires a module not enabled (VIEW.DEPTH with DEPTH_MODE.NONE for example).
ERROR_CODE.FAILURE if another error occurred.
Note
As this method retrieves the images grabbed by the grab() method, it should be called afterward.
# create sl.Mat objects to store the images
left_image = sl.Mat()
while True:
# Grab an image
if zed.grab() == sl.ERROR_CODE.SUCCESS: # A new image is available if grab() returns SUCCESS
zed.retrieve_image(left_image, sl.VIEW.LEFT) # Get the rectified left image
# Display the center pixel colors
err, left_center = left_image.get_value(left_image.get_width() / 2, left_image.get_height() / 2)
if err == sl.ERROR_CODE.SUCCESS:
print("left_image center pixel R:", int(left_center[0]), " G:", int(left_center[1]), " B:", int(left_center[2]))
else:
print("error:", err)

◆ set_svo_position()

None set_svo_position (   self,
int  frame_number 
)

Sets the playback cursor to the desired frame number in the SVO file.

This method allows you to move around within a played-back SVO file. After calling, the next call to grab() will read the provided frame number.

Parameters
frame_number: The number of the desired frame to be decoded.
Note
The method works only if the camera is open in SVO playback mode.
import pyzed.sl as sl
def main():
# Create a ZED camera object
zed = sl.CameraOne()
# Set configuration parameters
init_params = sl.InitParametersOne()
init_params.set_from_svo_file("path/to/my/file.svo")
# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS:
print(repr(err))
exit(-1)
# Loop between frames 0 and 50
left_image = sl.Mat()
while zed.get_svo_position() < zed.get_svo_number_of_frames() - 1:
print("Current frame: ", zed.get_svo_position())
# Loop if we reached frame 50
if zed.get_svo_position() == 50:
zed.set_svo_position(0)
# Grab an image
if zed.grab() == sl.ERROR_CODE.SUCCESS:
zed.retrieve_image(left_image, sl.VIEW.LEFT) # Get the rectified left image
# Use the image in your application
# Close the Camera
zed.close()
return 0
if __name__ == "__main__" :
main()

◆ get_svo_position()

int get_svo_position (   self)

Returns the current playback position in the SVO file.

The position corresponds to the number of frames already read from the SVO file, starting from 0 to n.

Each grab() call increases this value by one (except when using InitParametersOne.svo_real_time_mode).

Returns
The current frame position in the SVO file. -1 if the SDK is not reading an SVO.
Note
The method works only if the camera is open in SVO playback mode.

See set_svo_position() for an example.

◆ get_svo_number_of_frames()

int get_svo_number_of_frames (   self)

Returns the number of frames in the SVO file.

Returns
The total number of frames in the SVO file. -1 if the SDK is not reading a SVO.

The method works only if the camera is open in SVO playback mode.

◆ set_camera_settings_range()

ERROR_CODE set_camera_settings_range (   self,
VIDEO_SETTINGS  settings,
  value_min = -1,
  value_max = -1 
)

Sets the value of the requested camera setting that supports two values (min/max).

This method only works with the following VIDEO_SETTINGS:

Parameters
settings: The setting to be set.
min: The minimum value that can be reached (-1 or 0 gives full range).
max: The maximum value that can be reached (-1 or 0 gives full range).
Returns
ERROR_CODE to indicate if the method was successful.
Warning
If VIDEO_SETTINGS settings is not supported or min >= max, it will return ERROR_CODE.INVALID_FUNCTION_PARAMETERS.
Note
The method works only if the camera is open in LIVE or STREAM mode.
# For ZED X based product, set the automatic exposure from 2ms to 5ms. Expected exposure time cannot go beyond those values
zed.set_camera_settings_range(sl.VIDEO_SETTINGS.AEC_RANGE, 2000, 5000);

◆ set_camera_settings_roi()

ERROR_CODE set_camera_settings_roi (   self,
VIDEO_SETTINGS  settings,
Rect  roi,
  reset = False 
)

Overloaded method for VIDEO_SETTINGS.AEC_AGC_ROI which takes a Rect as parameter.

Parameters
settings: Must be set at VIDEO_SETTINGS.AEC_AGC_ROI, otherwise the method will have no impact.
roi: Rect that defines the target to be applied for AEC/AGC computation. Must be given according to camera resolution.
eye: SIDE on which to be applied for AEC/AGC computation. Default: SIDE.BOTH
reset: Cancel the manual ROI and reset it to the full image. Default: False
Note
The method works only if the camera is open in LIVE or STREAM mode.
roi = sl.Rect(42, 56, 120, 15)
zed.set_camera_settings_roi(sl.VIDEO_SETTINGS.AEC_AGC_ROI, roi, sl.SIDE.BOTH)

◆ get_camera_settings()

(ERROR_CODE, int) get_camera_settings (   self,
VIDEO_SETTINGS  setting 
)

Returns the current value of the requested camera setting (gain, brightness, hue, exposure, etc.).

Possible values (range) of each setting are available here.

Parameters
setting: The requested setting.
Returns
ERROR_CODE to indicate if the method was successful.
The current value for the corresponding setting.
err, gain = zed.get_camera_settings(sl.VIDEO_SETTINGS.GAIN)
if err == sl.ERROR_CODE.SUCCESS:
print("Current gain value:", gain)
else:
print("error:", err)
Note
The method works only if the camera is open in LIVE or STREAM mode.
Settings are not exported in the SVO file format.

◆ get_camera_settings_range()

(ERROR_CODE, int, int) get_camera_settings_range (   self,
VIDEO_SETTINGS  setting 
)

Returns the values of the requested settings for VIDEO_SETTINGS that supports two values (min/max).

This method only works with the following VIDEO_SETTINGS:

Possible values (range) of each setting are available here.

Parameters
setting: The requested setting.
Returns
ERROR_CODE to indicate if the method was successful.
The current value of the minimum for the corresponding setting.
The current value of the maximum for the corresponding setting.
err, aec_range_min, aec_range_max = zed.get_camera_settings(sl.VIDEO_SETTINGS.AUTO_EXPOSURE_TIME_RANGE)
if err == sl.ERROR_CODE.SUCCESS:
print("Current AUTO_EXPOSURE_TIME_RANGE range values ==> min:", aec_range_min, "max:", aec_range_max)
else:
print("error:", err)
Note
Works only with ZED X that supports low-level controls

◆ get_camera_settings_roi()

ERROR_CODE get_camera_settings_roi (   self,
VIDEO_SETTINGS  setting,
Rect  roi 
)

Returns the current value of the currently used ROI for the camera setting AEC_AGC_ROI.

Parameters
setting[in]: Must be set at VIDEO_SETTINGS.AEC_AGC_ROI, otherwise the method will have no impact.
roi[out]: Roi that will be filled.
eye[in]: The requested side. Default: SIDE.BOTH
Returns
ERROR_CODE to indicate if the method was successful.
roi = sl.Rect()
err = zed.get_camera_settings_roi(sl.VIDEO_SETTINGS.AEC_AGC_ROI, roi, sl.SIDE.BOTH)
print("Current ROI for AEC_AGC: " + str(roi.x) + " " + str(roi.y)+ " " + str(roi.width) + " " + str(roi.height))
Note
Works only if the camera is open in LIVE or STREAM mode with VIDEO_SETTINGS.AEC_AGC_ROI.
It will return ERROR_CODE.INVALID_FUNCTION_CALL or ERROR_CODE.INVALID_FUNCTION_PARAMETERS otherwise.

◆ is_camera_setting_supported()

bool is_camera_setting_supported (   self,
VIDEO_SETTINGS  setting 
)

Returns if the video setting is supported by the camera or not.

Parameters
setting[in]: the video setting to test
Returns
True if the VIDEO_SETTINGS is supported by the camera, False otherwise

◆ get_current_fps()

float get_current_fps (   self)

Returns the current framerate at which the grab() method is successfully called.

The returned value is based on the difference of camera timestamps between two successful grab() calls.

Returns
The current SDK framerate
Warning
The returned framerate (number of images grabbed per second) can be lower than InitParametersOne.camera_fps if the grab() function runs slower than the image stream or is called too often.
current_fps = zed.get_current_fps()
print("Current framerate: ", current_fps)

◆ get_timestamp()

Timestamp get_timestamp (   self,
TIME_REFERENCE  time_reference 
)

Returns the timestamp in the requested TIME_REFERENCE.

  • When requesting the TIME_REFERENCE.IMAGE timestamp, the UNIX nanosecond timestamp of the latest grabbed image will be returned.
    This value corresponds to the time at which the entire image was available in the PC memory. As such, it ignores the communication time that corresponds to 2 or 3 frame-time based on the fps (ex: 33.3ms to 50ms at 60fps).
  • When requesting the TIME_REFERENCE.CURRENT timestamp, the current UNIX nanosecond timestamp is returned.

This function can also be used when playing back an SVO file.

Parameters
time_reference: The selected TIME_REFERENCE.
Returns
The Timestamp in nanosecond. 0 if not available (SVO file without compression).
Note
As this function returns UNIX timestamps, the reference it uses is common across several Camera instances.
This can help to organized the grabbed images in a multi-camera application.
last_image_timestamp = zed.get_timestamp(sl.TIME_REFERENCE.IMAGE)
current_timestamp = zed.get_timestamp(sl.TIME_REFERENCE.CURRENT)
print("Latest image timestamp: ", last_image_timestamp.get_nanoseconds(), "ns from Epoch.")
print("Current timestamp: ", current_timestamp.get_nanoseconds(), "ns from Epoch.")

◆ get_frame_dropped_count()

int get_frame_dropped_count (   self)

Returns the number of frames dropped since grab() was called for the first time.

A dropped frame corresponds to a frame that never made it to the grab method.
This can happen if two frames were extracted from the camera when grab() is called. The older frame will be dropped so as to always use the latest (which minimizes latency).

Returns
The number of frames dropped since the first grab() call.

◆ get_init_parameters()

InitParametersOne get_init_parameters (   self)

Returns the InitParametersOne associated with the Camera object.

It corresponds to the structure given as argument to open() method.

Returns
InitParametersOne containing the parameters used to initialize the Camera object.

◆ get_streaming_parameters()

StreamingParameters get_streaming_parameters (   self)

Returns the StreamingParameters used.

It corresponds to the structure given as argument to the enable_streaming() method.

Returns
StreamingParameters containing the parameters used for streaming initialization.

◆ get_sensors_data()

ERROR_CODE get_sensors_data (   self,
SensorsData  py_sensors_data,
  time_reference = TIME_REFERENCE.CURRENT 
)

Retrieves the SensorsData (IMU, magnetometer, barometer) at a specific time reference.

SensorsData object contains the previous IMUData structure that was used in ZED SDK v2.X:
For IMU data, the values are provided in 2 ways :

The delta time between previous and current values can be calculated using data.imu.timestamp

Note
The IMU quaternion (fused data) is given in the specified COORDINATE_SYSTEM of InitParametersOne.
Parameters
data[out]: The SensorsData variable to store the data.
reference_frame[in]Defines the reference from which you want the data to be expressed. Default: REFERENCE_FRAME.WORLD.
Returns
ERROR_CODE.SUCCESS if sensors data have been extracted.
ERROR_CODE.SENSORS_NOT_AVAILABLE if the camera model is a MODEL.ZED.
ERROR_CODE.MOTION_SENSORS_REQUIRED if the camera model is correct but the sensors module is not opened.
ERROR_CODE.INVALID_FUNCTION_PARAMETERS if the reference_time is not valid. See Warning.
Warning
In SVO reading mode, the TIME_REFERENCE.CURRENT is currently not available (yielding ERROR_CODE.INVALID_FUNCTION_PARAMETERS.
Only the quaternion data and barometer data (if available) at TIME_REFERENCE.IMAGE are available. Other values will be set to 0.

◆ enable_streaming()

ERROR_CODE enable_streaming (   self,
  streaming_parameters = StreamingParameters() 
)

Creates a streaming pipeline.

Parameters
streaming_parameters: A structure containing all the specific parameters for the streaming. Default: a reset of StreamingParameters .
Returns
ERROR_CODE.SUCCESS if the streaming was successfully started.
ERROR_CODE.INVALID_FUNCTION_CALL if open() was not successfully called before.
ERROR_CODE.FAILURE if streaming RTSP protocol was not able to start.
ERROR_CODE.NO_GPU_COMPATIBLE if the streaming codec is not supported (in this case, use H264 codec which is supported on all NVIDIA GPU the ZED SDK supports).
import pyzed.sl as sl
def main() :
# Create a ZED camera object
zed = sl.CameraOneOne()
# Set initial parameters
init_params = sl.InitParametersOne()
init_params.camera_resolution = sl.RESOLUTION.HD720 # Use HD720 video mode (default fps: 60)
# Open the camera
err = zed.open(init_params)
if err != sl.ERROR_CODE.SUCCESS :
print(repr(err))
exit(-1)
# Enable streaming
stream_params = sl.StreamingParameters()
stream_params.port = 30000
stream_params.bitrate = 8000
err = zed.enable_streaming(stream_params)
if err != sl.ERROR_CODE.SUCCESS :
print(repr(err))
exit(-1)
# Grab data during 500 frames
i = 0
while i < 500 :
if zed.grab() == sl.ERROR_CODE.SUCCESS :
i = i+1
zed.disable_streaming()
zed.close()
return 0
if __name__ == "__main__" :
main()

◆ disable_streaming()

None disable_streaming (   self)

Disables the streaming initiated by enable_streaming().

Note
This method will automatically be called by close() if enable_streaming() was called.

See enable_streaming() for an example.

◆ is_streaming_enabled()

bool is_streaming_enabled (   self)

Tells if the streaming is running.

Returns
True if the stream is running, False otherwise.

◆ enable_recording()

ERROR_CODE enable_recording (   self,
RecordingParameters  record 
)

Creates an SVO file to be filled by enable_recording() and disable_recording().


SVO files are custom video files containing the un-rectified images from the camera along with some meta-data like timestamps or IMU orientation (if applicable).
They can be used to simulate a live ZED and test a sequence with various SDK parameters.
Depending on the application, various compression modes are available. See SVO_COMPRESSION_MODE.

Parameters
record: A structure containing all the specific parameters for the recording such as filename and compression mode. Default: a reset of RecordingParameters .
Returns
An ERROR_CODE that defines if the SVO file was successfully created and can be filled with images.
Warning
This method can be called multiple times during a camera lifetime, but if video_filename is already existing, the file will be erased.
import pyzed.sl as sl
def main() :
# Create a ZED camera object
zed = sl.CameraOneOne()
# Set initial parameters
init_params = sl.InitParametersOne()
init_params.camera_resolution = sl.RESOLUTION.HD720 # Use HD720 video mode (default fps: 60)
init_params.coordinate_units = sl.UNIT.METER # Set units in meters
# Open the camera
err = zed.open(init_params)
if (err != sl.ERROR_CODE.SUCCESS):
print(repr(err))
exit(-1)
# Enable video recording
record_params = sl.RecordingParameters("myVideoFile.svo")
err = zed.enable_recording(record_params)
if (err != sl.ERROR_CODE.SUCCESS):
print(repr(err))
exit(-1)
# Grab data during 500 frames
i = 0
while i < 500 :
# Grab a new frame
if zed.grab() == sl.ERROR_CODE.SUCCESS:
# Record the grabbed frame in the video file
i = i + 1
zed.disable_recording()
print("Video has been saved ...")
zed.close()
return 0
if __name__ == "__main__" :
main()

◆ disable_recording()

None disable_recording (   self)

Disables the recording initiated by enable_recording() and closes the generated file.

Note
This method will automatically be called by close() if enable_recording() was called.

See enable_recording() for an example.

◆ get_recording_status()

RecordingStatus get_recording_status (   self)

Get the recording information.

Returns
The recording state structure. For more details, see RecordingStatus.

◆ pause_recording()

None pause_recording (   self,
  value = True 
)

Pauses or resumes the recording.

Parameters
status: If True, the recording is paused. If False, the recording is resumed.

◆ get_device_list()

list[DeviceProperties] get_device_list ( )
static

List all the connected devices with their associated information.

This method lists all the cameras available and provides their serial number, models and other information.

Returns
The device properties for each connected camera.

◆ reboot()

ERROR_CODE reboot ( int  sn,
bool   full_reboot = True 
)
static

Performs a hardware reset of the ZED 2 and the ZED 2i.

Parameters
sn: Serial number of the camera to reset, or 0 to reset the first camera detected.
full_reboot: Perform a full reboot (sensors and video modules) if True, otherwise only the video module will be rebooted.
Returns
ERROR_CODE::SUCCESS if everything went fine.
ERROR_CODE::CAMERA_NOT_DETECTED if no camera was detected.
ERROR_CODE::FAILURE otherwise.
Note
This method only works for ZED 2, ZED 2i, and newer camera models.
Warning
This method will invalidate any sl.Camera object, since the device is rebooting.

◆ reboot_from_input()

ERROR_CODE reboot_from_input ( INPUT_TYPE  input_type)
static

Performs a hardware reset of all devices matching the InputType.

Parameters
input_type: Input type of the devices to reset.
Returns
ERROR_CODE::SUCCESS if everything went fine.
ERROR_CODE::CAMERA_NOT_DETECTED if no camera was detected.
ERROR_CODE::FAILURE otherwise.
ERROR_CODE::INVALID_FUNCTION_PARAMETERS for SVOs and streams.
Warning
This method will invalidate any sl.Camera object, since the device is rebooting.