This document describes the layout of information within a frame of image data populated by a call to the PixeLINK API's function PxLGetNextFrame or a call back routine. (See PxLSetCallback.) The layout in a frame is based primarily on the camera's pixel format, which can be found via the PixelFormat field of the Frame Descriptor structure that is returned by PxLGetNextFrame or passed to the callback routine. The pixel format will typically be one of the following:


MONO8, MONO16, MONO12_PACKED, BAYER8, BAYER16, BAYER12_PACKED, YUV422, MONO12_PACKED_MSFIRST, BAYER12_PACKED_MSFIRST


MONO8


Each sensor pixel is represented as an 8 bit DN value and takes up 8 bits (1 byte).  The frame is organized as an array of sensor pixels, starting at top left, moving left to right, top to bottom.


Example


PL-B771 camera configured for:


  • MONO8
  • ROI is 8X8


The camera is looking at a bright white image and all pixels are saturated (i.e. at max value).


Looking at the frame data in memory on a byte-by-byte basis:


 0x00A92D20  ff ff ff ff ff ff ff ff 
 0x00A92D28  ff ff ff ff ff ff ff ff  
 0x00A92D30  ff ff ff ff ff ff ff ff  
 0x00A92D38  ff ff ff ff ff ff ff ff  
 0x00A92D40  ff ff ff ff ff ff ff ff  
 0x00A92D48  ff ff ff ff ff ff ff ff  
 0x00A92D50  ff ff ff ff ff ff ff ff  
 0x00A92D58  ff ff ff ff ff ff ff ff
 ...  

 


MONO12_PACKED


Each sensor pixel is represented as a 12 bit DN value and takes up 12 bits such that it takes 3 bytes to represent 2 pixels.  The frame is organized as an array of sensor pixels, starting at top left, moving left to right, top to bottom.

Each two pixels are ‘packed; into 3 data bytes as follows: the first data byte will contain the 8 most significant bits of the first pixel, while the 4 least significant bits of the second data byte, will contain the 4 least significant bits of the first pixel.  The most significant 4 bits of the second data byte will contain the least significant 4 bits of the second pixel, while the third data byte will contain the most significant 8 bits of the second pixel.  The astute reader will notice that this packing scheme puts the most significant bits of each pixel into a unique data byte, which makes for easy conversion to 8 bit images.


Example camera configured for:

  • MONO12_PACKED
  • ROI is 8x8


The camera is looking at a bright white image and all pixels are saturated (i.e. at max value)
Looking at the frame data in memory on a byte-by-byte basis

 0x00A92D20  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D2C  ff ff ff ff ff ff ff ff ff ff ff ff 
 0x00A92D38  ff ff ff ff ff ff ff ff ff ff ff ff 
 0x00A92D44  ff ff ff ff ff ff ff ff ff ff ff ff 
 0x00A92D50  ff ff ff ff ff ff ff ff ff ff ff ff 
 0x00A92D5C  ff ff ff ff ff ff ff ff ff ff ff ff 
 0x00A92D68  ff ff ff ff ff ff ff ff ff ff ff ff 
 0x00A92D74  ff ff ff ff ff ff ff ff ff ff ff ff 



MONO12_PACKED_MSFIRST


Each sensor pixel is represented as a 12 bit DN value and images are packed such that it takes 3 bytes to represent 2 pixels.  The frame is organized as an array of sensor pixels, starting at top left, moving left to right, top to bottom.  Each two pixels are ‘packed; into 3 data bytes as follows: the first data byte will contain the 8 most significant bits of the first pixel and the second data byte contains the 8 most significant bits of the second pixel.  The 4 least significant bits of both the first and second pixel, are packed into the third data byte, with the least significant 4 bits of this data byte containing the least significant 4 bits of the first pixel (and the least significant 4 bits of the second pixel are in the most significant 4 bits of this third data byte).  Similar to the MONO12_PACKED formats, this packing scheme also facilitates easy conversion to 8 bit formats by ‘ignoring’ bytes that only contain the least significant pixel data.


Example camera configured for:


  • MONO12_PACKED_MSFIRST
  • ROI is 8X8.


The camera is looking at a bright white image and all pixels are saturated (i.e, at max value).

Looking at the frame data in memory on a byte-by-byte basis:

 

 0x00A92D20  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D2C  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D38  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D44  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D50  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D5C  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D68  ff ff ff ff ff ff ff ff ff ff ff ff
 0x00A92D74  ff ff ff ff ff ff ff ff ff ff ff ff

 

MONO16


Each sensor pixel is represented as a 10-bit or 12-bit digital number (DN). The number of bits 10 or 12 depends on the capabilities of the camera and can be determined by querying the feature FEATURE_MAX_PIXEL_SIZE. Note that this feature is supported only in API versions 6.18 or later. If this feature is not supported by your camera, only 10-bit values are supported.


Whether 10- or 12-bit data, the data from each sensor pixel takes up 16 bits (2 bytes).


The frame is organized as an array of sensor pixels, starting at top left, moving left to right, top to bottom.


The camera always uses the uppermost bits of a 16 bit value. On a 10-bit camera, the pixel values range from 0x0000 to 0xFFC0 (the bottom 6 bits aren't used), whereas on a 12-bit camera the pixel values range from 0x0000 to 0xFFF0 (the bottom 4 bits aren't used). 


The 16-bit data from the camera arrives into the computer in big-endian order. Because Wintel (Window & Intel/Intel compatible) computers are little-endian, a simple read of a 16-bit pixel value will result in a value that is byte-swapped. 


Example 
 

PL-B771 camera configured for:


  • MONO16
  • camera supports 10 bit data


The camera is looking at a bright white image so that all pixels are saturated. For 10-bit data we would  expect each pixel to have a value of 1023 (0x3FF). 


Looking at the frame in memory on a byte-by byte basis (hex values):


 0x00A94FF8  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0
 0x00A95008  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0  
 0x00A95018  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0  
 0x00A95028  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0  
 0x00A95038  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0  
 0x00A95048  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0  
 0x00A95058  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0  
 0x00A95068  ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0 ff c0

 


Looking at the data above in big-endian order, we see that the first pixel has a value of 0xFFC0, in other words, all 10 uppermost bits of the 16 bit value are set. However, we can't do big-endian reads on Wintel computers; a 16-bit (little-endian) read of the first pixel will return a value of 0xC0FF. To get the expected value of 0x03FF requires a bit of bit twiddling. 


 

 // Read the first pixel value

 U16 value = *((U16*)0x00A94FF8); 

 // Step 1 - Convert from big-endian to little-endian

 U16 correctValue = ((value &amp; 0xFF00) >> 8) | ((value &amp; 0x00FF) << 8);

 // Step 2 - 'Normalize' to get rid of unused bits
 // For 10 bits, bottom 6 bits aren't used. (16-10)
 // For 12 bits, bottom 4 bits aren't used. (16-12)

 correctValue >>= 6;

 

BAYER8


Each sensor pixel is represented as an 8-bit DN value that takes up 8 bits (1 byte).  The frame is organized as an array of sensor pixels, starting at top left, moving left to right, top to bottom.  Atop the sensor is a Bayer filter, a colour filter array (CFA) which limits which colours are seen by an individual sensor pixel. The Bayer pattern will be either Green-Red-Blue-Green (GRBG) or Green-Blue-Red-Green (GBRG), depending on the sensor. The variation of BAYER8 in use can be determined from the PixelFormat field of the Frame Descriptor.  For example:


  • Pixel format 3 = PIXEL_FORMAT_BAYER*_GRBG
  • Pixel format 8 = PIXEL_FORMAT_BAYER*_GBRG


See Appendix A for a list of cameras and the Bayer pattern they use.



Example


PL-B742 camera configured for:


  • Bayer8
  • ROI of 8X8


The camera is looking at a bright pure red image. The pixel format for the camera is PIXEL_FORMAT_BAYER8_GBRG. Looking at the frame data in memory on a byte-by-byte basis:

 

 0x00A92B98  00 00 00 00 00 00 00 00  
 0x00A92BA0  ff 00 ff 00 ff 00 ff 00  
 0x00A92BA8  00 00 00 00 00 00 00 00  
 0x00A92BB0  ff 00 ff 00 ff 00 ff 00  
 0x00A92BB8  00 00 00 00 00 00 00 00  
 0x00A92BC0  ff 00 ff 00 ff 00 ff 00  
 0x00A92BC8  00 04 00 00 00 00 00 00  
 0x00A92BD0  ff 00 ff 00 ff 00 ff 00
 ...  

 

Using the camera configuration, but now looking at a bright blue image we see this data:

 

 0x00A92B98  00 ff 00 ff 00 ff 00 ff  
 0x00A92BA0  00 00 00 00 00 00 00 00  
 0x00A92BA8  00 ff 00 ff 00 ff 00 ff  
 0x00A92BB0  00 00 00 00 00 00 00 00  
 0x00A92BB8  00 ff 00 ff 00 ff 00 ff  
 0x00A92BC0  00 00 00 00 00 00 00 00  
 0x00A92BC8  00 ff 00 ff 00 ff 00 ff  
 0x00A92BD0  00 00 00 00 00 00 00 00

 

Using the same configuration, but now looking at a bright green image: 

 

 0x00A92B98  ff 00 ff 00 ff 00 ff 00
 0x00A92BA0  00 ff 00 ff 00 ff 00 ff  
 0x00A92BA8  ff 00 ff 00 ff 00 ff 00
 0x00A92BB0  00 ff 00 ff 00 ff 00 ff  
 0x00A92BB8  ff 00 ff 00 ff 00 ff 00
 0x00A92BC0  00 ff 00 ff 00 ff 00 ff  
 0x00A92BC8  ff 00 ff 00 ff 00 ff 00
 0x00A92BD0  00 ff 00 ff 00 ff 00 ff
 ...

 


From this it can be seen that the CFA over this sensor is arranged as:

 

 0x00A92B98  G1 BB G1 BB G1 BB G1 BB 
 0x00A92BA0  RR G2 RR G2 RR G2 RR G2 
 0x00A92BA8  G1 BB G1 BB G1 BB G1 BB 
 0x00A92BB0  RR G2 RR G2 RR G2 RR G2 
 0x00A92BB8  G1 BB G1 BB G1 BB G1 BB 
 0x00A92BC0  RR G2 RR G2 RR G2 RR G2 
 0x00A92BC8  G1 BB G1 BB G1 BB G1 BB 
 0x00A92BD0  RR G2 RR G2 RR G2 RR G2
 ... 

 

With PIXEL_FORMAT_BAYER*_GBRG, the GBRG refers to the upper-left quartet of sensor pixels, and this quartet (Bayer pattern) is repeated over the entire sensor.


BAYER16 
 

Each sensor pixel is represented as an 10 bit DN value that takes up 16 bits (2 bytes).  For the organization of an individual pixel's bits within the 16-bits, see MONO16. As with BAYER8, there's a CFA above the sensor.  The Bayer pattern will be either GRBG or GBRG, depending on the sensor.


  • Pixel format  4 = PIXEL_FORMAT_BAYER16_GRBG
  • Pixel format 11 = PIXEL_FORMAT_BAYER16_GBRG


See Appendix A for a list of cameras and the Bayer pattern they use.


Example 
 
 

  

PL-B742 camera configured for:


  • BAYER16
  • ROI of 8x8

... 

Camera is looking at a bright pure red image. The pixel format for the camera is PIXEL_FORMAT_BAYER!^_GBRG


Looking at the frame data in memory on a byte-by-byte basis:

 

 0x00A92B98  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  

 0x00A92BA8  ff c0 00 00 ff c0 00 00 ff c0 00 00 ff c0 00 00  

 0x00A92BB8  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

 0x00A92BC8  ff c0 00 00 ff c0 00 00 ff c0 00 00 ff c0 00 00  

 0x00A92BD8  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  

 0x00A92BE8  ff c0 00 00 ff c0 00 00 ff c0 00 00 ff c0 00 00  

 0x00A92BF8  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  

 0x00A92C08  ff c0 00 00 ff c0 00 00 ff c0 00 00 ff c0 00 00
 ...  

 

BAYER12_PACKED


Each sensor pixel is represented as a 12 bit DN value that takes up 12 bits such that it takes 3 bytes to represent 2 pixels.  For the organization of an individual pixel's bits within the 12-bits, see MONO12_PACKED. As with BAYER8, there's a CFA above the sensor.  The Bayer pattern will be either GRBG, RGGB, or GBRG depending on the sensor. 


  • Pixel format 14 = PIXEL_FORMAT_BAYER16_GRBG
  • Pixel format 15 = PIXEL_FORMAT_BAYER16_RGGB
  • Pixel format 16 = PIXEL_FORMAT_BAYER16_GBRG
 
 

See Appendix A for a list of cameras and the Bayer pattern they use.

 


 

Example 
 

 

 

 

Camera Configured for:

 


 
  • BAYER12_PACKED
  • ROI of 8x8
 
  

Camera is looking at a bright pure red image.  The pixel format for the camera is PIXEL_FORMAT_BAYER12_PACKED_GBRG

 


 

Looking at the frame data in memory on a byte-by-byte basis:

 

 

 0x00A92B98  00 00 00 00 00 00 00 00 00 00 00 00 
 0x00A92BA4  ff 0f 00 ff 0f 00 ff 0f 00 ff 0f 00
 0x00A92BB0  00 00 00 00 00 00 00 00 00 00 00 00
 0x00A92BBC  ff 0f 00 ff 0f 00 ff 0f 00 ff 0f 00
 0x00A92BC8  00 00 00 00 00 00 00 00 00 00 00 00
 0x00A92BD4  ff 0f 00 ff 0f 00 ff 0f 00 ff 0f 00
 0x00A92BE0  00 00 00 00 00 00 00 00 00 00 00 00
 0x00A92BEC  ff 0f 00 ff 0f 00 ff 0f 00 ff 0f 00

 

BAYER12_PACKED_MSFIRST


Each sensor pixel is represented as a 12 bit DN value and images are packed such that it takes 3 bytes to represent 2 pixels.  For the organization of an individual pixel's bits within the 12-bits, see MONO12_PACKED_MSFIRST. As with BAYER8, there's a CFA above the sensor.  The Bayer pattern will be either GRBG, RGGB, GBRG, or BGGR depending on the sensor. 


  • Pixel format 21 = PIXEL_FORMAT_BAYER12_GRBG_PACKED_MSFIRST
  • Pixel format 22 = PIXEL_FORMAT_BAYER12_RGGB_PACKED_MSFIRST
  • Pixel format 23 = PIXEL_FORMAT_BAYER12_GBRG_PACKED_MSFIRST
  • Pixel format 24 = PIXEL_FORMAT_BAYER12_BGGR_PACKED_MSFIRST


See Appendix A for a list of cameras and the Bayer pattern they use.


Example 
 
 

camera configured for:


  • BAYER12_PACKED_MSFIRST
  • ROI of 8x8 
 
 

Camera is looking at a bright pure red image. The pixel format for the camera is PIXEL_FORMAT_BAYER12_PACKED_GBRG.

 


 

Looking at the frame data in memory on a byte-by-byte basis:

 

 0x00A92B98  00 00 00 00 00 00 00 00 00 00 00 00 
 0x00A92BA4  ff 00 0f ff 00 0f ff 00 0f ff 00 0f
 0x00A92BB0  00 00 00 00 00 00 00 00 00 00 00 00
 0x00A92BBC  ff 00 0f ff 00 0f ff 00 0f ff 00 0f
 0x00A92BC8  00 00 00 00 00 00 00 00 00 00 00 00
 0x00A92BD4  ff 00 0f ff 00 0f ff 00 0f ff 00 0f
 0x00A92BE0  00 00 00 00 00 00 00 00 00 00 00 00
 0x00A92BEC  ff 00 0f ff 00 0f ff 00 0f ff 00 0f


YUV422


The camera converts each sensor pixel to a YUV (aka YCbCr) triplet. But, rather than transmitting the entire triplet for each individual sensor pixel, the following pattern is sent:


U Y | V Y


This is for two pixels of 8 bits each.  For the first pixel, only the U and Y values are sent.  For the second pixel, only the V and Y values are sent.


Example 
 
 

PL-B686CF camera configured for:


  • YUV422
  • ROI of 16x16


Camera is looking at a bright pure red image. According to the image statistics - found in the histogram tool of PixeLINK Capture OEM:


  • Average Y is 76 (0X4C)
  • Average U is 85 (0X55)
  • Average V is 255 (0XFF)


The Frame Descriptor Pixel Format is 2, i.e. PIXEL_FORMAT_YUV422. Looking at the frame data in memory on a byte-by-byte basis:

 

 0x00A95178  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A951A8  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A951D8  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95208  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95238  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95268  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95298  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A952C8  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A952F8  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95328  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95358  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95388  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A953B8  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A953E8  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95418  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

 0x00A95448  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 55 4c ff 4c
 ... 

 

The UYVY pattern can be seen below:

 

 0x00A95178  55 4c ff 4c 55 4c ff 4c 55 4c ff 4c 

              U  Y  V  Y  U  Y  V  Y  U  Y  V  Y

 


Appendix A - Bayer Patterns Used by PixeLINK Cameras


The Bayer pattern depends only upon the internal sensor used. The descriptor accompanying each frame will identify the pixel format with the correct CFA.