Baumer industrial camera Baumer industrial camera uses the image callback function to save the image at full frame rate through BGAPISDK (C++)

Baumer industrial camera Baumer industrial camera uses image callback function to save image at full frame rate through BGAPISDK (C++)

  • Baumer industrial camera
  • Technical background of full frame rate preservation of Baumer industrial cameras
  • Baumer industrial camera uses camera image callback function through BGAPISDK
    • 1. Reference the appropriate class file
    • 2. Save at full frame rate in the camera image callback function through BGAPISDK
  • Advantages of saving images at full frame rate with Baumer industrial cameras
  • Industrial application of Baumer industrial cameras to save images at full frame rate

Baumer Industrial Camera

Baumer Industrial Cameras Baumer cameras are high-performance, high-quality industrial cameras that can be used in various application scenarios, such as object detection, counting and recognition, motion analysis and image processing.

Baumer’s 10 Gigabit cameras have excellent image processing performance and can transmit high-resolution images in real time. In addition, the camera features fast data transfer, low power consumption, easy integration, and high scalability.
?
Baumer industrial cameras are often used in the field of high-speed synchronous acquisition due to their superior and stable performance and quality, and usually use various image algorithms to improve the quality of the captured images.

Technical background of full frame rate storage of Baumer industrial cameras

Why do some applications need to use the full frame rate of industrial cameras to save images to hard disk space?

Because industrial cameras are designed to capture images with high speed and high resolution and are able to produce uncompressed images with high bit depth.

This allows detailed and high-quality images to be captured in real-time, which may be necessary in industries such as manufacturing and scientific research, where accurate and fast image data acquisition is critical.

Additionally, the use of industrial cameras ensures that there is no loss of image quality during image acquisition and storage, resulting in more reliable and consistent results.

This article here introduces the method of using the image callback function to save at full frame rate through BGAPISDK.

Baumer industrial camera uses the camera image callback function through BGAPISDK

The following describes how to use the camera image callback function of BGAPISDK for Baumer industrial cameras in C++

1. Reference the appropriate class file

The code is as follows (example):

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include "bgapi2_genicam/bgapi2_genicam.hpp"

2. Save at full frame rate in the camera image callback function through BGAPISDK

//Image callback function
//===================
void BGAPI2CALL BufferHandler( void * callBackOwner, Buffer * pBufferFilled )
{<!-- -->
CGigeDemoDlg* pDlg = (CGigeDemoDlg*)callBackOwner;
unsigned char* imagebuffer = NULL;
USES_CONVERSION;
try
{<!-- -->
if(pBufferFilled == NULL)
{<!-- -->

}
else if(pBufferFilled->GetIsIncomplete() == true)
{<!-- -->
// queue buffer again
pBufferFilled->QueueBuffer();
}
else
{<!-- -->
\t\t\t
pDlg->FrameID= pBufferFilled->GetFrameID(); //Get current image FrameID display frame rate
int frameid1 = pBufferFilled->GetFrameID();
int width = 0, height = 0;
width = (int)pBufferFilled->GetWidth();height = (int)pBufferFilled->GetHeight(); //Get current image pixel length and width
CString PixelFormat1 = (CString)pBufferFilled->GetPixelFormat(); //Get the current image pixel format
imagebuffer = (BYTE*)((bo_int64)pBufferFilled->GetMemPtr() + pBufferFilled->GetImageOffset());//Get the current image data
\t\t\t
#pragma region //Save image function is disabled (snapshot function)
\t\t\t
if(pDlg->m_bSaveImage & amp; & amp;!pDlg->m_strDirectory.IsEmpty())
{<!-- -->
CTime time = CTime::GetCurrentTime();
CString strtime;
strtime.Format(_T("\M-----"),time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time. GetSecond());
CString strpath = pDlg->m_strDirectory + strtime + "-";
CString strpath2;
strpath2.Format(_T("%s%d%s"),strpath,frameid1,_T(".jpg"));
//pDlg->FullFrameSaveImageName.Add(strpath2);
pDlg->SaveImageMono(strpath2, imagebuffer, width, height);
pDlg->TestNum0 =pDlg->TestNum0 + 1;
\t\t\t\t
if(pDlg->TestNum0==60)
{<!-- -->
pDlg->m_bSaveImage = false;
}
\t\t\t\t
}
#pragma endregion

\t\t\t\t\t\t\t
\t\t\t
delete pDlg->m_pBitmap;
pDlg->m_pBitmap = NULL;


// queue buffer again
pBufferFilled->QueueBuffer();
}
}
catch (BGAPI2::Exceptions::IException & ex)
{<!-- -->
CString str;
str.Format(_T("ExceptionType:%s! ErrorDescription:%s in function:%s"),ex.GetType(),ex.GetErrorDescription(),ex.GetFunctionName());
}
}

//Save the image data locally
bool CGigeDemoDlg::SaveImageMono(CString str, BYTE* bdata, int width, int height)
{<!-- -->
if (str. IsEmpty()) return false;
\t
HANDLE hFile = CreateFile(str,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
//DWORD dwError = GetLastError();
if (!hFile || hFile == INVALID_HANDLE_VALUE)
return false;
\t
//
BITMAPFILEHEADER FileHeader;
BITMAPINFOHEADER InfoHeader;
RGBQUAD rgbQuad[256];

DWORD dwImageSize = width*height;
FileHeader.bfType = 0x4D42; // "BM"
FileHeader.bfSize = sizeof(FileHeader) + sizeof(InfoHeader) + dwImageSize;
FileHeader.bfReserved1 = FileHeader.bfReserved2 = 0;
FileHeader.bfOffBits = sizeof(FileHeader) + sizeof(InfoHeader);
\t
ZeroMemory( &InfoHeader, sizeof(InfoHeader));
InfoHeader. biWidth = width;
InfoHeader.biHeight = -height;
InfoHeader.biSizeImage = dwImageSize;
InfoHeader. biBitCount = 8;
InfoHeader.biCompression = BI_RGB;
InfoHeader. biPlanes = 1;
InfoHeader.biSize = sizeof(BITMAPINFOHEADER);
InfoHeader.biXPelsPerMeter = 0xEC4;
InfoHeader.biYPelsPerMeter = 0xEC4;

for ( int i=0;i<256; i ++ )
{<!-- -->
rgbQuad[i].rgbBlue = (BYTE)i;
rgbQuad[i].rgbGreen = (BYTE)i;
rgbQuad[i].rgbRed = (BYTE)i;
rgbQuad[i].rgbReserved = 0;
}

DWORD Written;
WriteFile(hFile, (LPVOID) &FileHeader, sizeof(BITMAPFILEHEADER), &Written, NULL);
WriteFile(hFile, (LPVOID) & amp;InfoHeader, sizeof(BITMAPINFOHEADER), & amp;Written, NULL);
WriteFile(hFile, (LPVOID)rgbQuad,256*sizeof(RGBQUAD), &Written,NULL);
BYTE* src = bdata;
//int stride = m_Width*4;
\t

//DWORD bytes = m_Width * 4;
//for (unsigned long y = 0; y < NHEIGHT; y ++ ) {<!-- -->
WriteFile(hFile, (LPVOID)src, dwImageSize, &Written, NULL);
//}
CloseHandle(hFile);
return true;
}

The rendering effect is as follows:

The above test results show that 60 pictures can be saved at full frame rate, and appropriate modification can realize customized requirements.

Advantages of saving images at full frame rate of Baumer industrial cameras

1. Capable of capturing fast-moving objects clearly and precisely, which is very important for industries such as manufacturing and sports.

2. Through high-speed shooting, industrial cameras can capture images of moving parts and products, so that defects and quality problems can be found.

3. This technology is also critical for analyzing the movement of athletes and animals, providing insights for trainers and coaches.

4. The high-speed shooting function allows slow-motion playback, enabling people to further analyze the captured images.

5. Including the ability to capture images of fast-moving objects without motion blur, improve the accuracy of measuring the speed and position of objects, and the ability to detect and analyze rapid processes and changes in real time.

6. These cameras can be useful in a variety of industries, including manufacturing, automation, robotics, and more.

7. High-speed imaging can provide valuable insights into processes and help companies optimize their operations for greater efficiency and productivity.

Industrial application of Baumer industrial cameras saving images at full frame rate

Machine Vision: Industrial cameras that save images at full frame rate can be used in machine vision applications to capture images of fast-moving objects or processes. This can be used in manufacturing, quality control or inspection applications.

Robotics: Industrial cameras that save images at full frame rate can be used in robotics applications to capture images of fast-moving objects or to track the motion of robots. This can be used in manufacturing, assembly or pick and place applications.

Medical Imaging: Industrial cameras that save images at full frame rate can be used in medical imaging applications to capture high-speed images of internal organs or to track the movement of surgical instruments. This can be used for minimally invasive surgery or diagnostic imaging.

Sports Analysis: Industrial cameras that save images at full frame rates can be used in sports analysis applications to capture high-speed images of athletes in motion. This can be used for training or sports broadcast applications.

Aerospace: Industrial cameras that save images at full frame rate are used in aerospace to capture images of high-speed events such as rocket launches or aircraft tests.

In conclusion, the full frame rate image saving function of industrial cameras is ideal for any application that requires high-speed image acquisition, efficient data transfer, and real-time image analysis.