Main Content

Acquire Webcam Image

Acquire snapshot from webcam in the Live Editor

Since R2020b

Description

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.

Acquire Webcam Image task in Live Editor

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 camera, webcam, snapshot, preview and so on. Select Acquire Webcam Image from the suggested command completions.

Note

You can also use MATLAB Hardware Manager to run Acquire Webcam Image task, see Using Acquire Webcam Image Live Editor Task from Hardware Manager.

Parameters

expand all

Note

You can set properties for webcams connected to either a Windows® or a Linux system.

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.

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™.

Select Live preview to view the incoming video stream from the webcam. The width and height of the preview depends on the chosen resolution.

Image Properties

Adjust the amount of light in the image.

Adjust the difference between the darkest and brightest areas in the image.

Adjust the exposure to fine-tune the highlight and shadow details in the image. Clear the Auto check box to adjust the setting manually.

Adjust the gamma measurement of the image.

Adjust the color tint of the image through the red-yellow-blue spectrum.

Adjust the amount of color in the image.

Adjust the sharpness to adjust image clarity.

Adjust the white balance based on lighting conditions. Clear the Auto check box to adjust the setting manually.

Device Properties

Adjust the backlight compensation to capture images per the environmental conditions.

Adjust the focus to enhance the image clarity.

Adjust the gain to brighten the image.

Adjust the viewing angle of the camera in the horizontal plane.

Adjust the viewing angle to rotate the image.

Adjust the viewing angle of the camera in the vertical plane.

Adjust the zoom of the camera.

Display results

Select Show image to view the captured image.

Version History

Introduced in R2020b