November 8, 2012

Installation of Basler acA2000 with BitFlow Neon on a PC

Software and driver installation

  1. Install Basler Pylon, do not forget to select driver for Camera Link. The Pylon package contains tools for camera configuration (Pylon Viewer) and registration (Pylon CL Configuration Tool)
  2. Install BitFlow SDK (use serial number 0, if you have not purchased a full licence). The BitFlow SDK contains utilities for editing and registration of camera configuration files (CamEd, SysReg) together with live video preview (CiView) and useful throughput testing utility CiBench. Only one of the utilities can access the framegrabber at a time.


Connecting the camera to the framegrabber

Because Neon-CLB only supports Base Camera Link, we connect the cable to camera port marked with "B" (the other port is for Full Camera Link). If the LED indicator glows, the camera is powered over CameraLink. If not, PoCL must be enabled or one can power the camera with a standalone adapter. PoCL can be enabled when you open the camera configuration file in CamEd as it is shown below. Remember to edit the configuration file that you will later register with SysReg utility. The camera does not wake up even with enabled PoCL until you attempt to grab images (e.g. with the CiView utility). However, you have to do some other settings mentioned later on before you can try to grab images.

Enabling PoCL in the CamEd utility

Camera-framegrabber communication settings

The settings are done with Pylon CL Configuration Tool. After launching the program, one can choose the COM ports to be scanned for cameras. Tick the one called "BitFlow"and click "Probe Enabled Ports". The utility should detect the Basler camera. It is also possible to set the baud rate of the serial line under advanced settings. This value must be set the same as the one in the camera settings (recommended value is 460800 bauds per second).


Creating and setting the camera configuration file

In the first step, we have two options depending on the answer to question if we were provided with a set of ready-to-use camera files by the camera vendor or not. In the first case, we just copy the vendor camera files into the directory "..\BitFlow SDK x.xx\Config\R64". If we don't have any appropriate configuration file (one might be also present in the above directory after installation of the BitFlow SDK), we have to create our own configuration file using the CamEd utility from the BitFlow SDK. To do this, we run the utility, open any R64 configuration file, edit the settings so that they suit our needs and capabilities of our camera and save the file as our own one. In fact, the camera configuration file specifies, how the data from the camera are ordered as well as their format to the framegrabber.
The most important settings in camera configuration file include the following:
  1. Active pixels per line (image width)
  2. Active lines per frame (image height)
  3. Sensor type - if we use an RGB camera, in the 'Sensor' tab, we can enable hardware Bayer decoding on the framegrabber under 'Sensor architecture'. This option decreases the maximum acquisition rate because the amount of transferred data triples, as we get full resolution image in all three color layers every period. Otherwise, we get only a raw Bayer array output from the framegrabber.
  4. Camera bit depth in the 'Bayer' tab specifies number of bits per pixel in one layer of the framegrabber output.
  5. Enable/disable Power over Camera Link (PoCL). This is quite an useful option how to turn off the power supply to the camera when we need to break the Camera Link connection without turning off the computer with framegrabber. We can just uncheck the 'Power over Camera Link' box, save the configuration file and then choose 'Display' > 'Open' to propagate the settings to the framegrabber. Before finally breaking the connection, we make sure that the power is really turned off by checking the LED indicator on the camera.
Enabling hardware Bayer decoding in CamEd utility
We do not need to care about the other settings as Exposure control, because we do not use the camera control signals for image acquisition, but use the settings stored in the camera registry instead.

In the second step, we register the camera configuration file that will be used for image acquisition. We launch the SysReg utility from the BitFlow SDK and set the required camera configuration file to be used by clicking "Configure..." and then choosing the appropriate camera file.


Camera configuration

Camera settings can be edited in Pylon Viewer, which is a software from Basler. It is better to see the camera user's manual as a reference of various settings. We have to keep in mind that the camera settings must correspond with the settings in the camera configuration file registered with SysReg utility! If you change any settings that affect the format of the data from the camera, such as resolution, you have to update the registered camera configuration file so that the settings are consistent. Otherwise, you will get errors or destroyed image.
The Pylon Viewer provides tools for exposure settings (white balance, exposure time, gain etc.).
A very useful and important functionality is the possibility to specify up to 4 configuration sets that can be saved in the camera memory and loaded at any time through the Pylon Viewer. A configuration set stores all the camera settings available in the Pylon Viewer. It is also possible to specify, which configuration set is loaded during the camera startup. If we don't specify our own startup configuration set, all settings will be reverted to default values every time we reboot the camera.

Setting the configuration sets

First image acquisition

Having set camera, the configuration file and framegrabber communication, you can try to display a live video with CiView. If you use PoCL, the framegrabber will at first fail to acquire images, because at the first attempt, the camera will not be started yet. This first attempt should wake the camera up, and the LED indicator should glow (green+red during startup, green when the camera is ready). When the camera starts up, just re-open the Display Surface window in CiView and you should see live video from the camera.

Screenshot from live view

BitFlow NEON-CLB with MATLAB&Image Acquisition Toolbox

BitFlow offers a comfortable solution for users that are using Neon or other framegrabbers on a PC with Matlab together with the Image Acquisition Toolbox. It is possible to download adapter for BitFlow framegrabbers, which provides interface for Image Acquisition Toolbox. We find this very useful, because it is quite hard to visualize anything on the xPC Target, so it is easier to debug and test the algorithms on a standard PC with Matlab. A short demo script:


%% TEST IMAGE ACQUISITION WITH BitFlow FRAMEGRABBER
%
% register the BitFlow adaptor
clear all, close all, clc
adapt_path = 'C:\BitFlow SDK 5.60\Bin64\MATLAB Adaptor\WIN64\BitFlow.dll';
imaqregister(adapt_path, 'register');

% create video object and get source object

vidobj = videoinput('bitflow');
srcobj = vidobj.Source;
srcobj.TriggerMode = 'One Shot';

%% grab and display 200 frames

for it=1:200
    frame = getsnapshot(vidobj);
    imagesc(frame), axis equal
    disp(['Frame no. ' num2str(it)])
end


November 6, 2012

Connecting a Camera Link camera to Speedgoat

Having tested the USB webcam together with the Speedgoat platform, we moved on to try out the functionality with a Camera Link camera. The platform is provided with BitFlow Neon-CLB framegrabber. Neon-CLB offers Base Camera Link interface for one camera with safe Power over Camera Link (PoCL), which means that a PoCL compatible camera does not need a separate power cable. It fits into a PCIe x4 slot and supports cameras with Camera Link clock frequency up to 85 MHz.

Camera Link camera

We have chosen high speed color camera Basler acA2000-340kc with Camera Link interface for our application. It can capture video in full resolution of 2046x1086 pixels @ 340 frames per second. It is provided with a 2/3´´ CMOS sensor with bit depth at most 12 bits per pixel.
Basler cameras from the Ace series are not intended as high-end (they use CMOS sensors instead of CCD), but they can offer good basic parameters (resolution and speed) for a price that is two- or even more times lower than for other cameras. The price for monochrome and color variant of acA2000-340 is 29440CZK or 29980CZK, respectively. Therefore we decided for the color variant, because it could be useful to distinguish more balls on the platform marked with different colors. Just to compare the prices of other series and manufacturers, let's name a few other cameras
  • SVS Vistek svs1050 (1024x1024@90fps)  57239CZK
  • SVS Vistek evo1050 (1024x1024@190fps) 68068CZK
  • AVT Bonito CL400 (2320x1726@193fps) 81900CZK
  • Optronis CamRecord CL300x2 (1280x1024@125fps) 141960CZK
  • Basler avA1600-65 (1600x1200@67fps) 52260CZK
  • Basler A405k (2320x1726@167fps) 179400CZK
Generally, the CMOS sensors have heavier image noise compared to more expensive CCD sensors, but the noise becomes dominant in bad light conditions, which will not be the case in our application, so we rather focused on the image resolution and framerate parameters.

We have to be aware of several specific limitations for the use of the camera, too, as we could damage it otherwise.

  1. The camera body has a standard C-mount for lens, but the thread length is limited due to IR-cut filter in front of the CMOS sensor.
  2. We must be careful when making/breaking the Camera Link connections. When using PoCL, the power to the framegrabber card must be turned off before connecting/disconnecting the camera. When using a standalone power adapter, we can only manipulate with the PoCL cable when the power cable is disconnected or the adapter turned off.
  3. Of course, we must protect the CMOS sensor against dust and dirt.

Limitations of using Camera Link cameras on Speedgoat

Although xPC Target provides a Simulink block for signal acquisition from BitFlow Neon framegrabber, we ran into problems here. The Simulink block must be provided with a camera configuration file that specifies the format of the camera data for the framegrabber as well as how the data should be processed. However, one cannot perform any camera settings like exposure or AOI (area of interest) control from Speedgoat, because these settings are done through Basler Pylon software that can be installed only on Windows. Therefore, unless you want to run the camera with the default factory settings, you need another framegrabber that will be plugged into a PC with the Basler Pylon software installed. We could avoid buying another framegrabber by moving the one from Speedgoat to a PC, doing the necessary settings and moving it back again, but we would loose the Speedgoat warranty by opening the case.

Transfer of Basler camera settings to Speedgoat

When we want to use some other than default settings of the camera when connected to Speedgoat, we use the following procedure:
  1. Connect the camera to the host PC with BitFlow SDK and Basler SW installed, do all the necessary settings, save them as a user configuration set in the Basler Pylon Viewer and set this User Set as Default Startup Set. This will ensure that our settings are loaded every time when the camera is booted or re-booted. (Installation and setting of Basler camera together with BitFlow Neon CLB framegrabber on a PC is described in the next post.)
  2. Disconnect the camera from the host PC
  3. Connect the camera to the target PC and run the target application. The camera is booted with our own settings.

Live video transfer from Target to Host PC

Having configured the camera and Simulink models for Target and Host PC properly, we tried to transfer and display live video on the Host PC, similarly to the case with USB webcam. We faced the same problem with low framerate again and did not discover any working solution even asking the MathWorks support.

Setting the PCI slot of the framegrabber in xPC Target Simulink block

The xPC Target block 'NEON BitFlow Image Input' has an option to specify the address of PCI slot that hosts the BitFlow framegrabber card in the Target PC. First of all, we had to find out, which PCI slot it is using command 
getxpcpci('all')
This command lists all PCI devices installed in the Target PC. The PCI slot is then set in the configuration dialog of the Simulink block using notation '[bus,slot]'. The autosearch works as well, but it lengthens the initialization of the target application and causes that the Target disconnects from the Host during initialization. 
Setting the parameters of acquisition including the PCI location of the framegrabber in the target