### Install pyopengl Dependency Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/body tracking/python/README.md Installs the pyopengl library required for the ZED SDK Body Tracking sample using pip. ```bash python3 -m pip install pyopengl ``` -------------------------------- ### Install Dependencies (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/python/pytorch_yolov8_seg/README.md Install the required ultralytics library using pip, which is necessary for running the YOLOv8-seg model. ```Shell pip install ultralytics ``` -------------------------------- ### Setup Basic ZED Streaming Test (Bash) Source: https://github.com/stereolabs/zed-sdk/blob/master/camera streaming/receiver/python/README.md Commands to simulate a streaming setup locally. First, run the sender script to get the broadcast port, then run the receiver script using the local loopback address and the obtained port. ```bash python streaming_sender.py ``` ```bash python streaming_receiver.py --ip_address 127.0.0.1:port ``` -------------------------------- ### Installing YOLOv5 Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx/README.md Instructions for cloning the YOLOv5 repository from GitHub and installing its required dependencies using pip. ```Shell git clone https://github.com/ultralytics/yolov5 # clone cd yolov5 pip install -r requirements.txt # install ``` -------------------------------- ### Clone and Setup YOLOv5 Repository (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/python/pytorch_yolov5/README.md Clones the official YOLOv5 repository from GitHub and installs its required Python dependencies using pip. ```Shell git clone https://github.com/ultralytics/yolov5 # Install the dependencies if needed cd yolov5 pip install -r requirements.txt ``` -------------------------------- ### Running the Object Detection Program (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/python/pytorch_yolov8/README.md Executes the main Python script `detector.py` to start the object detection process using the ZED camera. It requires specifying the path to the YOLOv8 weights file (`yolov8m.pt` in this example). Optional arguments for image size, confidence threshold, and SVO file input are shown as comments. ```sh python detector.py --weights yolov8m.pt # [--img_size 512 --conf_thres 0.1 --svo path/to/file.svo] ``` -------------------------------- ### Setup ZED Fusion Module (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 9 - global localization/python/README.md Initializes the ZED Fusion module, sets its coordinate system and units, enables positional tracking within the fusion module, and subscribes the fusion module to the ZED camera using its serial number and communication parameters. ```Python # step 2 # init the fusion module that will input both the camera and the GPS fusion = sl.Fusion() init_fusion_parameters = sl.InitFusionParameters() init_fusion_parameters.coordinate_system = sl.COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP init_fusion_parameters.coordinate_units = sl.UNIT.METER fusion.init(init_fusion_parameters) fusion.enable_positionnal_tracking() uuid = sl.CameraIdentifier(camera_info.serial_number) print("Subscribing to", uuid.serial_number, communication_parameters.comm_type) #Subscribe fusion to camera status = fusion.subscribe(uuid, communication_parameters, sl.Transform(0,0,0)) if status != sl.FUSION_ERROR_CODE.SUCCESS: print("Failed to subscribe to", uuid.serial_number, status) exit(1) ``` -------------------------------- ### Install YOLOv8 Python Package Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov8_seg_onnx/README.md Installs the ultralytics package, which provides the YOLOv8 implementation and command-line interface, using pip. ```Shell python -m pip install ultralytics ``` -------------------------------- ### Installing YOLOv8 via pip Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Installs the ultralytics package, which provides the YOLOv8 models and associated tools, using the Python package installer pip. ```shell python -m pip install ultralytics ``` -------------------------------- ### Run ZED Body Tracking Sample (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/body tracking/csharp/README.md This command is used to execute the compiled ZED Body Tracking sample program from the terminal after navigating to the build directory. Ensure the ZED SDK is installed and the project has been built successfully. ```Shell ./ZED_Body_Tracking ``` -------------------------------- ### Installing YOLOv6 Dependencies Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Clones the YOLOv6 repository and installs the necessary Python dependencies using pip. This prepares the environment for working with YOLOv6 models. ```shell git clone https://github.com/meituan/YOLOv6 cd YOLOv6 pip install -r requirements.txt pip install onnx>=1.10.0 ``` -------------------------------- ### SVO Export Command Examples - Bash Source: https://github.com/stereolabs/zed-sdk/blob/master/recording/export/svo/python/README.md Examples demonstrating how to use the export script with different modes. Modes 0 and 1 export to AVI, requiring `--output_avi_file`. Modes 2, 3, and 4 export to PNG sequences, requiring `--output_path_dir`. ```bash python export_svo.py --mode 0 --input_svo_file --output_avi_file python export_svo.py --mode 1 --input_svo_file --output_avi_file python export_svo.py --mode 2 --input_svo_file --output_path_dir python export_svo.py --mode 3 --input_svo_file --output_path_dir python export_svo.py --mode 4 --input_svo_file --output_path_dir ``` -------------------------------- ### Run ZED SDK Camera Control Sample (Bash) Source: https://github.com/stereolabs/zed-sdk/blob/master/camera control/python/README.md This command executes the Python script for the ZED SDK camera control sample from the terminal. Ensure you have the ZED SDK and pyZED package installed and the script is in the current directory. ```bash python camera_control.py ``` -------------------------------- ### Install YOLOv8 using pip (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/python/pytorch_yolov8_async/README.md Installs the ultralytics package, which provides the official Pytorch implementation of YOLOv8, using the pip package manager. This is a required dependency for running the sample. ```Shell pip install ultralytics ``` -------------------------------- ### Install YOLOv8 Python Package Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx/README.md Installs the ultralytics YOLOv8 package using pip, providing the necessary command-line interface and libraries for YOLOv8 operations. ```Shell python -m pip install ultralytics ``` -------------------------------- ### Initialize ZED Camera C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/cpp/README.md Creates and configures a ZED camera object. Sets initialization parameters, specifically disabling depth computation to save processing power. Opens the camera and handles potential errors. ```C++ // Create a ZED camera object Camera zed; // Set configuration parameters InitParameters init_parameters; // no depth computation required here init_parameters.depth_mode = DEPTH_MODE::NONE; // Open the camera ERROR_CODE err = zed.open(init_parameters); if (err != ERROR_CODE::SUCCESS) { cout << "Error " << err << ", exit program.\n"; return -1; } ``` -------------------------------- ### Install YOLOv6 Dependencies Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx/README.md Clones the YOLOv6 repository and installs the required Python dependencies using pip, including a specific ONNX version. ```Shell git clone https://github.com/meituan/YOLOv6 cd YOLOv6 pip install -r requirements.txt pip install onnx>=1.10.0 ``` -------------------------------- ### Command Line Usage for SVO Export Source: https://github.com/stereolabs/zed-sdk/blob/master/recording/export/svo/csharp/README.md This snippet shows the command-line syntax for running the ZED_SVO_Export executable. It details the required input SVO file path, output file/folder path, and the export mode parameter, along with examples for different conversion types. ```Shell Usage: ZED_SVO_Export A B C Please use the following parameters from the command line: A - SVO file path (input) : "path/to/file.svo" B - AVI file path (output) or image sequence folder(output) : "path/to/output/file.avi" or "path/to/output/folder/" C - Export mode: 0=Export LEFT+RIGHT AVI. 1=Export LEFT+DEPTH_VIEW AVI. 2=Export LEFT+RIGHT image sequence. 3=Export LEFT+DEPTH_VIEW image sequence. 4=Export LEFT+DEPTH_16Bit image sequence. A and B need to end with '/' or '\' Examples: (AVI LEFT+RIGHT) ZED_SVO_Export "path/to/file.svo" "path/to/output/file.avi" 0 (AVI LEFT+DEPTH) ZED_SVO_Export "path/to/file.svo" "path/to/output/file.avi" 1 (SEQUENCE LEFT+RIGHT) ZED_SVO_Export "path/to/file.svo" "path/to/output/folder/" 2 (SEQUENCE LEFT+DEPTH) ZED_SVO_Export "path/to/file.svo" "path/to/output/folder/" 3 (SEQUENCE LEFT+DEPTH_16Bit) ZED_SVO_Export "path/to/file.svo" "path/to/output/folder/" 4 ``` -------------------------------- ### Initialize ZED Camera in Python Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/python/README.md Creates a ZED Camera object, sets initialization parameters (like depth mode to NONE), and attempts to open the camera. Includes error handling to print the error and exit if opening fails. ```python # Create a Camera object zed = sl.Camera() init_params = sl.InitParameters() init_params.depth_mode = sl.DEPTH_MODE.NONE # Open the camera err = zed.open(init_params) if err != sl.ERROR_CODE.SUCCESS : print(repr(err)) zed.close() exit(1) ``` -------------------------------- ### Running ZED SVO Recording Script - Bash Source: https://github.com/stereolabs/zed-sdk/blob/master/recording/recording/single camera/python/README.md Execute the Python script `svo_recording.py` to start recording ZED camera data into an SVO file. The `--output_svo_file` argument specifies the path and name for the output SVO file. ```Bash python svo_recording.py --output_svo_file ``` -------------------------------- ### Running YOLOv5 ONNX ZED Sample (SVO File) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Example command to run the YOLO ONNX ZED sample application using a YOLOv5 TensorRT engine and a recorded ZED SVO file. ```sh ./yolo_onnx_zed yolov5.engine ./foo.svo ``` -------------------------------- ### Running YOLOv5 ONNX ZED Sample (Camera) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Example command to run the YOLO ONNX ZED sample application using a YOLOv5 TensorRT engine and a connected ZED camera (ID 0). ```sh ./yolo_onnx_zed yolov5s.engine 0 ``` -------------------------------- ### Build and Run Sample (sh) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/opencv_dnn_yolov4/README.md This sequence of shell commands demonstrates how to build the project using CMake and make, assuming the necessary dependencies (ZED SDK, OpenCV with DNN) are installed. It then shows how to navigate back to the project root and execute the compiled sample program. ```sh mkdir build cd build cmake .. make cd ../ # ls # build # CMakeLists.txt # coco.names.txt # include # README.md # src # yolov4.cfg # yolov4.weights # Running the sample ./build/opencv_dnn_zed ``` -------------------------------- ### Running YOLOv6 ONNX ZED Sample (SVO File) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Example command to run the YOLO ONNX ZED sample application using a YOLOv6 TensorRT engine and a recorded ZED SVO file. ```sh ./yolo_onnx_zed yolov6s.engine ./foo.svo ``` -------------------------------- ### Running YOLOv6 ONNX ZED Sample (Camera) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Example command to run the YOLO ONNX ZED sample application using a YOLOv6 TensorRT engine and a connected ZED camera (ID 0). ```sh ./yolo_onnx_zed yolov6s.engine 0 ``` -------------------------------- ### Running YOLOv6 ONNX with ZED SDK Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx/README.md Examples demonstrating how to run the compiled sample application with a YOLOv6 TensorRT engine, using either a connected ZED camera or a recorded SVO file as input. ```Shell ./yolo_onnx_zed yolov6s.engine 0 ``` ```Shell ./yolo_onnx_zed yolov6s.engine ./foo.svo ``` -------------------------------- ### Enable ZED Body Tracking Module (C++) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 8 - body tracking/cpp/README.md Starts the body tracking module with the previously defined parameters. This step loads the AI model and may take some time, especially on the first run. Checks for errors after attempting to enable the module. ```cpp cout << "Body Tracking: Loading Module..." << endl; returned_state = zed.enableBodyTracking(detection_parameters); if (returned_state != ERROR_CODE::SUCCESS) { cout << "Error " << returned_state << ", exit program.\n"; zed.close(); return EXIT_FAILURE; } ``` -------------------------------- ### Running YOLOv5 ONNX with ZED SDK Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx/README.md Examples showing the general command structure and specific uses of the sample application to run inference with a generated TensorRT engine, using either a ZED camera or an SVO file. ```Shell ./yolo_onnx_zed [.engine] [zed camera id / optional svo filepath] ``` ```Shell ./yolo_onnx_zed yolov5s.engine 0 ``` ```Shell ./yolo_onnx_zed yolov5.engine ./foo.svo ``` -------------------------------- ### Running the YOLO ONNX ZED sample Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_internal/README.md This command executes the compiled sample application, taking the path to the ONNX model and either a ZED camera ID or an SVO file path as arguments. It initializes the ZED camera or loads the SVO, loads the specified ONNX model, and starts the object detection process. ```sh ./yolo_onnx_zed [.onnx] [zed camera id / optional svo filepath] # For example yolov8n ./yolo_onnx_zed yolov8n.onnx 0 # 0 for zed camera id 0 # With an SVO file ./yolo_onnx_zed yolov8n.onnx ./foo.svo ``` -------------------------------- ### Configuring ZED Camera InitParameters (C++) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/cpp/README.md This snippet demonstrates how to create a Camera object and initialize InitParameters to configure settings like resolution and frame rate before opening the camera. ```C++ // Create a ZED camera object Camera zed; // Set configuration parameters InitParameters init_params; init_params.camera_resolution = RESOLUTION::HD1080 ; init_params.camera_fps = 30 ; ``` -------------------------------- ### Configuring and Opening ZED Camera (C#) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/csharp/README.md This snippet demonstrates how to initialize the ZED camera with specific parameters like resolution and FPS using InitParameters, and then open the camera connection. It checks the return code from the Open method to ensure the operation was successful. Requires the ZED SDK C# wrapper. ```csharp InitParameters init_params = new InitParameters(); init_params.resolution = RESOLUTION.HD1080; init_params.cameraFPS = 30; Camera zedCamera = new Camera(); // Open the camera ERROR_CODE err = zedCamera.Open(ref init_params); if (err != ERROR_CODE.SUCCESS) Environment.Exit(-1); ``` -------------------------------- ### Opening the ZED Camera - C Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/c/README.md This snippet demonstrates how to open the ZED camera using the configured initialization parameters. It checks the return state to ensure the camera opened successfully and prints an error message if it fails. ```C # Open the camera int state = sl_open_camera(camera_id, &init_param, "", "", "", "", "", ""); if (state != 0) { printf("Error Open \n"); return 1; } ``` -------------------------------- ### Capture ZED Sensor Data C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/cpp/README.md Initializes a SensorsData object and enters a loop to continuously retrieve sensor data from the ZED camera using getSensorsData. The loop continues for a specified duration (5 seconds in this example). ```C++ SensorsData sensors_data; double elapse_time = 0; while (elapse_time < 5000) { if (zed.getSensorsData(sensors_data, TIME_REFERENCE::CURRENT) == ERROR_CODE::SUCCESS) { [...] } } ``` -------------------------------- ### Building - ZED SDK - Bash Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 4 - positional tracking/cpp/README.md Provides the standard command-line steps to build a ZED SDK sample project on Linux using CMake and Make. It creates a build directory, navigates into it, configures the project with CMake, and compiles it. ```bash mkdir build cd build cmake .. make ``` -------------------------------- ### Run ZED SVO Recording Sample Source: https://github.com/stereolabs/zed-sdk/blob/master/recording/recording/single camera/csharp/README.md Executes the ZED SVO Recording sample program from the build directory, specifying the output SVO file name as a command-line argument. ```Shell ./ZED_SVO_Recording my_svo_file.svo ``` -------------------------------- ### Opening the ZED Camera (C++) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/cpp/README.md This snippet shows how to open the ZED camera using the previously configured InitParameters. It includes basic error handling to check if the operation was successful. ```C++ // Open the camera err = zed.open(init_params); if (err != ERROR_CODE::SUCCESS) exit(-1); ``` -------------------------------- ### Run ZED Body Tracking Sample - Shell Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/multi-camera/csharp/README.md Command to execute the compiled ZED Body Tracking sample from the build directory in a terminal. ```Shell ./ZED_Body_Tracking ``` -------------------------------- ### Initialize ZED Camera and Parameters (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/python/README.md Creates a ZED camera object and sets initial configuration parameters, including camera resolution (HD1080) and frame rate (30 FPS). These parameters must be set before opening the camera. ```python # Create a ZED camera object zed = sl.Camera() # Set configuration parameters init_params = sl.InitParameters() init_params.camera_resolution = sl.RESOLUTION.HD1080 init_params.camera_fps = 30 ``` -------------------------------- ### Running the ZED Positional Tracking Sample Source: https://github.com/stereolabs/zed-sdk/blob/master/positional tracking/positional tracking/cpp/README.md This command executes the compiled ZED Positional Tracking sample from the build directory. Ensure you are in the correct directory before running. ```Shell ./ZED_Positional_Tracking ``` -------------------------------- ### Installing YOLOv8 Dependency (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/python/pytorch_yolov8/README.md Installs the `ultralytics` package, which provides the official PyTorch implementation of YOLOv8, using pip. This is a required dependency for the project. ```sh pip install ultralytics ``` -------------------------------- ### Running the ZED Plane Detection sample (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/plane detection/plane detection/csharp/README.md Instructions on how to execute the compiled ZED Plane Detection sample from the build directory using a terminal. ```Shell ./ZED_Plane_Detection ``` -------------------------------- ### Configuring ZED Camera Parameters - C Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/c/README.md This snippet shows how to create a ZED camera object and set its initial configuration parameters using the SL_InitParameters struct. These parameters, such as resolution, FPS, input type, and depth mode, must be set before opening the camera. ```C //Create a ZED camera object int camera_id = 0; sl_create_camera(camera_id); //Set configuration parameters struct SL_InitParameters init_param; init_param.camera_fps = 30; init_param.resolution = SL_RESOLUTION_HD1080; init_param.input_type = SL_INPUT_TYPE_USB; init_param.camera_device_id = camera_id; init_param.camera_image_flip = SL_FLIP_MODE_AUTO; init_param.camera_disable_self_calib = false; init_param.enable_image_enhancement = true; init_param.svo_real_time_mode = true; init_param.depth_mode = SL_DEPTH_MODE_NEURAL; init_param.depth_stabilization = 30; init_param.depth_maximum_distance = 40; init_param.depth_minimum_distance = -1; init_param.coordinate_unit = SL_UNIT_METER; init_param.coordinate_system = SL_COORDINATE_SYSTEM_LEFT_HANDED_Y_UP; init_param.sdk_gpu_id = -1; init_param.sdk_verbose = false; init_param.sensors_required = false; init_param.enable_right_side_measure = false; ``` -------------------------------- ### Installing YOLOv5 via Pip Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/custom detector/cpp/tensorrt_yolov5-v6-v8_onnx_async/README.md Commands to clone the YOLOv5 repository from GitHub and install its dependencies using pip, which is required for exporting models. ```sh git clone https://github.com/ultralytics/yolov5 # clone cd yolov5 pip install -r requirements.txt # install ``` -------------------------------- ### Run ZED Object Detection Sample - Shell Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/image viewer/cpp/README.md Launches the compiled ZED Object Detection sample executable from the build directory using a terminal command. ```Shell ./ZED_Object_detection_image_viewer ``` -------------------------------- ### Running the Positional Tracking Sample - Shell Source: https://github.com/stereolabs/zed-sdk/blob/master/positional tracking/positional tracking/csharp/README.md This command executes the compiled positional tracking sample program from the build directory. Ensure you are in the correct directory before running. ```Shell ./ZED_Positional_Tracking ``` -------------------------------- ### Run ZED Object Detection Sample (Bash) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/birds eye viewer/csharp/README.md Execute the compiled ZED object detection sample application from the build directory using a terminal. ```bash ./ZED_Object_detection_birds_eye ``` -------------------------------- ### Display ZED Sensor Temperature Data C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/cpp/README.md Iterates through available sensor locations to retrieve and display temperature data using the get method of the TemperatureData object. Checks for successful retrieval before printing. ```C++ cout << " - Temperature\n"; float temperature; for (int s = 0; s < SensorsData::TemperatureData::SENSOR_LOCATION::LAST; s++) { auto sensor_loc = static_cast(s); if (sensors_data.temperature.get(sensor_loc, temperature) == ERROR_CODE::SUCCESS) cout << " \t " << sensor_loc << ": " << temperature << "C\n"; } ``` -------------------------------- ### Run ZED Object Detection Sample - Shell Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/image viewer/csharp/README.md This command executes the compiled ZED Object Detection sample application from the build directory. ```Shell ./ZED_Object_detection_image ``` -------------------------------- ### Initializing ZED Camera in C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 2 - image capture/cpp/README.md This snippet demonstrates how to create a ZED camera object, set initialization parameters like resolution and framerate, and open the camera. It includes error handling to exit if the camera fails to open. ```C++ // Create a ZED camera object Camera zed; // Set configuration parameters InitParameters init_params; init_params.camera_resolution = RESOLUTION::AUTO; // Use HD720 opr HD1200 video mode, depending on camera type. init_params.camera_fps = 30; // Set fps at 30 // Open the camera ERROR_CODE err = zed.open(init_params); if (err != ERROR_CODE::SUCCESS) exit(-1); ``` -------------------------------- ### Example ZED SDK Object Detection JSON Structure Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/export/JSON export/cpp/README.md This snippet provides an example of the JSON format used by the ZED SDK to represent detected objects. It details properties like bounding box coordinates, 3D position and velocity, tracking state, and a unique ID for each detected object. ```json { "1680100601285": { "bodies": [ { "bounding_box_2d": [ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], "bounding_box_3d": [ [ 0.0, -0.44999998807907104, 0.0 ], [ 0.0, -0.4000000059604645, 0.0 ], [ 0.0, -0.10000000149011612, -0.11999999731779099 ], [ 0.0, 0.1359274685382843, -0.06343282014131546 ], [ 0.0, 0.0453091561794281, 0.0 ], [ -0.02718549221754074, 0.07702556997537613, 0.03171641007065773 ], [ -0.07702556997537613, 0.0561833530664444, 0.11780380457639694 ], [ 0.02718549221754074, 0.07702556997537613, 0.03171641007065773 ], [ 0.07702556997537613, 0.0561833530664444, 0.11780380457639694 ], [ 0.0, -0.10000000149011612, 0.03999999910593033 ], [ 0.0, -0.10000000149011612, 0.03999999910593033 ] ], "position": [ 0.06768068671226501, -0.018858879804611206, -0.5713798999786377 ], "position_covariance": [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.4000000059604645 ], "tracking_state": 0, "unique_object_id": "0b3a1b48-5316-4fa1-aa47-7c8844c68e5b", "velocity": [ 0.0, 0.0, 0.0 ] } ], "is_new": true, "is_tracked": false, "timestamp": 1680100601285169401 }, "1680100601351": { // another body... } } ``` -------------------------------- ### Running the ZED SVO Playback Sample (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/recording/playback/multi camera/cpp/README.md Execute the compiled ZED SVO Playback program from the build directory, providing the paths to one or more SVO files as command-line arguments. ```shell ./ZED_SVO_Playback svo_file_1.svo svo_file_2.svo ... ``` -------------------------------- ### Close ZED Camera C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/cpp/README.md Closes the ZED camera connection and returns a success code, releasing resources before the program exits. ```C++ // Close camera zed.close(); return 0; ``` -------------------------------- ### Run SVO Playback Sample (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/recording/playback/single camera/csharp/README.md Execute the compiled ZED SVO Playback sample with a specified SVO file as input from the build directory. ```shell ./ZED_SVO_Playback svo_file.svo ``` -------------------------------- ### Run ZED Body Tracking Sample Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/body tracking/python/README.md Executes the ZED SDK Body Tracking sample script using the default camera. ```bash python body_tracking.py ``` -------------------------------- ### Get ZED Camera Serial Number (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/python/README.md Retrieves the camera information object and extracts the serial number. The serial number is then printed to the console. ```python # Get camera information (serial number) zed_serial = zed.get_camera_information().serial_number print("Hello! This is my serial number: ", z_serial) ``` -------------------------------- ### Closing ZED Camera with ZED SDK (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/python/README.md Closes the ZED camera instance and returns 0, releasing resources after data processing is complete. Essential for proper program termination. ```python # Close camera zed.close() return 0 ``` -------------------------------- ### Initializing ZED Camera in Python Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 4 - positional tracking/python/README.md Creates a ZED camera object, sets initialization parameters like resolution, coordinate system, and units, and attempts to open the camera. Exits if the camera fails to open. ```python # Create a ZED camera object zed = sl.Camera() # Set configuration parameters init_params = sl.InitParameters() init_params.camera_resolution = sl.RESOLUTION.AUTO # Use HD720 or HD1200 video mode (default fps: 60) init_params.coordinate_system = sl.COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP # Use a right-handed Y-up coordinate system 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): exit(-1) ``` -------------------------------- ### Run ZED Body Tracking Sample (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/body tracking/cpp/README.md Command to execute the compiled ZED Body Tracking sample from the build directory on Linux/Jetson. ```Shell ./ZED_Body_Tracking ``` -------------------------------- ### Configure Batching Latency Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/birds eye viewer/python/README.md Example configuration line showing how to set the latency parameter for the batching system used in object re-identification. This value determines the delay for displaying batched detections. ```configuration batch_parameters.latency = 3.0 ``` -------------------------------- ### Accessing Magnetometer Data with ZED SDK (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/python/README.md Checks if new magnetometer data is available and prints the calibrated magnetic field vector if updated. Requires a ZED2 camera and the ZED SDK. ```python # Check if Magnetometer data has been updated (not the same frequency than IMU) if ts_handler.is_new(sensors_data.get_magnetometer_data()): magnetic_field_calibrated = sensors_data.get_magnetometer_data().get_magnetic_field_calibrated() print(" - Magnetometer\n \t Magnetic Field: [ {0} {1} {2} ] [uT]".format(magnetic_field_calibrated[0], magnetic_field_calibrated[1], magnetic_field_calibrated[2])) ``` -------------------------------- ### Retrieving Image and Timestamp from ZED Camera in C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 2 - image capture/cpp/README.md After a successful grab, this snippet demonstrates how to retrieve the left image into a `sl::Mat` object and get the corresponding image timestamp using `zed.retrieveImage()` and `zed.getCameraTimestamp()`. ```C++ zed.retrieveImage(image,VIEW_LEFT); // Get the left image unsigned long long timestamp = zed.getCameraTimestamp(); // Get the timestamp of the image printf("Image resolution: %d x %d || Image timestamp: %llu\n", image.getWidth(), image.getHeight(), timestamp); ``` -------------------------------- ### Open ZED Camera (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/python/README.md Opens the ZED camera using the previously defined initialization parameters. It checks the return value for success and exits the program if an error occurs during opening. ```python # Open the camera err = zed.open(init_params) if (err != sl.ERROR_CODE.SUCCESS) : exit(-1) ``` -------------------------------- ### Accessing Barometer Data with ZED SDK (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/python/README.md Checks if new barometer data is available using a timestamp handler and prints the atmospheric pressure if updated. Requires a ZED2 camera and the ZED SDK. ```python if ts_handler.is_new(sensors_data.get_barometer_data()): magnetic_field_calibrated = sensors_data.get_barometer_data().pressure print(" - Barometer\n \t Atmospheric pressure: {0} [hPa]".format(sensors_data.get_barometer_data().pressure)) ``` -------------------------------- ### Initialize ZED Camera for Positional Tracking (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 9 - global localization/python/README.md Creates, opens, and configures the ZED camera for positional tracking. It sets up communication parameters for publishing data, performs a warm-up grab, and enables positional tracking with specific parameters required for GNSS integration. ```Python # step 1 # create the camera that will input the position from its odometry zed = sl.Camera() status = zed.open(init_params) if status != sl.ERROR_CODE.SUCCESS: print("Camera Open: " + repr(status) + ". Exit program.") exit() # set up communication parameters and start publishing communication_parameters = sl.CommunicationParameters() communication_parameters.set_for_shared_memory() zed.start_publishing(communication_parameters) # warmup for camera if zed.grab() != sl.ERROR_CODE.SUCCESS: print("Camera grab: " + repr(status) + ". Exit program.") exit() else: zed.get_position(odometry_pose, sl.REFERENCE_FRAME.WORLD) tracking_params = sl.PositionalTrackingParameters() # These parameters are mandatory to initialize the transformation between GNSS and ZED reference frames. tracking_params.enable_imu_fusion = True tracking_params.set_gravity_as_origin = True err = zed.enable_positional_tracking(tracking_params) if (err != sl.ERROR_CODE.SUCCESS): print("Camera positional tracking: " + repr(status) + ". Exit program.") exit() camera_info = zed.get_camera_information() ``` -------------------------------- ### Run ZED Depth Sensing Sample (Shell) Source: https://github.com/stereolabs/zed-sdk/blob/master/depth sensing/depth sensing/csharp/README.md Command to execute the compiled ZED Depth Sensing sample from the build directory in a terminal. ```Shell ./ZED_Depth_Sensing ``` -------------------------------- ### Getting ZED Camera Serial Number - C Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 1 - hello ZED/c/README.md This snippet shows how to retrieve the serial number of the connected ZED camera using the sl_get_zed_serial function and print it to the console. This is a simple way to verify communication with the camera. ```C // Get camera information (serial number) int sn = sl_get_zed_serial(camera_id); printf("Hello! This is my serial number: %d\n", sn); ``` -------------------------------- ### Initialize ZED Camera (C++) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 10 - split process/cpp/README.md This snippet initializes and opens the ZED camera with specific configuration parameters, including enabling verbose output, setting the depth mode to NEURAL, and using millimeter units. It checks for errors during the opening process. ```C++ // Create a ZED camera Camera zed; // Create configuration parameters InitParameters init_params; init_params.sdk_verbose = 1; // Enable the verbose mode init_params.depth_mode = DEPTH_MODE::NEURAL; // Set the depth mode to NEURAL init_params.coordinate_units = UNIT::MILLIMETER; // Use millimeter units // Open the camera ERROR_CODE err = zed.open(init_params); if (err != ERROR_CODE::SUCCESS) { std::cout << "Error " << err << ", exit program.\n"; // Display the error return -1; } ``` -------------------------------- ### Run ZED Object Detection Sample (Default) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/image viewer/python/README.md Execute the object detection sample using the default wired ZED camera. ```bash python object_detection_image_viewer.py ``` -------------------------------- ### Initializing ZED Camera - ZED SDK - C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 5 - spatial mapping/cpp/README.md Creates a ZED camera object, sets initialization parameters (resolution, coordinate system, units), and opens the camera. It configures a right-handed Y-up coordinate system in meters and checks for successful opening, exiting on failure. ```C++ // Create a ZED camera object Camera zed; // Set configuration parameters InitParameters init_params; init_params.camera_resolution = RESOLUTION::AUTO; // Use HD720 or HD1200 video mode (default fps: 60) init_params.coordinate_system = COORDINATE_SYSTEM::RIGHT_HANDED_Y_UP; // Use a right-handed Y-up coordinate system init_params.coordinate_units = UNIT::METER; // Set units in meters // Open the camera ERROR_CODE err = zed.open(init_params); if (err != ERROR_CODE::SUCCESS) exit(-1); ``` -------------------------------- ### Run ZED Body Tracking Sample with Arguments Source: https://github.com/stereolabs/zed-sdk/blob/master/body tracking/body tracking/python/README.md Executes the ZED SDK Body Tracking sample script, allowing specification of an SVO file, IP address, or resolution. ```bash python body_tracking.py --input_svo_file --ip_address --resolution ``` -------------------------------- ### Accessing IMU Data with ZED SDK (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/python/README.md Retrieves and prints the filtered orientation quaternion, linear acceleration, and angular velocities from the IMU sensor data. Applicable for ZED2 cameras using the ZED SDK. ```python # Filtered orientation quaternion quaternion = sensors_data.get_imu_data().get_pose().get_orientation().get() print(" \t Orientation: [ Ox: {0}, Oy: {1}, Oz {2}, Ow: {3} ]".format(quaternion[0], quaternion[1], quaternion[2], quaternion[3])) # linear acceleration linear_acceleration = sensors_data.get_imu_data().get_linear_acceleration() print(" \t Acceleration: [ {0} {1} {2} ] [m/sec^2]".format(linear_acceleration[0], linear_acceleration[1], linear_acceleration[2])) # angular velocities angular_velocity = sensors_data.get_imu_data().get_angular_velocity() print(" \t Angular Velocities: [ {0} {1} {2} ] [deg/sec]".format(angular_velocity[0], angular_velocity[1], angular_velocity[2])) ``` -------------------------------- ### Initialize ZED Camera (C#) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 8 - body tracking/csharp/README.md Initializes the ZED camera with specified parameters (resolution, coordinate units, verbose mode) and opens the connection. Exits the application if the camera fails to open. ```C# // Create ZED objects Camera zedCamera = new Camera(0); InitParameters init_params = new InitParameters(); init_params.resolution = RESOLUTION.HD720; init_params.coordinateUnits = UNIT.METER; init_params.sdkVerbose = true; // Open the camera ERROR_CODE err = zedCamera.Open(ref init_params); if (err != ERROR_CODE.SUCCESS) Environment.Exit(-1); ``` -------------------------------- ### Get Depth Value from Depth Map at Center Pixel - C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 3 - depth sensing/cpp/README.md Retrieves the depth value at the center pixel of the image directly from the depth map. It accesses the float value from the depth Mat and prints it. ```C++ int x = image.getWidth() / 2; int y = image.getHeight() / 2; float depth_value; depth.getValue(x,y, depth_value); printf("Depth to Camera at (%d, %d): %f mm\n", x, y, depth_value); ``` -------------------------------- ### Initializing - ZED Camera - C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 4 - positional tracking/cpp/README.md Creates a ZED Camera object and initializes it with specified parameters, including resolution, coordinate system, and units. It attempts to open the camera and exits the program if the operation fails. ```c++ // Create a ZED camera object Camera zed; // Set configuration parameters InitParameters init_params; init_params.camera_resolution = RESOLUTION::AUTO; // Use HD720 or HD1200 video mode (default fps: 60) init_params.coordinate_system = COORDINATE_SYSTEM::RIGHT_HANDED_Y_UP; // Use a right-handed Y-up coordinate system init_params.coordinate_units = UNIT::METER; // Set units in meters // Open the camera ERROR_CODE err = zed.open(init_params); if (err != ERROR_CODE::SUCCESS) exit(-1); ``` -------------------------------- ### Run ZED Object Detection Sample (Default) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/birds eye viewer/python/README.md Executes the ZED SDK object detection sample script using the default camera input and settings. ```bash python object_detection_birds_view.py ``` -------------------------------- ### Initializing ZED Camera in Python Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 2 - image capture/python/README.md Creates a ZED camera object, sets initialization parameters like resolution (AUTO) and framerate (30 fps), and attempts to open the camera. Exits the program if the camera fails to open. ```python # Create a ZED camera object zed = sl.Camera() # Set configuration parameters init_params = sl.InitParameters() init_params.camera_resolution = sl.RESOLUTION.AUTO # Use HD720 opr HD1200 video mode, depending on camera type. init_params.camera_fps = 30 # Set fps at 30 # Open the camera err = zed.open(init_params) if (err != sl.ERROR_CODE.SUCCESS) : exit(-1) ``` -------------------------------- ### Initializing ZED Camera - Python Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 8 - body tracking/python/README.md Creates a ZED Camera object, sets initialization parameters including resolution, depth mode, coordinate units, and verbosity, and opens the camera connection. Requires a ZED 2 camera. ```Python # Create a Camera object zed = sl.Camera() # Create a InitParameters object and set configuration parameters init_params = sl.InitParameters() init_params.camera_resolution = sl.RESOLUTION.HD720 # Use HD720 video mode init_params.depth_mode = sl.DEPTH_MODE.NEURAL init_params.coordinate_units = sl.UNIT.METER init_params.sdk_verbose = 1 # Open the camera err = zed.open(init_params) if err != sl.ERROR_CODE.SUCCESS: exit(1) ``` -------------------------------- ### Run ZED Object Detection Sample (Linux/Jetson) Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/birds eye viewer/cpp/README.md Command to execute the compiled ZED Object Detection sample from the build directory on Linux or Jetson platforms. ```bash ./ZED_Object_detection_birds_eye_viewer ``` -------------------------------- ### Run ZED Object Detection Sample with Arguments Source: https://github.com/stereolabs/zed-sdk/blob/master/object detection/image viewer/python/README.md Execute the object detection sample specifying an input source (SVO file or IP address) or camera resolution. Arguments include --input_svo_file, --ip_address, and --resolution. ```bash python object_detection_image_viewer.py --input_svo_file --ip_address --resolution ``` -------------------------------- ### Check for New Sensor Data C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/cpp/README.md Demonstrates how to use a TimestampHandler to determine if a specific sensor's data (e.g., IMU) has been updated since the last check. This helps process only new sensor readings. ```C++ TimestampHandler ts; if (ts.isNew(sensors_data.imu)) { // sensors_data.imu contains new data } ``` -------------------------------- ### Saving Mesh to File - ZED SDK - C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 5 - spatial mapping/cpp/README.md Saves the processed mesh object to an external file. The example saves the mesh in the common OBJ format with the filename "mesh.obj", making it accessible for use in other 3D software. ```C++ mesh.save("mesh.obj"); // Save the mesh in an obj file ``` -------------------------------- ### Check for New ZED IMU Data Update in Python Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 7 - sensor data/python/README.md Uses a `TimestampHandler` utility class to determine if the IMU data has been updated since the last check. This is crucial for processing unsynchronized sensor data, as the IMU typically has the highest update rate. ```python # Check if the data has been updated since the last time # IMU is the sensor with the highest rate if ts_handler.is_new(sensors_data.get_imu_data()): ``` -------------------------------- ### Running the Spatial Mapping Program - Bash Source: https://github.com/stereolabs/zed-sdk/blob/master/spatial mapping/spatial mapping/python/README.md Commands to run the ZED SDK spatial mapping sample. The basic command uses the default camera, while the advanced command allows specifying an SVO file, IP address, and resolution. ```bash python spatial_mapping.py ``` ```bash python spatial_mapping.py --input_svo_file --ip_address --resolution ``` -------------------------------- ### Filtering Mesh - ZED SDK - C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 5 - spatial mapping/cpp/README.md Applies a filter to the extracted mesh object using the `filter` member function. The example uses a low-level filter (`sl::MeshFilterParameters::MESH_FILTER::LOW`) to remove unnecessary vertices and faces, optimizing the mesh. ```C++ mesh.filter(sl::MeshFilterParameters::MESH_FILTER::LOW); // Filter the mesh (remove unnecessary vertices and faces) ``` -------------------------------- ### Initialize and Open ZED Camera (Python) Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 5 - spatial mapping/python/README.md Creates a ZED camera object, sets configuration parameters including resolution, coordinate system (right-handed Y-up), and units (meters), and opens the camera. Exits if the camera fails to open. ```python # Create a ZED camera object zed = sl.Camera() # Set configuration parameters init_params = sl.InitParameters() init_params.camera_resolution = sl.RESOLUTION.AUTO # Use HD720 or HD1200 video mode (default fps: 60) init_params.coordinate_system = sl.COORDINATE_SYSTEM.RIGHT_HANDED_Y_UP # Use a right-handed Y-up coordinate system 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): exit(-1) ``` -------------------------------- ### Capture Image, Depth, and Point Cloud - C++ Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 3 - depth sensing/cpp/README.md Captures image, depth map, and point cloud data from the opened ZED camera for 50 frames. It uses the `grab()` function to check for new frames and `retrieveImage()` and `retrieveMeasure()` to get the data. ```C++ // Capture 50 images and depth, then stop int i = 0; sl::Mat image, depth; while (i < 50) { // Grab an image if (zed.grab(runtime_parameters) == ERROR_CODE::SUCCESS) { // A new image is available if grab() returns ERROR_CODE::SUCCESS zed.retrieveImage(image, VIEW::LEFT); // Get the left image zed.retrieveMeasure(depth, MEASURE::DEPTH); // Retrieve depth Mat. Depth is aligned on the left image zed.retrieveMeasure(point_cloud, MEASURE::XYZRGBA); i++; } } ``` -------------------------------- ### Run ZED Depth Sensing Sample (Linux/Jetson) Source: https://github.com/stereolabs/zed-sdk/blob/master/depth sensing/depth sensing/cpp/README.md Command to execute the compiled ZED Depth Sensing sample from the build directory on Linux or Jetson platforms. ```Shell ./ZED_Depth_Sensing ``` -------------------------------- ### Retrieving ZED Camera Image and Timestamp in Python Source: https://github.com/stereolabs/zed-sdk/blob/master/tutorials/tutorial 2 - image capture/python/README.md Retrieves the left camera image into a `sl.Mat` object and gets the timestamp associated with the captured image frame. Prints the image resolution and timestamp in milliseconds. Assumes `grab()` was successful just prior. ```python zed.retrieve_image(image,sl.VIEW.LEFT) # Get the left image timestamp = zed.get_current_timestamp(sl.TIME_REFERENCE.IMAGE) # Get the timestamp of the image print("Image resolution: ", image.get_width(), " x ", image.get_height()," || Image timestamp: ", timestamp.get_milliseconds()) ```