Please enable JavaScript to view this site.

IDS peak 2.10.0 / uEye+ firmware 3.34

Navigation: C: Programming with IDS peak > How to program

Converting images (comfortSDK)

Scroll Previous Top Next More

IDS Peak comfortSDK, genericSDK, IPL, and AFL developer manuals are external documents. Please contact us if you need them.

Debayering in the camera

Fig. 280: Debayering in the camera

Fig. 280: Debayering in the camera

Debayering in the software

Fig. 281: Debayering in the software

Fig. 281: Debayering in the software

Image conversion in the camera

To get already converted color images from the camera, the source pixel format must be set to an appropriate color format. For example, if an RGB format with 8 bits per color channel is selected, then this is 24 bits of data per pixel (= 3 bytes). The required bandwidth on the transfer line is thus 3 times as high as for the transfer of a Bayer format.

Querying supported source pixel formats in the camera

comfortC

PEAK_STATUS status = PEAK_STATUS_SUCCESS;
size_t pixelFormatCount = 0;
status = peak_PixelFormat_GetList(hCam, NULL, &pixelFormatCount);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
peak_pixel_format* pixelFormatList = (peak_pixel_format*) malloc(pixelFormatCount * sizeof(peak_pixel_format));
if (pixelFormatList == NULL) { /* Error handling ... */ }
status = peak_PixelFormat_GetList(hCam, pixelFormatList, &pixelFormatCount);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

Querying the current source pixel format

comfortC

peak_pixel_format pixelFormat;
status = peak_PixelFormat_Get(hCam, &pixelFormat);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

Setting the source pixel format

comfortC

status = peak_PixelFormat_Set(hCam, PEAK_PIXEL_FORMAT_RGB12);
if (PEAK_ERROR(status)) { /* Error handling ... */ }

Image conversion in IDS peak

The conversion of Bayer images can be done in IDS peak. For this, you use the functions "peak_IPL_...". (IPL: Image Processing Library). In the following example, Bayer images are received in the image acquisition loop and then converted to RBG format (see Receiving images). The"peak_IPL_ProcessFrame()" function creates a new IDS peak image with the desired target pixel format. Afterwards, the buffer can be returned to the buffer pool.

hint_info

Note that only with the "peak_IPL_ProcessFrame()" function a copy of the buffer is created. Before this, the buffer must not be returned to the buffer pool, otherwise the data may be overwritten!

Creating an image with target pixel format (RGB8) directly from buffer

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
 
status = peak_IPL_PixelFormat_Set(hCam, PEAK_PIXEL_FORMAT_RGB8);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
peak_frame_handle hFrame;
peak_frame_handle hResultFrame;
while (running)
{
  status = peak_Acquisition_WaitForFrame(hCam, 5000, &hFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
  status = peak_IPL_ProcessFrame(hCam, hFrame, &hResultFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
  // release original image
  status = peak_Frame_Release(hCam, hFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
  // do something with the converted image
 
  // release converted image
  status = peak_Frame_Release(hCam, hResultFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
}

Image with target pixel format (BGRa12) with flipping and 2x gain in software

comfortC

peak_status status = PEAK_STATUS_SUCCESS;
 
status = peak_IPL_PixelFormat_Set(hCam, PEAK_PIXEL_FORMAT_BGRA12);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
status = peak_IPL_Mirror_LeftRight_Enable(hCam, PEAK_TRUE);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
status = peak_IPL_Gain_Set(hCam, PEAK_GAIN_CHANNEL_MASTER, 2);
if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
// feel free to add more peak_IPL_... functions here
 
peak_frame_handle hFrame;
peak_frame_handle hResultFrame;
while (running)
{
  status = peak_Acquisition_WaitForFrame(hCam, 5000, &hFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
  status = peak_IPL_ProcessFrame(hCam, hFrame, &hResultFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
  // release original image
  status = peak_Frame_Release(hCam, hFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
  // do something with the converted, mirrored and gained image
 
  // release converted image
  status = peak_Frame_Release(hCam, hResultFrame);
  if (PEAK_ERROR(status)) { /* Error handling ... */ }
}

© 2024 IDS Imaging Development Systems GmbH