Technical Application Notes
Click an item to read from the list below.

Technical Application Notes


 

 

Getting Started with MATLAB

Subject

Technical Application Note (TAN2015014): Getting Started with MATLAB

10523

Applicable Products

  • All FLIR machine vision cameras

Application Note Description

This application note provides information on how to install, configure, and use cameras with MATLAB.

 

 

This document provides examples using MATLAB2014a. For more information, visit the MathWorks website.

Preparing for Use

Before you use your camera, we recommend that you are aware of the following resources available from our Downloads page.

  • Getting Started Manual for the camera—provides information on installing components and software needed to run the camera.
  • Technical Reference for the camera—provides information on the camera’s specifications, features and operations, as well as imaging and acquisition controls.
  • Firmware updates—ensure you are using the most up-to-date firmware for the camera to take advantage of improvements and fixes.
  • Tech InsightsSubscribe to monthly email updates containing information on new knowledge base articles, new firmware and software releases, and Product Change Notices (PCN).

Installation and Configuration

MATLAB uses different adaptors depending on the type of camera connected:

  • dcam—for FireWire cameras. It supports IIDC1394 specific calls.
  • gige—for GigE Vision cameras.
  • gigecam—for GigE Vision cameras. This adaptor uses GigE Vision advanced property features and is the recommended adaptor.
  • pointgrey—for all cameras. It lacks some calls specific to FireWire and GigE Vision cameras such as Device Link Throughput Limit.
  • winvideo—for all cameras using DirectShow. This requires the installation of Spinnaker SDK (version 1.0.0.270 or later) for USB3 Vision cameras, or FlyCapture SDK for other cameras. There are some limitations and it does not work with multiple cameras.
 

MATLAB2014a’s gigecam adapter is accessed by a command window instead of a GUI. The MathWorks website outlines the differences between gige and gigecam and lists the gigecam commands. We recommend the gigecam adaptor.

The steps for installing and setting up depend which interface your camera uses.

FireWire
Cameras (dcam)

GigE Vision Cameras
(gigecam)

USB3 Vision/USB2 Cameras
(gige/pointgrey)

All Cameras if using
DirectShow
(winvideo)
1. Install MATLAB. 1. Install MATLAB. 1. Install MATLAB.

1. Install MATLAB.

2. Connect the Camera to the PC and install the CMU camera driver.. 2. Connect the Camera to the PC. 2. Connect the Camera to the PC. 2. Connect the Camera to the PC and install the camera's SDK..
3. Start MATLAB and Detect the Camera. 3. Start MATLAB and Detect the Camera. 3. Start MATLAB and Detect the Camera. 3. Start MATLAB and Detect the Camera.
4. Start Acquisition. 4. Start Acquisition. 4. Start Acquisition. 4. Start Acquisition.

 The following sections provide more detail.

 

Step 1—Install MATLAB

MATLAB is available for download from the MathWorks website.  Follow the installation instructions.

Step 2—Connect the Camera to the PC and install any required drivers or SDKs

Connect the camera to the PC. For information, see the camera’s Getting Started Manual. FireWire cameras require youo to install the CMU driver. Cameras using the DirectShow adaptor (winvideo) require you to install the camera's SDK.

  • For FireWire cameras that use the dcam adaptor, install the CMU driver.

To verify your driver:

  1. In Windows Device Manager, verify your driver. If the host controller is 1394 OHCI Compliant (Microsoft OHCI host controller), go to Step 3 below.



    If the host controller is the Point Grey Bus Host Controller, your driver is the Point Grey FirePRO driver, and is not 1394 OHCI Compliant. Update the driver as instructed in Step 2 below.



  2. To update the driver:
    1. Right-click the host controller and select Update driver software.
    2. Click Browse my computer for driver software.
    3. Click Let me pick from a list of device drivers on my computer.
    4. Select 1394 OHCI Compliant Host Controller.

  3. In Windows Device Manager, verify the camera driver. If it is listed under Imaging devices as CMU 1394 Digital Camera Device, go to Step 3 Start MATLAB and Detect the Camera.




    If you are using the Point Grey camera driver, the camera is listed under Point Grey Research Devices as PGR <Camera Model> and the driver needs to be updated as instructed in Step 4 below.




  4. To update the driver:
    1. Right click the camera and select Update driver software.
    2. Click Browse my computer for driver software.
    3. Browse to C:\Program Files (x86)\CMU\1394Camera\Driver or C:\Program Files\CMU\1394Camera\Driver and click Open.
  • For cameras using the DirectShow adaptor (winvideo), install the camera SDK.

To use a camera with the DirectShow adaptor (winvideo), you need the DirectShow filter provided with the SDK. Install the version of of the SKD that matches the architecture of the MATLAB installation (32-bit or 64-bit).

- For Blackfly S cameras, install Spinnaker SDK (version 1.0.0.270 or later)

- For other cameras, install FlyCapture SDK.

To install the Spinnaker DirectShow filter:

  1. Download the Spinnaker SDK from the Downloads page. Select version 1.0.0.270 or newer.
  2. Follow the installation instructions. Ensure the DirectShow filter is selected during installation.
  3. Right-click on the shortcut below and run as administrator:
    Start Menu → All Programs → Point Grey Spinnaker SDK (64bit) → DirectShow_vs201X → Register DirectShow Dlls
    Where 32-bit MATLAB is used in 64-bit system, register the 32-bit DirectShow: Start Menu → All Programs → Point Grey Spinnaker SDK → DirectShow_vs201X → Register DirectShow Dlls

To install the FlyCapture2 DirectShow filter:

  1. Download the FlyCapture2 SDK from the Downloads page.
  2. Follow the installation instructions. Ensure the DirectShow filter is selected during installation.
  3. Right click on the file below and run as administrator:
    C:\Program Files\Point Grey Research\FlyCapture2\src\DirectShowScriptFiles\DirectShowRegister.bat

Where 32-bit MATLAB is used in 64-bit system, register the 32-bit DirectShow:
C:\Program Files (x86)\Point Grey Research\FlyCapture2\src\DirectShowScriptFiles\DirectShowRegister.bat

 

Step 3—Start MATLAB and Detect the Camera

  • To start MATLAB detect the camera (gigecam only):
  1. Launch MATLAB R2014a.
    Start Menu → All Programs → MATLAB → R2014a → MATLAB R2014a
  2. In the command window, enter
    g = gigecam(1)
    From this window, you can detect the camera and stream images. Mathworks provides a comprehensive list of gigecam commands.

 

To start MATLAB and detect the camera (dcam, gige, point grey, winvideo):

  1. Launch MATLAB R2014a.
    Start Menu → All Programs → MATLAB → R2014a → MATLAB R2014a

  2. Under the APPS menu, click Image Acquisition.




  3. A list of MATLAB adaptors installed on the system is shown in the Information window of Image Acquisition Tool:
  • dcam—IEEE 1394 IIDC
  • gige—GigE Vision
  • pointgrey—Point Grey
  • winvideo—DirectShow



 

More than one adaptor can be installed at the same time.

If the MATLAB adaptor you want to use is not installed on the system, use MATLAB’s Support package Installer to install the adaptor.

 

The gigecam adaptor does not appear in Image Acquisition Toolbox as it is accessed by a command window. See Step 3–Start MATLAB and detect the camera (gigecam only).

4.  In the Hardware Browser, ensure the camera shows up using the correct adaptor.

FireWire IIDC (dcam)

 

GigE Vision (gige)

 

Point Grey (pointgrey

 

DirectShow (winvideo)

 

 Step 4—Start Acquisition

  • For GigE Vision cameras using the gigecam adapter, use the command window to stream images. MathWorks provides a comprehensive list of gigecam commands.
  • For all other cameras using dcam, gige, pointgrey, or DirectShow winvideo adaptors:

To start acquisition:

  1. In the Hardware Browser window, click one of the Video Modes listed under the camera.



  2. Click Start Preview button from Preview window.

Troubleshooting Tips

The following suggestions may help you troubleshoot issues with your camera:

  1. Update the driver to the latest version.
  2. Update the firmware to the latest version.
  3. Update the software to the latest version.
  4. Perform a soft reboot and if still necessary a hard reboot of the PC.
  5. Disable then enable the driver.
  6. Power cycle the camera.
  7. Power the camera through GPIO, if wiring harness is available.
  8. Use a separate host controller instead of an integrated one, if available.
  9. Ensure the card is powered via the 4-pin hard drive connector, if applicable.
  10. Use a different cable or host controller or PC.
  11. Restore the default setting of the camera.
  12. Reset image acquisition objects in MATLAB with imaqreset command.