Acquire snapshot from webcam in the Live Editor
The Acquire Webcam Image task enables you to interactively connect to a webcam, set properties based on the live video, and capture images. The task automatically generates MATLAB® code for your live script. For more information about Live Editor tasks, see Add Interactive Tasks to a Live Script.
To get started with the Acquire Webcam Image task, select the webcam that is connected to your computer. The task gives you controls that help you set webcam resolution values and other properties:
Image-specific properties — Set the values for webcam brightness, contrast, white balance, and so on.
Device-specific properties — Set the values of webcam backlight compensation, tilt, zoom, and so on.
The default settings of the image and device properties are based on the selected webcam. When you adjust a property, the task updates the corresponding property and captures an image. You can view the property change in real time in the live video preview.
To add the Acquire Webcam Image task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Acquire Webcam Image.
In a code block in your script, type a relevant keyword, such as
camera
, webcam
, snapshot
,
preview
and so on. Select Acquire Webcam
Image
from the suggested command completions.
Note
You can set properties for webcams connected to either a Windows® or a Linux system.
Webcam
— Webcam to acquire snapshotChoose from the list of available webcams connected to your computer. The image and device properties available in the Acquire Webcam Image task depend on the webcam.
Resolution
— Resolution of incoming video stream from webcamChoose the resolution (width-by-height) to acquire the snapshot. The list of available resolutions depends on the selected webcam. The Acquire Webcam Image task currently supports only the default resolution in MATLAB Online™.
Live preview
— Preview incoming video stream from webcamSelect Live preview to view the incoming video stream from the webcam. The width and height of the preview depends on the chosen resolution.
Brightness
— Adjust image brightnessAdjust the amount of light in the image.
Contrast
— Adjust image contrastAdjust the difference between the darkest and brightest areas in the image.
Exposure
— Adjust image exposureAdjust the exposure to fine-tune the highlight and shadow details in the image. Clear the Auto check box to adjust the setting manually.
Gamma
— Adjust image gammaAdjust the gamma measurement of the image.
Hue
— Adjust image hueAdjust the color tint of the image through the red-yellow-blue spectrum.
Saturation
— Adjust image saturation Adjust the amount of color in the image.
Sharpness
— Adjust image sharpnessAdjust the sharpness to adjust image clarity.
White balance
— Adjust image white balanceAdjust the white balance based on lighting conditions. Clear the Auto check box to adjust the setting manually.
Backlight Compensation
— Adjust camera backlight compensationAdjust the backlight compensation to capture images per the environmental conditions.
Focus
— Adjust camera focusAdjust the focus to enhance the image clarity.
Gain
— Adjust camera gainAdjust the gain to brighten the image.
Pan
— Adjust camera panAdjust the viewing angle of the camera in the horizontal plane.
Roll
— Adjust camera rollAdjust the viewing angle to rotate the image.
Tilt
— Adjust camera tiltAdjust the viewing angle of the camera in the vertical plane.
Zoom
— Adjust camera zoomAdjust the zoom of the camera.
Show image
— View captured imageSelect Show image to view the captured image.