%% Working with Properties
%
% Copyright 2001-2018 The MathWorks, Inc.

%% Accessing Properties
% This example shows how to access and configure video acquisition properties. 
%
% To access a complete list of an object's properties and their current
% values, use the |get| function with the object.

% Create a video input object.
vidobj = videoinput('dcam', 1);

% List the video input object's properties and their current values.
get(vidobj)

%%

% Access the currently selected video source object
src = getselectedsource(vidobj);

% List the video source object's properties and their current values.
get(src)

%%
% To access a specific property value, use the |get| function with the object
% and property name.

framesPerTriggerValue = vidobj.FramesPerTrigger;

%%
brightnessValue = src.Brightness;

%%
% Alternatively, we can access a specific property value by using the
% dot (.) notation.

framesPerTriggerValue = vidobj.FramesPerTrigger

%%
brightnessValue = src.Brightness

%% Configuring Properties
% Enumerated properties have a defined set of possible values. To list the
% enumerated values of a property, use the |set| function with the object and
% property name.  The property's default value is listed in braces.
set(vidobj, 'LoggingMode')

%%
% To access a complete list of an object's configurable properties, use the
% |set| function with the object.

% List the video input object's configurable properties.
set(vidobj)

%%

% List the video source object's configurable properties.
set(src)

%%
% To configure an object's property value, use the |set| function with the
% object, property name, and property value.

vidobj.TriggerRepeat = 2;
src.Saturation = 100;

%%
% Alternatively, we can configure a specific property value by using the
% dot (.) notation.

vidobj.TriggerRepeat = 2;
src.Saturation = 100;

%% Getting Property Help and Information
% To obtain a property's description, use the |imaqhelp| function with the
% object and property name. |imaqhelp| can also be used for function help.
imaqhelp(vidobj, 'LoggingMode')

%%
% To obtain information on a property's attributes, use the |propinfo| 
% function with the object and property name.
propinfo(vidobj, 'LoggingMode')

%%
% When an image acquisition object is no longer needed, remove it from 
% memory and clear the MATLAB(R) workspace of the associated variable.
delete(vidobj);
clear vidobj
