This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Set Properties for Webcam Acquisition

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. Use dot notation to set object-specific or device-specific properties.

Note

The only properties available in MATLAB® Online™ are Name, AvailableResolutions, and Resolution. The default resolution of the webcam is the only resolution supported in MATLAB Online for the R2018a release.

Object-Specific Properties

Use dot notation to set property values for the webcam object. The preview window is dynamic, so if you set a property while previewing your image, you can see the change take effect.

Set properties after creating the webcam object and before acquiring images.

To set an object-specific property, use the object name and property name in dot notation as the first argument, and the value you want to set as the second argument. Property names and values can be character vectors or numerics. This example sets the camera resolution to the value shown for the webcam object cam.

cam.Resolution = '320x240';

You can use these webcam object-specific properties for any webcam.

Object-Specific PropertyDescription
NameA read-only property that specifies the camera name. It is dynamically populated and uses the name that is shown in the output of the webcamlist function. For example, 'Logitech Webcam 250'.
ResolutionSpecifies the video resolution (width-by-height) of the incoming video stream of the current webcam object. Webcams typically support acquiring images at multiple resolutions, and you can change the resolution using this property and the object name. The default that is used is the default resolution of the camera. Use this syntax to change it:

cam.Resolution = '160x120';

AvailableResolutionsDisplays the list of all available resolutions for the selected webcam. Use object name:

cam.AvailableResolutions

ans =

'320x240'

'160x120'

'80x60'

FrameRateA read-only property that displays frames per second for the acquisition. Note that some cameras do not support this property, so you may not see it for your device.

Device-Specific Properties

You can set device-specific properties for your webcam if your device allows programmatic access. These properties vary depending on your device. See the table for a list of the possible properties for a UVC compatible webcam. Your camera may not have all of these. You can set only the properties that your camera supports. To see the properties for your camera, look at the output when you create the webcam object. This example shows the available properties for a Logitech® webcam.

cam = webcam('Logitech')
cam = 

webcam with properties:

                     Name: 'Logitech Webcam 250'
               Resolution: '640x480'
     AvailableResolutions: {1x11 cell}
                 Exposure: -4
                     Gain: 253
               Saturation: 32
             WhiteBalance: 8240
             ExposureMode: 'auto'
                Sharpness: 48
               Brightness: 128
    BacklightCompensation: 1
                 Contrast: 32

Note

You can set device-specific properties only for webcams connected to a Windows® system.

To set a device-specific property, use the object name and property name in dot notation as the first argument, and the value you want to set as the second argument. This example sets the camera brightness to the value shown for the webcam object cam.

cam.Brightness = 150;

This table lists the possible properties of UVC webcams. Your specific camera may not have all of these. Your camera could also have mode properties, which are not listed here. See your camera documentation for the list of properties your device supports.

Possible Device-Specific PropertiesDescription
BacklightCompensationConfigures backlight compensation modes to adjust the camera to capture images dependent on environmental conditions. Values are on and off.
BrightnessIndicates the brightness level, which adjusts for the amount of lighting on the image.
ContrastIndicates contrast level, which adjusts for the difference between brightest and dimmest areas in the image.
ColorEnableSpecifies the color enable setting. Values are on and off.
GainIndicates a multiplier for the RGB color values. The value 0 is normal. Positive values are brighter and negative values are darker.
GammaIndicates gamma measurement.
HueIndicates hue setting, which adjusts the color tint of the image through the red-yellow-blue spectrum.
PowerLineFrequencyReduces flicker caused by the frequency of a power line.
SaturationIndicates saturation level, which adjusts the amount of color in the image.
SharpnessIndicates sharpness level, which adjusts the clarity of the image.
WhiteBalanceIndicates color temperature in degrees Kelvin.
PanControl panning, measured in degrees.
TiltControl tilting, measured in degrees.
RollControl rolling, measured in degrees.
ZoomControl zooming, measured in millimeters.
ExposureSpecify exposure, in log base 2 seconds (1/2^n seconds).
IrisSpecify iris setting, in units of f-stop x 10.
FocusSet focus, as the distance to the optimally focused target, in millimeters.

Note

In desktop versions of MATLAB, webcam support is available through the MATLAB Support Package for USB Webcams. For instructions, see Install the MATLAB Support Package for USB Webcams. Webcams are also supported in MATLAB Online. For more information, see Webcam Support in MATLAB Online.

See Also

Related Topics