Main Content

Creating a Stub Adaptor Test Procedure

As part of the Image Acquisition Toolbox Adaptor Kit, we now offer a test procedure and automated tests for third-party adaptor developers and camera vendors to test adaptors and hardware against the toolbox. This test procedure is part of that suite. For more information, see Testing Adaptors or Hardware.

After creating a stub adaptor per instructions in “Creating a Stub Adaptor” in this Adaptor Kit documentation, follow these steps to verify that the stub adaptor shows up in MATLAB®.

Test ProceduresExpected Results
In MATLAB, register the adaptor using the following command:
imaqregister('AdaptorDllName')
where 'AdaptorDllName' is the adaptor dll file name with the full path to the file.

The registration of the adaptor should work without any errors or warnings.

Once verified, run the following command:

imaqreset
Run the following command:
imaqhwinfo
imaqhwinfo will output a list of available adaptors. The adaptor being built should be listed in InstalledAdaptors.
Run the following command:
imaqhwinfo('AdaptorName')
The details of the adaptor library are shown. AdaptorDllName should be the full path to the adaptor library. At this point DeviceIDs and DeviceInfo should empty (1x0).

Once the device enumeration code has been added, follow these steps to verify the device information.

Test ProceduresExpected Results
Run the following command:
devInfo = imaqhwinfo
   ('AdaptorName')
The DeviceIDs and DeviceInfo fields should now be populated. DeviceIDs should be from 1 to N based on the number of devices added. DeviceInfo is a MATLAB structure (or array of structures if there are multiple devices).
Run the following command:
devInfo(:).DeviceInfo
DeviceInfo should show the information as follows for each device:
DefaultFormat: '640x480'
DeviceFileSupported: 0
DeviceName: 'MyDevice'
DeviceID: 1
ObjectConstructor: 'videoinput
   ('mydeviceimaq', 1)'
SupportedFormats: {'640x480' 
   '320x240'}

where,

DefaultFormat is the format for which the second argument to addDeviceFormat is set to true.

DeviceFileSupported is true (1) if the device supports device files.

DeviceName is the name of the device as defined in createDeviceInfo.

DeviceID is the ID associated with the device as defined in createDeviceInfo. This is usually 1.

ObjectConstructor is how a videoinput object for that device is created in MATLAB.

SupportedFormats is a cell array of all supported formats as defined using addDeviceFormat. It is empty if DeviceFileSupported is true and no formats were added by DeviceFormat.

After the adaptor class has been written, follow these steps to test the videoinput object creation and destruction.

Test ProceduresExpected Results
Run the following command:
vidObj = videoinput
   ('AdaptorName')
The videoinput object should get created using the first device found and the default format without any error and its details should be displayed at the MATLAB command prompt. This will not work if only device files are supported. The details should be similar to:
Summary of Video Input Object Using 
   'MyDevice'.
Acquisition Source(s): MyDeviceSource is 
   available.
Acquisition Parameters: 
   'MyDeviceSource' is the current selected 
       source.
   10 frames per trigger using the selected 
       source.
   '640x480' 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.

where MyDevice is the device connected.

Run the following commands:
delete(vidObj);
vidObj

The following message should get displayed:

Invalid Image Acquisition object.

This object is not associated with any hardware and should be removed from your workspace using clear.

Run the following commands:
vidObj = videoinput
   ('AdaptorName');
imaqreset;
vidObj

The following message should get displayed:

Invalid Image Acquisition object.

This object is not associated with any hardware and should be removed from your workspace using clear.