Acquire Webcam Image
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.
Open the Task
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
previewand so on. Select
Acquire Webcam Imagefrom the suggested command completions.
- Detect and Plot Water Level Change with USB Webcam Live Editor Task
- Add Interactive Tasks to a Live Script
You can set properties for webcams connected to either a Windows® or a Linux system.
Webcam — Webcam to acquire snapshot
Choose 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 webcam
Choose 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 webcam
Select 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 brightness
Adjust the amount of light in the image.
Contrast — Adjust image contrast
Adjust the difference between the darkest and brightest areas in the image.
Exposure — Adjust image exposure
on (default) | off
Adjust 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 gamma
Adjust the gamma measurement of the image.
Hue — Adjust image hue
Adjust 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 sharpness
Adjust the sharpness to adjust image clarity.
White balance — Adjust image white balance
on (default) | off
Adjust the white balance based on lighting conditions. Clear the Auto check box to adjust the setting manually.
Backlight Compensation — Adjust camera backlight compensation
Adjust the backlight compensation to capture images per the environmental conditions.
Focus — Adjust camera focus
Adjust the focus to enhance the image clarity.
Gain — Adjust camera gain
Adjust the gain to brighten the image.
Pan — Adjust camera pan
Adjust the viewing angle of the camera in the horizontal plane.
Roll — Adjust camera roll
Adjust the viewing angle to rotate the image.
Tilt — Adjust camera tilt
Adjust the viewing angle of the camera in the vertical plane.
Zoom — Adjust camera zoom
Adjust the zoom of the camera.
Show image — View captured image
Select Show image to view the captured image.
Introduced in R2020b