Documentation Center

  • Trial Software
  • Product Updates

Setting 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 your specific Webcam, if supported by your device. You use the set function to set object-specific property values for the Webcam object, and either the set function or the dot notation to set device-specific properties. These two methods are described in the following two sections.

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

Object-Specific Properties

You can use the get and set functions to display property values or 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 as the first argument, followed by property-value pairs, which can be strings or numerics. This example sets the camera resolution to the value shown for the webcam object cam.

set(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. By default, we will select the default resolution of the camera. Use this syntax to change it:

set(cam, 'Resolution', '160x120');

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

cam.AvailableResolutions

ans =

'320x240'

'160x120'

'80x60'

FrameRateDisplays frames per second for the acquisition.

Device-Specific Properties

You can also set device-specific properties that are specific to your Webcam if your device allows for programmatic access. These properties vary depending on your device. See the table below for a list of the possible properties for a UVC compatible Webcam. Your camera may not have all of these. You can only set properties that your camera allows. See the properties for your camera by looking at the output when you create the webcam object. For example, the following 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 that device-specific properties can only be set 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;

These are the properties that a UVC Webcam can have. Your specific camera may not have all of these. The 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 spectrums.
PowerLineFrequencyOption for reducing 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.
PanCamera control property for panning, in degrees.
TiltCamera control property for tilting, in degrees.
RollCamera control property for rolling, in degrees.
ZoomCamera control property for zooming, in millimeters.
ExposureCamera control property for specifying exposure, in log base 2 seconds (1/2^n seconds).
IrisCamera control property for specifying iris setting, in units of f-stop x 10.
FocusCamera control property for setting focus, as the distance to the optimally focused target, in millimeters.

    Note:   Webcam support is available only through a Hardware Support Package. You must download and install the necessary files using the Support Package Installer. For instructions, see Installing the Webcam Support Package.

Was this topic helpful?