Main Content

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.


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.

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:


ans =




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 C925e'
               Resolution: '640x480'
     AvailableResolutions: {'2304x1536'  '2304x1296'  '1920x1080'  '1600x896'  '1280x720'  '960x720'  '1024x576'  '800x600'  '864x480'  '800x448'  '640x480'  '640x360'  '432x240'  '352x288'  '320x240'  '320x180'  '176x144'  '160x120'  '160x90'}
    BacklightCompensation: 0
               Brightness: 128
                 Contrast: 128
                 Exposure: -5
             ExposureMode: 'auto'
                    Focus: 0
                FocusMode: 'auto'
                     Gain: 0
                      Pan: 0
               Saturation: 128
                Sharpness: 128
                     Tilt: 0
             WhiteBalance: 4000
         WhiteBalanceMode: 'auto'
                     Zoom: 100


You can set device-specific properties for webcams connected to either a Windows® or a Linux 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 = 128;

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 to adjust the camera to capture images dependent on environmental conditions. The valid values are specified as a double.
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 to fine-tune the highlight and shadow details in the image.
IrisSpecify iris setting, in units of f-stop x 10.
FocusSet focus, as the distance to the optimally focused target, in millimeters.


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