FG Camera Library  1.7.0.0 (2025-06-26)
Gpixel GL7004

Overview

The VisionCam LM2 uses the quad color line sensor GPixel GL7004:

Sensor name Type eFG_CAMERA_TYPE Number of
pixels
Pixel size
GL7004 4-line RGBW FG_CAMERA_TYPE_4096_4_IMAGO_GL7004 4x 4096 7 µm x 7 µm

Features

  • Quad color line sensor (RGBW)
  • Global Shutter with interleaved integration and readout
  • Free-run mode with adjustable scan rate
  • Hardware triggered mode: line and frame trigger (controlled by RTCC)
  • 10 bit ADC and 10 bit pixel processing
  • Automatic black level correction by using dedicated black sensor pixels
  • Shading Correction (gain and offset)
  • Independent digital gain for each sensor line
  • Adjustable line delay
  • Horizontal and vertical binning
  • Lookup Table for 10 bit to 8 bit mapping
  • Horizontal mirror option

The following image shows the functional bocks and pipeline stages:

Functional blocks

Supported pixel formats

The supported pixel formats and maximum scan rates are listed below:

Supported pixel types
eFG_PIXEL_TYPE Active sensor lines Output format
FG_PIXEL_TYPE_Y_8 W 1 byte per pixel (8 bit)
FG_PIXEL_TYPE_RGB_24 R, G, B 3 bytes per pixel (8 bit R/G/B)
FG_PIXEL_TYPE_RGBX_32 R, G, B, W 4 bytes per pixel (8 bit R/G/B/W)

Use the calculator to obtain the maximum line rate:

Line rate calculator
Pixel Format:
Horizontal Binning:
Vertical Binning:
Line rate:

Special features

The sensor supports the following special features:

Special features
Property name Argument Description
LineRate
0: Use the maximum line rate (default)
≥ 1: Desired line rate in Hertz

Sets the desired sensor line rate for free-run mode in Hertz. The actual line rate may be limited by:

  • The exposure time which must be about 2 µs shorter than the readout period
  • Sensor limit, depending on pixel format
  • FPGA processing speed
  • PCIe Bandwidth

Use FG_get_special_option() in free-run mode to obtain the actual value.

ScanPeriod
0: Use maximum line rate
≥ 1: Desired line period in µs
Sets the desired sensor line period in microseconds, similar to LineRate.
Mirror
0: no flipping (default)
1: flip horizontally
Flips the image horizontally
BinningH
1: no pixel binning (default)
2: x2 pixel binning (sum of two neighbour pixels divided by two)
4: x4 pixel binning (sum of four neighbour pixels divided by four)
Horizontal binning mode
Note
  • The binning mode must be configured before the first buffer is allocated.
  • The parameters for FG_set_scan_param() / FG_set_aoi() refer to the reduced image width after binning is enabled.
BinningV
1: no pixel binning (default)
2: x2 pixel binning (sum of two neighbour pixels divided by two)
Vertical binning mode
Note
  • The binning mode must be configured before the first buffer is allocated.
  • The parameters for FG_set_scan_param() / FG_set_aoi() refer to the reduced scan count / image height after binning is enabled.
LineDelay -200...200: readout delay in percent of one line

Sets the readout delay between two neighbouring sensor lines (color pixel formats).

This setting compensates the physical displacement of the different sensor lines depending on the transport direction and speed. The value is given in percent of one line. The default value is 200 (percent) which represents the physical separation of two neighbouring sensor lines. This is the correct value for square pixel projection (relation of object speed and line rate).

Note
Interpolation of successive lines for each color channel is used if the delay is not a multiple of 100.
AnalogGain
1...4: gain value
Analog gain.
OffsetCorrection
0: off
1: on (default)

Controls the automatic offset correction.

The offset correction is based on dedicated black sensor pixels for each sensor line.

Note
Because each incoming 10-bit pixel value is subtracted by the black pixel offset, the resulting output value for saturating pixels will be slightly reduced (< 1023).
ImageMode
0: Video output
1: Test image: horizontal ramp
2: Test image: horizontal ramp with increasing start value
Controls the image mode

Additional features are described in the following sections:

Image size and sensor AOI

Multiple sensor lines are recorded and concatenated to complete an image with the specified image height.

Selecting a smaller image height reduces software latency, because all image lines have to be in memory before the buffer is given to the user. But this will also increase the processing overhead.

FG_set_aoi()

With FG_set_aoi(), the x coordinates specify the sensor columns for readout. The parameter y1 has to be zero and y2 + 1 specifies the number of lines to acquire for each image. The default image height is 512 after initialization.

Example:

UINT32 image_width, image_height;
// configure new image height (100) using the full sensor width:
image_height = 100;
image_width = 4096;
FG_set_aoi(0, 0, image_width-1, image_height-1, FG_PIXEL_TYPE_RGB_24);

FG_set_scan_param()

The alternative function FG_set_scan_param() can also be used to specify the AOI width and number of scans per image (parameter image_scan_count). The parameter scan_height must be set to one and image_scan_count is equal to the desired image height.

Example:

The following example configures an AOI width of 1024 at the sensor's center location:

UINT32 scan_x, scan_y, scan_width, scan_height, image_scan_count;
// the sensor AOI:
scan_width = 1024;
scan_height = 1;
// set x offset to the sensor's center:
scan_x = (4096 - scan_width) / 2;
scan_y = 0;
// a scan count of 100 also results in an image height of 100:
image_scan_count = 100;
// configure AOI:
FG_set_scan_param(scan_x, scan_y, scan_width, scan_height, image_scan_count, FG_PIXEL_TYPE_RGB_24);

Triggering the sensor

Line trigger

In hardware triggered mode, each trigger event starts exposure for active color channels (depending on the selected pixel format). The exposure time is controlled by FG_set_shutter_time().

The RTCC can be used to adapt the the trigger signal to the desired scan rate, see section Hardware trigger for examples.

Depending on the configured image height, multiple trigger events are required before the image is completed and returned to the user (see Image size and sensor AOI).

Note
Software triggered mode is not supported.

Frame trigger

An additional frame trigger can be used to start acquisition of an image with the configured height. The trigger can be software based or hardware based using a VIB::Multiplexer signal.

Line trigger events are ignored as long as the frame is not active. Additional frame trigger events during an active frame are ignored.

A frame start delay can be configured to ignore a certain number of line trigger events after the frame trigger occured. The frame start delay period and the acquisition of the previous frame may overlap, but the previous frame must be completed before the delay expires.

The frame trigger is configured by using the following special features:

Special features for frame trigger mode
Property name Description
FrameTriggerMode Sets the frame trigger mode.
0: Don't use a frame trigger, images are captured continuously (default)
1: Frames are software triggered by using the special option FrameTrigger
100...115: Use VIB::Multiplexer output line 0...15 with rising edge
200...215: Use VIB::Multiplexer output line 0...15 with falling edge
FrameTriggerDelay Frame start delay after receiving the frame trigger. The number determines how many line trigger events are ignored after a frame trigger event.
0...65535 (default: 0)
FrameTrigger Triggers a frame in software controlled frame trigger mode (write only).
Only the value 0 is valid.
Note
  • FrameTriggerDelay is not used if the sensor is in free-run mode.
  • Color distortions are visible in the first lines of an image for RGB and RGBW mode because the delayed sensor lines are taken from the last lines of the previous frame (see LineDelay feature).

Example:

// Setup hardware based frame trigger using Multiplexer output 3 with rising edge:
FG_set_special_option("FrameTriggerMode", 103);
// Delay frame start by 100 line trigger events
FG_set_special_option("FrameTriggerDelay", 100);
// Connect Multiplexer output 3 to digital input IN0:
VIB::Multiplexer multiplexer;
multiplexer.Open();

Gain settings

Analog Gain

Analog Gain is configured with FG_set_special_option() and the property AnalogGain. Valid values are 1, 2, 3 and 4 corresponding to analog gain x1 ... x4.

Digital Gain

Digital gain can be specified for the different sensor lines / colors. The functions FG_set_gain() and FG_set_gain_rgb() control the channel gain as follows:

  • FG_set_gain() acts as a global gain for all sensor lines (R/G/B/W).
  • FG_set_gain_rgb() sets additional gain values for the R/G/B channels. The gain value for each color is multiplied by the global gain.

Both functions accept a value in the range 0...1023 which corresponds to a gain value of x0 ... ~x4. The value for unity gain is 256 (default setting).

Note
  • The combined gain for the R/G/B channels is internally limited to x4, higher gain values will be truncated.
  • Autmatic offset correction causes a reduced output value for saturating pixels (< 1023), because each incoming 10-bit pixel value is subtracted by the black pixel offset. A digital gain value slightly above x1 can be used for compensation.

Shading Correction

The processing pipeline provides independent offset and gain coefficients for each sensor pixel. This can be used to compensate the following problems:

  • Sensor Dark Signal Non-Uniformity (DSNU)
  • Sensor Photo Response Non-Uniformity (PRNU)
  • Non-uniform illumination
  • Lens vignetting
  • White balance

Shading correction is processed by the FPGA as follows:

  • First, the offset coefficients are subtracted from the incoming 10-bit pixel values. Negativ results will be clipped to zero.
  • Then, the result is multiplied by the gain coefficients. The maximum supported gain value is 4.0. Clipping of saturating pixels only occurs after the channel gain was applied.

The gain and offset coefficients have to be calculated by the application. The calculated coefficients can then be stored into flash for later re-use.

The coefficients are configured by using FG_set_special_option() with options OffsetCoeff and GainCoeff:

Special features for Shading Correction
Property name Argument Description
OffsetCoeff Pointer to an array of unsigned char values.

Sets the offset coefficients for each active sensor pixel (see below). The values are in the range 0...255 and are applied to 10-bit values.

If argument is NULL, the offset coefficients are reset to 0 for each pixel.

GainCoeff

Pointer to an array of unsigned short values.

Sets the gain coefficients for each active sensor pixel (see below). The values are in the range 0...1023, 256 is the nominal gain value.

If argument is NULL, the gain coefficients are reset to 256 for each pixel.

SaveShadingCoeff
0...3: setting index
Stores the current gain and offset coefficients in flash memory for later re-use. Up to four settings can be stored.
LoadShadingCoeff
0...3: setting index
Loads the offset and gain coefficients from flash memory.

The argument for OffsetCoeff and GainCoeff is a pointer to an array of values containing the offset or gain coefficients for each active sensor pixel. The length and arrangement of the array depends on the pixel format and AOI width used:

eFG_PIXEL_TYPE Number of values Argument
FG_PIXEL_TYPE_Y_8 AOI width One value for each pixel
FG_PIXEL_TYPE_RGB_24 3x AOI width R/G/B components for each pixel
FG_PIXEL_TYPE_RGBX_32 4x AOI width R/G/B/W components for each pixel
Note
  • Coefficients are reset when calling FG_install_camera() (zero offset, x1 gain).
  • The coefficients for OffsetCoeff and GainCoeff are in the same order and length as used for storing the image pixels for one line, but without horizontal binning applied.
  • Coefficients for inactive sensor pixels are automatically set to their default value.
  • The sensor's DSNU error is usually very low for Analog Gain ≤ x2. Therefore, offset correction is not required for most applications.
  • The features SaveShadingCoeff and LoadShadingCoeff may block for some time.

Calculating gain coefficients

First, a reference image for calculation of the optimum gain values is required:

  • Use a uniform target for capturing the reference image, e.g. a white sheet of paper.
  • Configure the desired AOI size and pixel format, but don't use horizontal binning.
  • Set analog gain to the desired target value, for example:
    FG_set_special_option("AnalogGain", 2);
  • Reset offset and gain coefficients to their default values:
    FG_set_special_option("OffsetGainCoeff", 0);
    FG_set_special_option("GainCoeff", 0);
  • Set digital gain to default values:
    FG_set_gain_rgb(256, 256, 256);
  • Configure a linear mapping for the Lookup Table:
  • Adjust the exposure time for the uniform target: bright but not saturating pixel levels should be reached:
  • Acquire multiple lines for calculation of average pixel values. One line will not be adequate for cancelation of random pixel noise.
+ Example code for calculation and configuration of gain values

The example function below takes one acquired reference image to calculate the gain values for each sensor pixel.

The calculation of gain values for this example is based on the average values calculated for each sensor pixel (column and color). The sensor pixel with the highest average value receives a gain of 1.0. This results in a gain ≥ 1.0 for all pixels.

The function will limit gain values to the maximum allowed value of 1023. This is the case for regions which are too dark to compensate.

int CalcShadingGain( FG_IMAGE *pFgImage, // pointer to reference image for calculating the shading coefficients
bool save = false) // store coefficients permanently
{
unsigned int width, height, bytes;
unsigned int channels;
// get the image size:
FG_get_image_size(&width, &height, &bytes);
// number of used color channels:
channels = bytes / (width * height);
std::vector<unsigned short> gainCoeff(channels * width, 256); // Resulting array of gain coefficients, default: 256 (x1)
std::vector<unsigned int> colSum(channels * width, 0); // Sum for each column
std::vector<double> colAvg(channels * width); // Average value for each column
double maxVal = 0.0; // Highest average value
// Calculate pixel sum for each column and channel
for (unsigned int y = 0; y < height; y++)
{
for (unsigned int x = 0; x < width; x++)
{
for (unsigned int color=0; color < channels; color++)
{
colSum[x * channels + color] += pFgImage->pixel_ptr[(x + y * width) * channels + color];
}
}
}
// Calculate average pixel value and store the highest average for all pixels
for (unsigned int x = 0; x < (channels*width); x++)
{
colAvg[x] = (double)colSum[x] / (double)height;
if (colAvg[x] > maxVal)
maxVal = colAvg[x];
}
// Calculate gain coefficients for each pixels.
// The pixel with the highest average gets a gain of 1.0.
// The gain for darker pixels is increased to reach the same brightness level.
for (unsigned int x = 0; x < (channels*width); x++)
{
if (colAvg[x] > 0.0)
{
unsigned int coeff = lroundf(256.0f * maxVal / colAvg[x]);
if (coeff > 1023) // limit gain value to ~ x4
coeff = 1023;
gainCoeff[x] = coeff;
}
}
// Set coefficients
FG_set_special_option("GainCoeff", (INT64)&gainCoeff[0]);
// Save the new coefficients permanently
if (save)
FG_set_special_option("SaveShadingCoeff", 0);
return 0;
}

Lookup Table

A lookup table maps the 10-bit sensor values to 8-bit output values. For example, a gamma compression curve can be used to provide higher sensitivity for darker pixels and lower sensitivity for brighter pixels.

The lookup table is configured by using FG_set_special_option() with the option LUT. The argument is a pointer to an array of 1024 output values.

Special features
Property name Argument Description
LUT Pointer to an array of 1024 unsigned char values

Sets the Lookup Table used for mapping the 10-bit pixels to 8-bit output. 8-bit values must be provided for input values in the range 0...1023.

If the argument is NULL, the Lookup Table is reset to linear mapping.

SaveLUT
0...3: setting index
Stores the current Lookup Table into flash memory for later re-use. Up to four settings can be stored.
LoadLUT
0...3: setting index
Loads the Lookup Table from flash memory.
Note
  • The table is reset to linear mapping when calling FG_install_camera().
  • The features SaveLUT and LoadLUT may block for some time.

The default linear mapping is the same as the following example:

unsigned char lut[1024];
for (unsigned int i = 0; i < 1024; i++)
lut[i] = i / 4;
FG_set_special_option("LUT", (INT64)lut);
FG_install_camera
UINT32 DLL_FG_API FG_install_camera(enum eFG_CAMERA_TYPE camera_type,...)
Opens and initializes the camera.
Definition: FG_CameraInterface.cpp:283
VIB::Multiplexer::MUX_SRC_DIG_IN0
MUX_SRC_DIG_IN0
FG_IMAGE::pixel_ptr
UINT8 *const pixel_ptr
Pointer to image memory.
Definition: FG_CameraInterface.h:169
FG_IMAGE
This structure stores information associated with image buffers
Definition: FG_CameraInterface.h:164
VIB::Multiplexer::ConnectOutput
bool ConnectOutput(unsigned int OutputIndex, Multiplexer::MUX_SOURCE Source)
FG_PIXEL_TYPE_RGB_24
@ FG_PIXEL_TYPE_RGB_24
3 bytes per pixel containing 8 bit red/green/blue. The sequence is [R0G0B0 R1G1B1 ....
Definition: FG_CameraInterface.h:125
FG_set_aoi
UINT32 DLL_FG_API FG_set_aoi(UINT32 x1, UINT32 y1, UINT32 x2, UINT32 y2, enum eFG_PIXEL_TYPE pixel_type)
Sets the area of interest and the output format.
Definition: FG_CameraInterface.cpp:750
FG_set_gain_rgb
UINT32 DLL_FG_API FG_set_gain_rgb(UINT32 gain_red, UINT32 gain_green, UINT32 gain_blue)
Sets the color component gain values for supported hardware.
Definition: FG_CameraInterface.cpp:930
FG_set_shutter_time
UINT32 DLL_FG_API FG_set_shutter_time(UINT32 shutter_time_us)
Sets the exposure time in µs.
Definition: FG_CameraInterface.cpp:954
FG_set_gain
UINT32 DLL_FG_API FG_set_gain(UINT32 gain)
Sets the gain using a normalized value.
Definition: FG_CameraInterface.cpp:906
FG_set_special_option
UINT32 DLL_FG_API FG_set_special_option(const char *option, INT64 arg)
Configures a special camera property.
Definition: FG_CameraInterface.cpp:972
VIB::Multiplexer
FG_get_image_size
UINT32 DLL_FG_API FG_get_image_size(UINT32 *width, UINT32 *height, UINT32 *bytes)
Returns the size of the image buffers.
Definition: FG_CameraInterface.cpp:811
FG_set_scan_param
UINT32 DLL_FG_API FG_set_scan_param(UINT32 scan_x, UINT32 scan_y, UINT32 scan_width, UINT32 scan_height, UINT32 image_scan_count, enum eFG_PIXEL_TYPE pixel_type)
Sets the area of interest and output format.
Definition: FG_CameraInterface.cpp:774
VIB::iDevice::Open
bool Open(unsigned int Index=0)
FG_CAMERA_TYPE_4096_4_IMAGO_GL7004
@ FG_CAMERA_TYPE_4096_4_IMAGO_GL7004
IMAGO Visioncam GL7004 4096x4 RGBW.
Definition: FG_CameraInterface.h:91