Main Content

arducam

Connect to ArduCam Multi Camera Adapter Module

Since R2023b

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

    Description

    This object connects MATLAB® to the cameras connected to ArduCam Multi Camera Adapter Module on the Raspberry Pi® hardware. To interact with the cameras on the module, use the Object Functions.

    MATLAB Support Package for Raspberry Pi Hardware currently supports ArduCam Multi Camera Adapter Module V2.2. You can use the V2.2 module to connect up to four cameras to a single Raspberry Pi board. This module supports sequential acquisition from all four cameras. MATLAB Support Package for Raspberry Pi Hardware supports 5MP OV5647 cameras, and these cameras are compatible with ArduCam Multi Camera Adapter Module.

    Creation

    Description

    aCamObj = arducam(mypi,moduleName) connects MATLAB to the module attached to the Raspberry Pi board. The moduleName argument sets the moduleName property.

    aCamObj = arducam(mypi,moduleName,Name=Value) sets optional name-value arguments. You can use the name-value arguments to control image resolution and select a camera.

    Input Arguments

    expand all

    Connection to the Raspberry Pi hardware board, specified as a raspi object.

    Properties

    expand all

    This property is read-only.

    Name of the ArduCam module, specified as a string.

    Example: "Multi Camera Adapter"

    Data Types: string

    Image dimensions, specified as a string representing the height and width of the image in pixels.

    Example: "1024x768"

    Data Types: string

    This property is read-only.

    Name of the camera that you want to select, specified as "Camera A", "Camera B", "Camera C", or "Camera D".

    Example: "Camera A"

    Data Types: string

    This property is read-only.

    Recording status of selected camera, specified as false or true.

    Example: false

    Data Types: logical

    Object Functions

    recordRecord video from camera board or ArduCam Multi Camera Adapter Module camera
    stopStop recording from camera board or selected camera on ArduCam Multi Camera Adapter Module
    snapshotCapture latest RGB image frame from Camera Board or selected camera on ArduCam Multi Camera Adapter Module
    readFrameReturn oldest image frame from board, web, or ArduCam module camera
    selectCamera Select camera on ArduCam Multi Camera Module

    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 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 and display a snapshot on your computer.

    img = snapshot(aCamObj);
    imagesc(img);

    Obtain four images with corresponding timestamps. Return the oldest image first.

    [imagedata,ts] = readFrame(aCamObj,4);
    

    Record a 60-second video.

    record(aCamObj,"myvideo.h264",60);

    Stop the recording.

    stop(aCamObj);

    Copy the video from the camera to your computer.

    getFile(mypi,"myvideo.h264","C:\MATLAB");

    Delete the video file from the hardware to free up space.

    deleteFile(mypi,"myvideo.h264");

    Extended Capabilities

    Version History

    Introduced in R2023b