Main Content


Connection to USB web camera


This object represents a connection from the MATLAB® software to a web camera attached to the NVIDIA® DRIVE or Jetson hardware. To create this object, use the webcam function. To configure the web camera settings, use the object properties listed in Properties. To interact with the web camera, use this object with the functions listed in Object Functions.




expand all

This property is read-only.

Image dimensions, specified as a string.

Example: '640x480'

Data Types: char

This property is read-only.

Image dimensions, specified as a cell array of strings.

When you create the webcam object, you can specify this value.

Example: {'320x240' '640x480'}

Data Types: char

Object Functions

snapshotCapture RGB image from Camera


collapse all

You can connect from the MATLAB software to a USB camera connected to an NVIDIA platform and capture images from this camera.

Create a live hardware connection from the MATLAB software to the NVIDIA hardware by using the jetson function. To create a live hardware connection object, provide the host name or IP address, user name, and password of the target board. For example:

hwobj = jetson('','ubuntu','ubuntu');

To find the web camera name, check the webcamlist property of the hwobj object.

ans =

  1×1 cell array

    {'Microsoft® LifeCam Cinema(TM)'}

If this property is empty, then try reconnecting the USB webcam and run the following command. This command tries to scan the available webcams on the target when there is a addition or deletion.


Create a webcam object, wcam using the name or the index number of the webcam list. If no webcam name or the index is specified, then it uses the default webcam. The wcam object has the following camera properties.

wcam = webcam(hwobj)
wcam = 

  webcam with properties:

                    Name: 'Microsoft® LifeCam Cinema(TM)'
              Resolution: '320x240'
    AvailableResolutions: {1×12 cell}

To display the images captured from webcam in MATLAB, use the following commands.

img = snapshot(wcam);

To change the resolution of the image capture, use the following command.

clear wcam;
wcam = webcam(hwobj,1,[1280 800])

You can use the AvailableResolutions property of the wcam object to get a cell array of the available resolutions for your camera.

Import and display a sequence of 50 snapshots on your host computer.

for ii = 1:50
    img = snapshot(wcam);

Introduced in R2018b