Main Content

网络摄像头图像采集

从网络摄像头采集图像

创建一个 webcam 对象,然后使用 snapshot 函数从网络摄像头采集图像。您可以采集单个图像,也可以设置循环来采集多个图像。使用 preview 函数测试摄像头流。

如果您的摄像头允许编程访问,则还可以设置设备特定的属性,如分辨率和亮度。这些属性因您的设备而异。要了解摄像头的属性,请查看创建 webcam 对象时的输出。有关设置属性的信息,请参阅Set Properties for Webcam Acquisition

函数

webcamlistList of webcams connected to your system
webcamConnection to a webcam
previewPreview live video data from webcam
snapshotAcquire single image frame from a webcam
closePreviewClose webcam preview window
propertyInfo Retrieve metadata for webcam properties (自 R2024a 起)

实时编辑器任务

获取网络摄像头图像Acquire snapshot from webcam in the Live Editor (自 R2020b 起)

主题

  • Webcam Acquisition Overview

    You can use MATLAB® webcam support to bring live images from any USB Video Class (UVC) compliant webcam into MATLAB. Supported platforms are listed here.

  • Acquire Images from Webcams

    To acquire images from a webcam, you first create a webcam object using the webcam function. This example describes the typical workflow for acquiring images from webcams and bringing them into MATLAB.

  • Using Acquire Webcam Image Live Editor Task from Hardware Manager

    You can use MATLAB Hardware Manager to detect your webcam and run the Acquire Webcam Image Live Editor task to interactively connect to your webcam, set its properties based on the live video, and capture images.

  • Acquire Webcam Images in a Loop

    The snapshot function acquires a single image from a webcam. If you want to acquire images in a loop, you can do that with some extra programming.

  • Acquiring a Single Image in a Loop

    This example shows how to use the snapshot function to acquire live images from USB webcams.

  • Logging Video to Disk

    This example shows how to use the snapshot function to acquire live images and log the video to disk.

  • Set Properties for Webcam Acquisition

    You can set object-specific properties for the webcam object to use with any webcam. You can also set device-specific properties for a specific webcam, if supported by your device.