Using MATLAB Image Acquisition Toolbox for Windows

Using MATLAB Image Acquisition Toolbox for Windows

Image Acquisition Toolbox™ provides functions and blocks that enable you to connect industrial and scientific cameras to MATLAB® and Simulink®. It includes a MATLAB app that lets you interactively detect and configure hardware properties. The toolbox enables acquisition modes such as processing in-the-loop, hardware triggering, background acquisition, and synchronizing acquisition across multiple devices. The following instructions detail how to configure Lucid Vision GigE Vision cameras with MATLAB Image Acquisition Toolbox.

MATLAB can also be configured to be a GenTL Consumer (via CTI files included with the Arena SDK. This procedure is outlined below as well.

System Specifications

  • Windows 10 Pro 64-bit, version 1709, build 16299.64
  • MATLAB 2017b 64-bit

Prerequisites

  1. Install the Image Acquisition Toolbox.

    • Click on the Apps tab.
    • Click Get More Apps.

    /wp-content/uploads/2018/01/matlab_windows_get_more_apps.png

    • Search for the Image Acquisition Toolbox package and install it.

    The Image Acquisition Tool, which is part of the Image Acquisition Toolbox, will be available in your Apps tab.

    /wp-content/uploads/2018/01/matlab_windows_image_acquisition_installed.png

  2. Install the MATLAB GigE Vision adapter.

    • Click on the Apps tab.
    • Click Get More Apps.
    • Search for the Image Acquisition Support Package for GigE Vision Hardware package and install it.

    /wp-content/uploads/2018/01/matlab_windows_addon_gige.png

  3. Verify the MATLAB GigE Vision adapter is installed by finding the package named gige in the Installed adaptors list in the Information section of the Image Acquisition Tool window.

    /wp-content/uploads/2018/01/matlab_windows_image_acquisition_gige.png

MATLAB Image Acquisition Tool

  1. Launch the MATLAB Image Acquisition Tool from within MATLAB. MATLAB can be launched from the Start Menu.

    /wp-content/uploads/2018/01/matlab_windows_image_acquisition.png

  2. Choose your desired camera and pixel format in the Hardware Browser.

    /wp-content/uploads/2018/01/matlab_windows_image_acquisition_hardware_browser.png

  3. Click Start Preview to preview images on screen in the current imaging settings.

  4. Click Stop Preview to stop previewing images on screen.

  5. Select the Device Properties tab to adjust camera settings.

  6. Select the Logging tab to adjust the logging settings used by the Image Acquisition Tool.

    • Choose Log to: Memory to log image data to memory. Click Export Data to export the data after image acquisition.
    • Choose Log to: Disk to log image data to disk. Image data gets logged to a VideoWriter file.
    • Choose Log to: Disk and memory to log image data to memory and disk.
  7. Select the Region of Interest tab to adjust image height and width.

  8. Select the Triggering tab to configuring MATLAB’s triggering modes.

    • Immediate will immediately log image data.
    • Manual will log image data when the Trigger button is clicked.

    Camera triggering options are present in the Device Properties tab.

  9. Click Start Acquisition to start grabbing and logging image data.

  10. Click Stop Acquisition to stop grabbing and logging image data.

The Image Acqusition Tool will also record your actions in the Session Log which can be saved as a MATLAB M-file (.m). Click matlab_windows_image_acquisition_button_save_session_log to save your session log.

/wp-content/uploads/2018/01/matlab_windows_image_acquisition_session_log.png

MATLAB gigecam Interface

Starting with MATLAB 2014a, the Image Acquisition Support Package for GigE Vision Hardware also includes the gigecam interface, which is specifically designed for GigE Vision cameras. It can be used to access GigE Vision-specific features.

The following MATLAB commands demonstrate connecting to a GigE camera and setting up camera properties using the gigecam interface.

% List cameras
>> gigecamlist

ans =

  1×4 table

       Model          Manufacturer          IPAddress       SerialNumber
    ___________    ___________________    ______________    ____________

    'PHX050S-M'    'LUCID Vision Labs'    '169.254.51.0'    '50'

% Connect to camera by IP address
% It is also possible to connect by list index number or serial number
>> g = gigecam('169.254.51.0')

g =

   Display Summary for gigecam:

          DeviceModelName: 'PHX050S-M'
             SerialNumber: '50'
                IPAddress: '169.254.51.0'
              PixelFormat: 'Mono8'
    AvailablePixelFormats: {'Mono8'  'Mono10p'  'Mono10Packed'  'Mono12Packed'  'Mono12p'  'Mono10'  'Mono12'  'Mono16'}
                   Height: 2048
                    Width: 2448
                  Timeout: 10

   Show Beginner, Expert, Guru properties.
   Show Commands.

>> g.PixelFormat = 'Mono8'
>> g.Width = 320
>> g.Height = 240
>> g.GainAuto = 'Off'
>> g.Gain = 1
>> g.ExposureAuto = 'Off'
>> g.ExposureTime = 1000
>> g.GevSCPSPacketSize = 9000

% preview(g) will preview the image from the camera
% snapshot(g) will acquire a single image
>> img = snapshot(g)

% display 'img' on screen
>> imshow(img)

% clear 'img'
>> clear img

For more information about the gigecam interface, please see the page Acquisition Using GigE Vision Hardware from MathWorks.

The Image Acquisition Tool uses the gige interface with the videoinput object, which is separate from the gigecam interface.

Using ArenaView CTI files with MATLAB 

Using CTI files allows MATLAB and other GenTL consumers to use the CTI file to directly access the GenTL layer of the camera.  

The Arena SDK installation installs three different CTI files, each for a different transport protocol.  

  • UDP
  • TCP
  • RDMA

You can still use HALCON as a GenTL Consumer by following the procedure below.

Applicable systems 

The procedure applies to systems with the following installed:

  • Arena SDK version 1.0.44.7 or higher.
  • MATLAB R2022b
  • GenTL support for MatLab, which may be available through the Image Acquisition Toolbox add-in or some other add-in.

Procedure 

To configure MATLAB to use a particular CTI file in the Arena SDK:  

  1. Ensure that the GENICAM_GENTL32_PATH environmental variable exists on your system.
  2. In Windows Explorer, navigate to the x64Release folder in the Arena SDK installation. The default location is:
    C:\Program Files\LUCID Vision Labs\Arena SDK\x64Release.
  3. Rename the file extensions to all of the CTI files except for the one you are going to use (e.g., GenTL_RDMA_LUCID_v140.cti.not_used).
  4. Start MATLAB, and select Apps > Image Acquisition.
  5. Select the appropriate hardware-adapter combination. The GenTL adapter is labeled “gentl”.

When you use a CTI file, MATLAB should choose the correct protocol (i.e., UDP, TCP, or RDMA). If the protocol doesn’t change as expected, you can change it manually in ArenaView or MATLAB. You may need to restart MATLAB for the changes to take effect.