record
Record video from camera board or ArduCam Multi Camera Adapter Module camera
Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.
Description
record(
records a video from the camera board to a file on the Raspberry Pi® hardware.mycamera
,filename
,duration
)
record(
records a video from the selected camera on ArduCam Multi Camera
Adapter Module to a file on the Raspberry Pi hardware.aCamObj
,filename
,duration
)
Note
record
is a non-blocking function.
Please wait for the recording to complete before
executing any further statements.
Examples
Capture Images from the Camera Board
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 or 180) HorizontalFlip: 0 VerticalFlip: 0 FrameRate: 30 (2 to 90) 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: "normal" (View available exposure modes) ExposureCompensation: 0 (-10 to 10) AWBMode: "indoor" (View available AWB modes) MeteringMode: "average" (View available metering modes) Effects 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 use the same approach to change the values of other
cameraboard
properties.
Record a 60 second video.
record(mycam,"myvideo.h264",60)
Stop the recording immediately.
stop(mycam)
Copy the video from the board to your computer.
getFile(mypi,"myvideo.h264","C:\MATLAB")
Delete the video file from the hardware to free up space.
deleteFile(mypi,"myvideo.h264")
Record Videos from Cameras on ArduCam Multi Camera Adapter Module
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
Record a 10-second video.
record(aCamObj,"myvideocamA.h264",10); while(aCamObj.Recording) % Wait for the recording to complete end
Select "Camera B"
and record for 10
seconds.
selectCamera(aCamObj,"Camera B"); record(aCamObj,"myvideocamB.h264",10); while(aCamObj.Recording) % Wait for the recording to complete end
Select "Camera C"
and record for 10
seconds.
selectCamera(aCamObj,"Camera C"); record(aCamObj,"myvideocamC.h264",10); while(aCamObj.Recording) % Wait for the recording to complete end
Select "Camera D"
and record for 10
seconds.
selectCamera(aCamObj,"Camera D"); record(aCamObj,"myvideocamD.h264",10);
Stop the recording.
stop(aCamObj)
Copy the videos recorded from all four cameras to your computer.
getFile(mypi,"myvideocamA.h264","C:\MATLAB"); getFile(mypi,"myvideocamB.h264","C:\MATLAB"); getFile(mypi,"myvideocamC.h264","C:\MATLAB"); getFile(mypi,"myvideocamD.h264","C:\MATLAB");
Delete all the video files from the hardware to free up space.
deleteFile(mypi,"myvideocamA.h264"); deleteFile(mypi,"myvideocamB.h264"); deleteFile(mypi,"myvideocamC.h264"); deleteFile(mypi,"myvideocamD.h264");
Input Arguments
mycamera
— Connection to Camera Board
cameraboard
object
Connection to camera board on the Raspberry Pi hardware, specified as a
cameraboard
object.
Example: mycam
aCamObj
— Connection to camera on ArduCam Multi Camera Adapter Module
arducam
object
Connection to a camera on the ArduCam Multi Camera
Adapter Module, specified as an
arducam
object.
Example: myarducam
filename
— Video file name
video file name
Video file name, specified as a string. The only file
extension supported is .h264
.
Example: "myvideo.h264"
Data Types: char
duration
— Duration of recording
duration of recording
Duration of recording, specified in seconds.
Example:
Data Types: double
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
You can also deploy
record
on the Raspberry Pi hardware in MATLAB Online™.Bullseye and Bookworm OS only supports C++ code generation while using
record
function withcameraboard
object.
See Also
raspi
| arducam
| stop
| snapshot
| readFrame
| selectCamera
| getFile
| deleteFile
Topics
External Websites
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)