Documentation Center

  • Trial Software
  • Product Updates

getFile

Transfer file from Raspberry Pi hardware to host computer

Syntax

  • getFile(mypi,source)
  • getFile(mypi,source,destination)

Description

getFile(mypi,source) copies the specified file from the Raspberry Pi™ hardware to the MATLAB® Current Folder. Wildcards are supported.

getFile(mypi,source,destination) copies the file to a destination path and optional file name.

Examples

expand all

Download a File to the MATLAB Current Folder

You can copy a file, such as .profile, from the Raspberry Pi hardware to the MATLAB Current Folder on your host computer.

getFile(mypi,'/home/pi/.profile')

Download Multiple Files to a Specific Folder on Your Host Computer

You can use a wildcard to copy any matching file or files from the Raspberry Pi hardware to your host computer. You can specify the path of a destination folder. The folder must already exist.

getFile(mypi,'/home/pi/*.png','C:\Users\myusername\Desktop')

Use the Camera Board

You can create a connection to the Camera Board, take a photograph, and record video.

Create a connection to the Raspberry Pi board.

mypi = raspi;

Create a connection to the Camera Board while changing the resolution, and assign that connection to a handle, mycam. The handle 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])

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

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

If the image is upside down, change the orientation of the image.

mycam.Rotation = 180;

You can use the same approach to change the values of many mycamera properties listed in the "Name-Value Pair Arguments" for cameraboard.

Record a 60 second video.

record(mycam,'myvideo.mp4',60)

Stop recording before the 60 seconds have elapsed.

stop(mycam)

Copy the video from the board to your host computer.

getFile(mypi,'myvideo.mp4','C:\MATLAB')

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

deleteFile(mypi,'myvideo.mp4')

Input Arguments

expand all

mypi — Connection to specific boardhandle

Connection to a specific board, specified as a handle.

Use raspi to create this connection.

Example: mypi

source — Path and name of file on Raspberry Pi hardwarepath and name file name

Path and file name on the Raspberry Pi hardware, specified as a string. You can use either the absolute path from the root folder, the relative path from the present working folder. Use Linux® path and file naming conventions. The default path is /home/pi/.

Example: '.profile'

Example: '/home/pi/.profile'

Example: '/home/pi/.pro*'

Data Types: char

destination — Path and name of file on host computerMATLAB Current Folder (default) | destination path

Path and name of file on host computer, specified as a string. If not specified, getFile uses the MATLAB Current Folder and the current file name. Use naming conventions of the operating system on the host computer. This function does not create new folders. Folder names in the path must already exist. Optional.

Example: 'C:\Users\myusername\Desktop'

Data Types: char

See Also

| | | |

Was this topic helpful?