Main Content

getCameraList

Get a list of available cameras on the NVIDIA hardware

Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.

Description

example

camlist = getCameraList(hwObj) returns a table containing the name, Linux® device number, and available pixel formats for the cameras detected on the NVIDIA® target hardware. The getCameraList function lists cameras connected to both the USB and camera peripheral interfaces (CSI) of the target board.

Examples

collapse all

You can connect from the MATLAB® software to the onboard CSI 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('jetson-board-name','ubuntu','ubuntu');

To find the camera name, use the getCameraList function.

camlist = getCameraList(hwobj)
camlist =

  2×3 table

             Camera Name              Video Device            Available Resolutions        
    ______________________________    _____________    ____________________________________

    "vi-output, ov5693 2-0036"        "/dev/video0"    "[1280 720],[2592 1458],[2592 1944]"
    "Microsoft LifeCam Cinema(TM)"    "/dev/video1"    "(View resolutions)"   

If the function does not list a USB based camera, try reconnecting the USB webcam and run the updatePeripheralInfo function. This function tries to scan the available webcams on the target when there is an addition or deletion.

updatePeripheralInfo(hwobj);

Create a camera object, cam using the name of the camera from the list and a supported resolution. For multiple cameras with the same name, use the 'VideoDevice' argument to identify a camera by its Linux device number. The cam object has the following camera properties.

cam = camera(hwobj,"vi-output, ov5693 2-0036",[2592 1944])
cam = 

  camera with properties:

           Name: 'vi-output, ov5693 2-0036'
      ImageSize: [2592 1944]
    VideoDevice: '/dev/video0'

To capture a frame of image from this camera and display it in MATLAB, use the following commands.

img = snapshot(cam);
figure();
imagesc(img);
drawnow;

To change the resolution of the image capture, you must clear the camera object by using the clear function and then use the camera function to connect to the camera again.

clear cam;
cam = camera(hwobj,"vi-output, ov5693 2-0036",[1280 720]);

Input Arguments

collapse all

Connection to a specific NVIDIA hardware board, specified as a jetson or drive object.

Output Arguments

collapse all

Table containing the list of cameras that the software detects on the target hardware. the table contains the name, Linux device number, and available pixel formats for the cameras. For example,

camlist =

  2×3 table

             Camera Name              Video Device     Pixel Formats        
    ______________________________    _____________    _____________

    "vi-output, ov5693 2-0036"        "/dev/video0"    "BG10"
    "Logitech Webcam C925e"           "/dev/video0"    "YUYV,MJPG" 

When you click on View resolutions, you can view the supported resolutions.

Resolutions: [1280 720],[1280 800],[160 120],[176 144], ...
[320 240],[352 288],[416 240],[424 240],[640 360], ...
[640 480],[800 448],[800 600],[960 544]

For information on accessing data in tables, see Access Data in Tables.

Version History

Introduced in R2019a