videoinput

Create video input object

Syntax

obj = videoinput(adaptorname)
obj = videoinput(adaptorname,deviceID)
obj = videoinput(adaptorname,deviceID,format)
obj = videoinput(adaptorname,deviceID,format,P1,V1,...)

Description

obj = videoinput(adaptorname) constructs the video input object obj. A video input object represents the connection between MATLAB® and a particular image acquisition device. adaptorname is a character vector that specifies the name of the adaptor used to communicate with the device. Use the imaqhwinfo function to determine the adaptors available on your system.

obj = videoinput(adaptorname,deviceID) constructs a video input object obj, where deviceID is a numeric scalar value that identifies a particular device available through the specified adaptor, adaptorname. Use the imaqhwinfo(adaptorname) syntax to determine the devices available through the specified adaptor. If deviceID is not specified, the first available device ID is used. As a convenience, a device's name can be used in place of the deviceID. If multiple devices have the same name, the first available device is used.

obj = videoinput(adaptorname,deviceID,format) constructs a video input object, where format is a character vector that specifies a particular video format supported by the device or the full path of a device configuration file (also known as a camera file).

To get a list of the formats supported by a particular device, view the DeviceInfo structure for the device that is returned by the imaqhwinfo function. Each DeviceInfo structure contains a SupportedFormats field. If format is not specified, the device's default format is used.

When the video input object is created, its VideoFormat field contains the format name or device configuration file that you specify.

obj = videoinput(adaptorname,deviceID,format,P1,V1,...) creates a video input object obj with the specified property values. If an invalid property name or property value is specified, the object is not created.

The property name and property value pairs can be in any format supported by the set function, i.e., parameter/value character vector pairs, structures, or parameter/value cell array pairs.

To view a complete listing of video input object functions and properties, use the imaqhelp function.

imaqhelp videoinput

In the documentation, see Image Acquisition Toolbox Properties for links to the property reference pages.

Examples

Construct a video input object.

obj = videoinput('matrox', 1);

Select the source to use for acquisition.

obj.SelectedSourceName = 'input1'

View the properties for the selected video source object.

src_obj = getselectedsource(obj);
get(src_obj)

Preview a stream of image frames.

preview(obj);

Acquire and display a single image frame.

frame = getsnapshot(obj);
image(frame);

Remove video input object from memory.

delete(obj);

Tips

The toolbox chooses the first available video source object as the selected source and specifies this video source object's name in the object's SelectedSourceName property. Use getselectedsource(obj) to access the video source object that is used for acquisition.

Note

To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.

Introduced before R2006a