Skip to content
  • By Deployment
    Offroad AutonomyLogistics AutomationSmart Infrastructure
    Integrations
    Partner Ecosystem
  • ZED X One
    LearnOrder
    ZED X Series
    LearnOrder
    ZED Series
    LearnOrder
    ZED Box
    LearnOrder
  • Software
  • Get Started
    OverviewSDK DownloadsZED X Drivers
    Resources
    DocumentationAPI ReferenceCode SamplesIntegrationsSupportCommunityGitHub
  • Company
    About UsOur TechnologyNewsCareersResources
  • Store
  • StoreBar_ZEDX_family_front
    Cameras
    Embedded PC
    Accessories
    Kits
    Shop All
    • There are currently no items in your bag.
      San Francisco | USA New York | USA Paris | France

        Products

      1. ZED X One
      2. ZED X Family
      3. ZED 2 Family
      4. ZED Box
      5. Terra AI
      6. ZED SDK

        Store

      1. ZED X
      2. ZED X Mini
      3. ZED X One
      4. ZED 2i
      5. ZED Mini
      6. ZED Box
      7. Bundles
      8. Accessories

        Solutions

      1. Offroad Autonomy
      2. Logistics Automation
      3. Smart Infrastructure

        Company

      1. About
      2. News
      3. Careers
      4. Partner Ecosystem

        Developers

      1. ZED SDK
      2. ZED X Drivers
      3. Documentation
      4. API Reference
      5. Community
      6. Tutorials
      7. Support
      8. GitHub

        Contact

      1. Email
      2. Tracking
      3. YouTube
      4. LinkedIn
      support@stereolabs.com
      © 2025 Stereolabs Inc. All Rights Reserved.
      NewsTutorials
      Jul 3, 2015.

      Using the ZED Stereo Camera with MATLAB

      This tutorial will explain how to use the ZED 3D camera with MATLAB.

      Note: This is for ZED SDK 1.2 only. Please see the latest MATLAB guide here.

      Introduction

      This tutorial will explain how to use the ZED 3D camera with MATLAB. You will learn how to capture images from the ZED and adjust camera parameters in MATLAB. Note that viewing and manipulating depth map data is not covered in this tutorial.

      NOTE : when using directly the ZED camera (as a webcam), the images are not rectified.

      For capturing rectified images and depth maps in MATLAB with the ZED, please refer to “How to use the ZED SDK with MATLAB".

      Prerequisites

      You must have a MathWorks account (free) and MATLAB installed on your system. Of course, the ZED SDK has to be installed as well. Even if you’re new to MATLAB, this tutorial should be easy to follow.

      Getting Started

      Open MATLAB and in the Command Window, enter this command:

      >> webcamlist

      You should encounter an error if you’ve never used MATLAB with a webcam before:

      Error using webcamlist (line 20). MATLAB Support Package for Webcams has not been installed. Open Support Package Installer to install the Webcam Support Package.

      If you’ve encountered the error, click the link in the error log. A dialog window appears:

      Click Next > and Log In. MATLAB will ask for your MathWorks account credential. Log in.

      Then, read and accept the MathWorks auxiliary software license agreement. Click Next > and Install. This might take a while (around 10-15 seconds).

      When the setup process is finished, uncheck the “Show support package examples” check box and click on Finish.

      Now, in the MATLAB Command Window, re-enter:

      >> webcamlist

      and that should give you:

      ans ='ZED'

      Perfect! The ZED camera is properly detected. 🙂

      Now grab an instance of the ZED camera with the following command line:

      >> cam = webcam

      and the cam variable will return the current parameters of the camera:

      cam =
      
      webcam with properties:
      
      Name: 'ZED'
      Resolution: '2560x720'
      AvailableResolutions: {1x4 cell}
      WhiteBalanceMode: 'auto'
      Sharpness: 4
      Saturation: 5
      Hue: 0
      Gain: 4
      WhiteBalance: 4600
      Contrast: 4
      Brightness: 4
      Exposure: 2
      ExposureMode: 'auto'

      Note that you can check whether the ZED camera works properly by using this command:

      >> preview(cam)

      You can now grab ZED frames with:

      >> img = snapshot(cam);

      You’ve just grabbed your first ZED frame in MATLAB. If you need real-time video capture, set up a loop. Fairly straightforward, isn’t it ? 😛

      The ZED Camera will stay active as long as you keep the cam variable in MATLAB’s environment. To turn off the ZED camera, use this command:

      >> clear cam

      Here is a snippet that demonstrate how to open the ZED , grab the side by side images and split them:

      clear all;close all;clc;
      
      % get access to the ZED camera
      zed = webcam('ZED')
      % set the desired resolution
      zed.Resolution = zed.AvailableResolutions{1};
      % get the image size
      [height width channels] = size(snapshot(zed))
      
      % Create Figure and wait for keyboard interruption to quit
      f = figure('keypressfcn','close','windowstyle','modal');
      ok = 1;
      % loop over frames
      while ok
          %capture the current image
          img = snapshot(zed);
      
          % split the side by side image image into two images
          im_Left = img(:, 1 : width/2, :);
          im_Right = img(:, width/2 +1: width, :);
      
          % display the left and right images
          subplot(1,2,1);
          imshow(im_Left);
          title('Image Left');
          subplot(1,2,2);
          imshow(im_Right);
          title('Image Right');
      
          drawnow; %this checks for interrupts
          ok = ishandle(f); %does the figure still exist
      end
      
      % close the camera instance
      clear cam