Main Content

snapshot

Capture latest RGB image frame from Camera Board or selected camera on ArduCam Multi Camera Adapter Module

Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.

Description

img = snapshot(mycamera) returns the latest still image frame from the Camera Board in RGB format.

[img,ts] = snapshot(mycamera) returns the latest still image frame from the Camera Board in RGB format in RGB format along with the timestamp of the captured image.

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

[img,ts] = snapshot(wcam) returns the latest still image frame from the USB web camera in RGB format along with the timestamp of the captured image.

img = snapshot(aCamObj) returns the latest still image frame from the selected camera on the ArduCam Multi Camera Adapter Module in the RGB format.

[img,ts] = snapshot(aCamObj) also returns the timestamp of the image.

example

Examples

collapse all

Create a connection from the MATLAB® to the Raspberry Pi® board. If you encounter errors after running the above command, try using additional arguments (as listed in raspi) or refer to Troubleshoot Connecting Issues to Raspberry Pi Hardware.

mypi = raspi;

Create a connection, mycam, from the MATLAB software to the camera board on the Raspberry Pi hardware, and set the image resolution. The connection displays the camera board properties.

mycam = cameraboard(mypi,"Resolution","1280x720")
mycam = 

Cameraboard with Properties:

                    Name: Camera Board   
              Resolution: "1280x720"       (View available resolutions)
                 Quality: 10              (1 to 100)
                Rotation: 0               (0, 90, 180 or 270)
          HorizontalFlip: 0              
            VerticalFlip: 0              
               FrameRate: 30              (2 to 30)
               Recording: 0              

   Picture Settings
              Brightness: 50              (0 to 100)
                Contrast: 0               (-100 to 100)
              Saturation: 0               (-100 to 100)
               Sharpness: 0               (-100 to 100)

   Exposure and AWB
            ExposureMode: "auto"          (View available exposure modes)
    ExposureCompensation: 0               (-10 to 10)
                 AWBMode: "auto"          (View available AWB modes)
            MeteringMode: "average"       (View available metering modes)

   Effects
             ImageEffect: "none"          (View available image effects)
      VideoStabilization: "off"          
                     ROI: [0.00 0.00 1.00 1.00] (0.0 to 1.0 [top, left, width, height])

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

for ii = 1:10
img = snapshot(mycam);
    imagesc(img)
    drawnow
end

Each of the 10 snapshots is the latest image captured by the camera.

If the image is upside down, change its orientation.

mycam.Rotation = 180

You can connect from the MATLAB software to the USB web camera connected to Raspberry Pi board and take a photograph.

Create a connection from the MATLAB to the Raspberry Pi board. If you encounter errors after running the above command, try using additional arguments (as listed in raspi) or refer to Troubleshoot Connecting Issues to Raspberry Pi Hardware.

mypi = raspi;

Create a connection from the MATLAB software to the Raspberry Pi hardware.

mypi = raspi;

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

wcam = webcam(mypi)
wcam = 

  webcam with properties:

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

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

for ii = 1:10
    img = snapshot(wcam);
    imagesc(img)
    drawnow
end

Create a connection from the MATLAB to the Raspberry Pi board. If you encounter errors after running the above command, try using additional arguments (as listed in raspi) or refer to Troubleshoot Connecting Issues to Raspberry Pi Hardware.

mypi = raspi;

Create a connection from the MATLAB to the Raspberry Pi board. If you encounter errors after running the above command, try using additional arguments (as listed in raspi) or refer to Troubleshoot Connecting Issues to Raspberry Pi Hardware.

mypi = raspi;

Create a connection from MATLAB to the ArduCam module attached to the Raspberry Pi board. Set the image resolution. The connection displays the ArduCam properties.

aCamObj = arducam(mypi,"MultiCamAdapter","Resolution","1280x720")
aCamObj = 

ArduCam with Properties:

              ModuleName: "Multi Camera Adapter"  
          SelectedCamera: "Camera A" 
              Resolution: "1280x720"       (View available resolutions)
               Recording: 0              

Capture image from "Camera A".

imgA = snapshot(aCamObj);

Capture an image from "Camera B".

selectCamera(aCamObj,"Camera B")
imgB = snapshot(aCamObj);

Capture an image from "Camera C".

selectCamera(aCamObj,"Camera C")
imgC = snapshot(aCamObj);

Capture an image from "Camera D".

selectCamera(aCamObj,"Camera D")
imgD = snapshot(aCamObj);

Display a montage containing all the images.

montage({imgA,imgB,imgC,imgD})

Input Arguments

collapse all

Connection to camera board on the Raspberry Pi hardware, specified as a cameraboard object.

Example: mycam

Connection to a USB Webcam, specified as a webcam object.

Use the webcam function to create this connection.

Example: mycam

Connection to a camera on the ArduCam Multi Camera Adapter Module, specified as an arducam object.

Example: myarducam

Output Arguments

collapse all

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

Timestamp of the RGB images captured by camera.

Extended Capabilities