"Camera" (General OS-Supported Camera)
"Camera" provides a general interface for communicating with imaging devices, such as USB webcams, using operating system-supported drivers.
Imaging devices can be built-in or connected via USB, firewire, etc.
Available cameras can be found using $ImagingDevices or FindDevices.
Device Discovery
- FindDevices["Camera"] lists the camera devices connected to your system.
- $ImagingDevices gives a list of names of available cameras.
Opening the Device
- $ImagingDevices can be used to obtain a list of camera names.
- $DefaultImagingDevice returns the name of the default camera.
- $ImagingDevice gives the name of the imaging device used to capture images.
- Evaluating CurrentImage and ImageCapture automatically opens the appropriate camera. Devices can be used to obtain the associated DeviceObject.
DeviceOpen["Camera"]
opens the default camera.
DeviceOpen["Camera",name]
opens the camera with the specified name.
DeviceOpen["Camera",opts}]
opens the default camera using the specified options.
DeviceOpen["Camera",{name,opts}]
opens the camera with the specified name using the specified options.
Configuring the Device
- DeviceConfigure can be used to set camera properties such as "FrameRate" and "RasterSize".
DeviceConfigure[dev,p->v]
sets property p to value v.
Device Properties
- The following native properties are available:
-
"DeviceName" Automatic name of the camera "FrameRate" Automatic rate at which frames are collected "RasterSize" Automatic camera resolution for capturing frames "SupportedCameraResolutions" Automatic image resolutions supported by the camera "Timeout" Automatic idle time until camera is automatically closed - The Automatic setting for "FrameRate" is 12 frames per second.
- Possible values for "RasterSize" are of the form {width,height}.
- The Automatic setting for "RasterSize" is {320,240}.
- A connected camera that is left idle for the period specified by the "Timeout" option will be automatically disconnected. The Automatic setting for "Timeout" corresponds to 120 s. "Timeout" can also be set to Infinity.
Reading Data
- Wolfram Language functions such as DeviceReadList and DeviceReadLatest are also supported.
- CurrentImage can be used to obtain the latest image captured.
DeviceRead[dev]
reads a single frame from the camera, returning an Image object.
DeviceReadTimeSeries[dev]
reads a sequence of frames for t seconds at time interval dt, returning a TimeSeries.
Closing and Releasing Resources
DeviceClose[dev]
stops capture, closes the camera connection, and frees related resources.
Examples
Basic Examples (6)
Open the default camera using default settings:
Automatically open the default camera using CurrentImage:
Use the Devices function to find the associated DeviceObject:
Close the camera with DeviceClose:
Open the specified camera with parameters:
Change camera settings by setting device properties:
Change camera settings with DeviceConfigure:
Use DeviceRead to capture an image from an opened camera:
Capture a TimeSeries of images: