Baumer工业相机中偏振相机如何使用Baumer堡盟GAPI SDK来进行偏振数据的计算转换输出(C#)

 项目场景

Baumer工业相机堡盟相机是一种高性能、高质量的工业相机,可用于各种应用场景,如物体检测、计数和识别、运动分析和图像处理。  

Baumer的万兆网相机拥有出色的图像处理性能,可以实时传输高分辨率图像。此外,该相机还具有快速数据传输、低功耗、易于集成以及高度可扩展性等特点。

Baumer工业相机的BGAPI SDK给新型偏振照相机提供了测量所获图像的强度和偏振的能力。因此,它能够在应用程序中利用偏振信息。本应用说明描述了如何获得偏振信息。

工业相机产品:
Baumer堡盟VCXU-50MP和堡盟VCXG-50MP,GAPI SDK v2.9.2及以上。

Baumer工业相机的偏振功能的详细介绍应用可以参考下面的技术博客,本文只介绍偏振数据的使用:

Baumer工业相机堡盟相机如何使用偏振功能(偏振相机优点和行业应用)(C++)_格林威的博客-CSDN博客


技术背景

Baumer工业相机的BGAPI SDK可以提供相机的图像原始数据,Halcon具有极为巨大的图像处理库,在图像处理领域非常强大,功能丰富,使用于工业视觉检测。

工业相机的SDK(Software Development Kit)是为了方便开发人员对工业相机进行控制和图像采集而提供的一套软件工具。而Halcon是一款强大的机器视觉软件,能够进行图像处理、分析、识别等多种任务。

 Baumer工业相机中的偏振相机是基于索尼IMC250MZR传感器的。该传感器涂有一层金属网,可以过滤4个相邻像素的偏振信息。偏振角度被过滤以0°、45°、90°、135°的方式排列。
有了这些信息,就可以计算出以下数据:
偏振角(AOP)。
直线极化度(DOLP)
角度和直角极化度(ADOLP)
图像的强度。

使用BGAPI SDK的偏振相机的用法:
该相机只提供有关偏振的原始数据。不同偏振格式的计算格式的计算在主机系统上通过堡盟GAPI SDK完成。

这就减少了接口的必要带宽,因为数据只传输一次,而不是针对每种偏振格式(AOP、DOLP、ADOLP.Intensity)单独传输、强度)分别传输。


功能分析

偏振相机功能的描述
使用标准化的SFNC特性 "ComponentSelector "和 "ComponentEnable",GenICam
兼容的软件可以识别该相机提供原始偏振数据。这些特征不能被改变(只读)。
为了进行识别,应检查以下特征:
ComponentSelector = PolarizedRaw
ComponentEnable = True
为了实现对广泛的GenICam兼容软件的兼容性,堡盟没有引入自定义图像格式。
原始偏振数据使用标准格式Mono8、Mono10、Mono12或Mono13传输、Mono10、Mono12或Mono12p。
此外,该相机还提供了用于校准相机的必要功能,这些功能属于以下类别"校准控制" 这些功能充满了堡盟的校准值。

如有必要,还可使用"DeviceResetToDeliveryState "将把这些值重置为堡盟提供的校准值。


代码分析

为了确保计算尽可能少地使用资源并实现高帧率,有两种方法方法来处理数据。这里我们解释一下最重要的配置和使用的软件功能的使用。
如果一个应用只需要一种偏振格式(AOP、DOLP或ADOLP),最好使用一个单部分图像对象。单部分图像对象正好包含一个图像。

下面核心代码提供了偏振图像原始数据进行转换的相关用法。

核心代码如下所示:

BGAPI2.Buffer bufferFilled = dataStream.GetFilledBuffer(1000); //timeout 1000 msec
if (bufferFilled == null)
{
    System.Console.Write("Error: Buffer Timeout after 1000 msec\r\n");
}
else
{
    try
    {
        if (bufferFilled.IsIncomplete)
        {
            System.Console.Write("Error: Image is incomplete\r\n");
        }
        else if (bufferFilled.ImagePresent != true)
        {
            System.Console.Write("Error: Image not present\r\n");
        }
        else
        {
            // get information about the image from the buffer object
            uint width = (uint)(bufferFilled.Width);
            uint height = (uint)(bufferFilled.Height);
            IntPtr pBufferData = bufferFilled.MemPtr;
            ulong bufferDataSize = bufferFilled.MemSize;
            ulong imageOffset = bufferFilled.ImageOffset;
            ulong imageDataSize = (bufferDataSize > imageOffset) ? (bufferDataSize - imageOffset) : 0;
            IntPtr pImageData = (IntPtr)((ulong)(pBufferData) + imageOffset);

            System.Console.Write(" Image {0, 5:d} received in memory address {1:X}\r\n", bufferFilled.FrameID, pBufferData);

            /* For the first image, a new image object is created, all further images reuse the object and
                therefore just initialize it with new data */
            if (imagePolarized == null)
            {
                imagePolarized = imageProcessor.CreateImage(width, height, sPixelFormatRaw, pImageData, imageDataSize);

                // Enable the component to be calculated, disable all others
                EnableSingleComponent(imagePolarized, sComponent);
            }
            else
            {
                imagePolarized.Init(width, height, sPixelFormatRaw, pImageData, imageDataSize);
                /* As the pixel format is the same for all images captured, the enabled components and the active component selector
                    are preserved, so you don't need to enable components on every image. */
            }

            // Calculate the required Polarisation format using a direct transformation from raw polarized image.
            BGAPI2.Image component = imageProcessor.CreateTransformedImage(imagePolarized
                , (sComponent != "ADOLP") ? "Mono8" : "RGB8");

            System.Console.Write("  component image: {0}\r\n", component.NodeList["ComponentSelector"].Value);
            if (bSaveBrw)
            {
                string sFilename = sComponent + ".brw";
                component.NodeList["SaveBrw"].Value = sFilename;
            }

            component.Release();
            bSaveBrw = false;
        }
    }
    catch (BGAPI2.Exceptions.IException ex)
    {
        returncode = (returncode == 0) ? 1 : returncode;
        System.Console.Write("ExceptionType:    {0}\r\n", ex.GetType());
        System.Console.Write("ErrorDescription: {0}\r\n", ex.GetErrorDescription());
        System.Console.Write("in function:      {0}\r\n", ex.GetFunctionName());
    }
}

if (bufferFilled != null)
{
    // Queue buffer again
    bufferFilled.QueueBuffer();
}


CameraExplorer软件使用偏振功能

我们可以通过CameraExplorer软件用于查看和保存以下格式的偏振数据
AOP、DOLP、ADOLP和Intensity。
配置是可以在基本视图中使用 "偏振 "类别来完成。

如下图所示:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

格林威

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值