Main Content


Capture RGB image from web camera



img = snapshot(wcam) returns a still image from the web camera in RGB format.


collapse all

You can connect to the web camera from the MATLAB® software and take a photograph.

Create a connection from the MATLAB software to the BeagleBone® Black hardware.

bbb = beaglebone

Create a connection, wcam, from the MATLAB software to the web camera, and set the image resolution. The connection displays the web camera properties.

wcam = webcam(bbb)
wcam = 

  webcam with properties:

                    Name: '/dev/video0'
              Resolution: '320x240'
    AvailableResolutions: {'320x240'  '640x480'}

Import and display a sequence of 10 snapshots on your computer.

for ii = 1:10
img = snapshot(wcam)

Input Arguments

collapse all

Connection to a web camera, specified as a camera object.

Use the webcam function to create this connection.

Example: mycam

Output Arguments

collapse all

RGB image, returned as an n-by-n-by-3 matrix of values.

Version History

Introduced in R2015a