Main Content

Getting Hardware Information

Getting Hardware Information

To connect to an image acquisition device from within MATLAB®, you must create a video input object. This object represents the connection between MATLAB and the device. You can use object properties to control various aspects of the acquisition. Before you can create the object, you need several pieces of information about the device that you want to connect to.

To access an image acquisition device, the toolbox needs several pieces of information:

  • The name of the adaptor the toolbox uses to connect to the image acquisition device

  • The device ID of the device you want to access

  • The video format of the video stream or, optionally, a device configuration file (camera file)

You use the imaqhwinfo function to retrieve this information, as described in the following subsections.

Note

When using imaqhwinfo to get information about a device, especially devices that use a Video for Windows® (VFW) driver, you might encounter dialog boxes reporting an assertion error. Make sure that the software drivers are installed correctly and that the acquisition device is connected to the computer.

Determining the Device Adaptor Name

An adaptor is the software the toolbox uses to communicate with an image acquisition device via its device driver. The toolbox includes adaptors for some vendors of image acquisition equipment and for particular classes of image acquisition devices. For the latest information about supported hardware, visit the Image Acquisition Toolbox™ product page at the MathWorks® Web site (www.mathworks.com/products/image-acquisition).

To determine which adaptors are available on your system, call the imaqhwinfo function. The imaqhwinfo function returns information about the toolbox software and lists the adaptors available on the system in the InstalledAdaptors field. In this example, there are two adaptors available on the system.

imaqhwinfo
ans = 

    InstalledAdaptors: {'matrox'  'winvideo'}
        MATLABVersion: '7.4 (R2007a)'
          ToolboxName: 'Image Acquisition Toolbox'
       ToolboxVersion: '2.1 (R2007a)'

Note

While every adaptor supported by the Image Acquisition Toolbox software is installed with the toolbox, imaqhwinfo lists only adaptors in the InstalledAdaptors field that are loadable. That is, the device drivers required by the vendor are installed on the system. Note, however, that inclusion in the InstalledAdaptors field does not necessarily mean that an adaptor is connected to a device.

Determining the Device ID

The adaptor assigns a unique number to each device with which it can communicate. The adaptor assigns the first device it detects the device ID 1, the second it detects the device ID 2, and so on.

To find the device ID of a particular image acquisition device, call the imaqhwinfo function, specifying the name of the adaptor as the only argument. When called with this syntax, imaqhwinfo returns a structure containing information about all the devices available through the specified adaptor.

In this example, the imaqhwinfo function returns information about all the devices available through the Matrox® adaptor.

info = imaqhwinfo('matrox');
info = 

       AdaptorDllName: [1x73 char]
    AdaptorDllVersion: '2.1 (R2007a)'
          AdaptorName: 'matrox'
            DeviceIDs: {[1]}
           DeviceInfo: [1x1 struct]

The fields in the structure returned by imaqhwinfo provide the following information.

Field

Description

AdaptorDllName

Character vector that identifies the name of the adaptor dynamic link library (DLL)

AdaptorDllVersion

Information about the version of the adaptor DLL

AdaptorName

Name of the adaptor

DeviceIDs

Cell array containing the device IDs of all the devices accessible through this adaptor

DeviceInfo

Array of device information structures. See Getting More Information About a Particular Device for more information.

Getting More Information About a Particular Device

If an adaptor provides access to multiple devices, you might need to find out more information about the devices before you can select a device ID. The DeviceInfo field is an array of device information structures. Each device information structure contains detailed information about a particular device available through the adaptor.

To view the information for a particular device, you can use the device ID as a reference into the DeviceInfo structure array. Call imaqhwinfo again, this time specifying a device ID as an argument.

dev_info = imaqhwinfo('matrox',1)

dev_info = 

          DefaultFormat: 'M_RS170'
    DeviceFileSupported: 1
             DeviceName: 'Orion'
               DeviceID: 1
  VideoInputConstructor: 'videoinput('matrox', 1)'
 VideoDeviceConstructor: 'imaq.VideoDevice('matrox', 1)'       
       SupportedFormats: {1x10 cell}

The fields in the device information structure provide the following information about a device.

Field

Description

DefaultFormat

Character vector that identifies the video format used by the device if none is specified at object creation time

DeviceFileSupported

If set to 1, the device supports device configuration files; otherwise 0. See Using Device Configuration Files (Camera Files) for more information.

DeviceName

Descriptive character vector, assigned by the adaptor, that identifies the device

DeviceID

ID assigned to the device by the adaptor

VideoInputConstructor

Default syntax you can use to create a video input object to represent this device. See Creating Image Acquisition Objects for more information.

VideoDeviceConstructorDefault syntax you can use to create a VideoDevice System object to represent this device.

SupportedFormats

Cell array of character vectors that identify the video formats supported by the device. See Determining Supported Video Formats for more information.

Determining Supported Video Formats

The video format specifies the characteristics of the images in the video stream, such as the image resolution (width and height), the industry standard used, and the size of the data type used to store pixel information.

Image acquisition devices typically support multiple video formats. You can specify the video format when you create the video input object to represent the connection to the device. See Creating Image Acquisition Objects for more information.

Note

Specifying the video format is optional; the toolbox uses one of the supported formats as the default.

To determine which video formats an image acquisition device supports, look in the SupportedFormats field of the DeviceInfo structure returned by the imaqhwinfo function. To view the information for a particular device, call imaqhwinfo, specifying the device ID as an argument.

dev_info = imaqhwinfo('matrox',1)

dev_info = 

          DefaultFormat: 'M_RS170'
    DeviceFileSupported: 1
             DeviceName: 'Orion'
               DeviceID: 1
  VideoInputConstructor: 'videoinput('matrox', 1)'
 VideoDeviceConstructor: 'imaq.VideoDevice('matrox', 1)'       
       SupportedFormats: {1x10 cell}

The DefaultFormat field lists the default format selected by the toolbox. The SupportedFormats field is a cell array containing character vectors that identify all the supported video formats. The toolbox assigns names to the formats based on vendor-specific terminology. If you want to specify a video format when you create an image acquisition object, you must use one of the character vectors in this cell array. See Creating Image Acquisition Objects for more information.

celldisp(dev_info.SupportedFormats)

ans{1} =
 
M_RS170

ans{2} =
 
M_RS170_VIA_RGB

ans{3} =
 
M_CCIR

ans{4} =
 
M_CCIR_VIA_RGB

ans{5} =
 
M_NTSC

ans{6} =
 
M_NTSC_RGB

ans{7} =
 
M_NTSC_YC

ans{8} =
 
M_PAL

ans{9} =
 
M_PAL_RGB

ans{10} =
 
M_PAL_YC