Main Content

Use Raspberry Pi Web Camera to Capture Images

This example shows how to create a connection to the web camera and capture still images.

Connect the Raspberry Pi® board to your host computer.


If you have not previously configured your Raspberry Pi board, see Hardware Setup.

Create a connection to the Raspberry Pi hardware using raspi.

mypi = raspi

Create a connection to the webcam and assign the connection to a handle, mycam. You can optionally override the default Resolution property, shown here.

mycam = webcam(mypi)
mycam = 

  webcam with properties:

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

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

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

See Also