This example shows how to access and connect to a video device.
A video input object represents the connection between MATLAB® and an image acquisition device. To create a video input object, use the VIDEOINPUT function and indicate what device the object is to be associated with.
% Access an image acquisition device. vidobj = videoinput('dt', 1, 'RS170')
Summary of Video Input Object Using 'Dt313xK'. Acquisition Source(s): VID0, VID1, and VID2 are available. Acquisition Parameters: 'VID0' is the current selected source. 10 frames per trigger using the selected source. 'RS170' video data to be logged upon START. Grabbing first of every 1 frame(s). Log data to 'memory' on trigger. Trigger Parameters: 1 'immediate' trigger(s) on START. Status: Waiting for START. 0 frames acquired since starting. 0 frames available for GETDATA.
A video source object represents a collection of one or more physical data sources that are treated as a single entity. For example, one video source object could represent the three physical connections of an RGB source (red, green, and blue).
The Source property of a video input object provides an array of the device's available video source objects.
% Access the device's video sources that can be used for acquisition. sources = vidobj.Source
Display Summary for Video Source Object Array: Index: SourceName: Selected: 1 'VID0' 'on' 2 'VID1' 'off' 3 'VID2' 'off'
Name Size Bytes Class sources 1x3 872 videosource object Grand total is 47 elements using 872 bytes
A video source object can be selected for acquisition by specifying its name.
vidobj.SelectedSourceName = 'VID2') % Notice that the corresponding video source has been selected. sources
Display Summary for Video Source Object Array: Index: SourceName: Selected: 1 'VID0' 'off' 2 'VID1' 'off' 3 'VID2' 'on'
To obtain the video source object that is currently selected, use the GETSELECTEDSOURCE function.
selectedsrc = getselectedsource(vidobj)
Display Summary for Video Source Object: Index: SourceName: Selected: 1 'VID2' 'on'
Each video source object provides a list of general and device specific properties.
% List the video source object's properties and their current values. get(selectedsrc)
General Settings: Parent = [1x1 videoinput] Selected = on SourceName = VID2 Tag = Type = videosource UserData =  Device Specific Properties: FirstActiveLine = 21 FirstActivePixel = 140 FrameType = interlacedEvenFieldFirst StrobeOutput = off StrobeOutputDuration = 3.3ms StrobeOutputPolarity = activeHigh StrobeOutputType = afterFrame SyncInput = composite TriggerTimeout = 0
Note: Each video source object maintains its own property configuration. Modifying the selected video source is equivalent to selecting a new video source configuration.
% Once the video input object is no longer needed, delete % it and clear it from the workspace. delete(vidobj) clear vidobj
See also IMAQHWINFO, VIDEOINPUT, IMAQDEVICE/GETSELECTEDSOURCE, IMAQHELP, IMAQDEVICE/GET, IMAQDEVICE/PROPINFO.