Baumer工业相机堡盟相机如何使用偏振功能(偏振相机优点和行业应用)(C++)

2023-11-04 08:30

本文主要是介绍Baumer工业相机堡盟相机如何使用偏振功能(偏振相机优点和行业应用)(C++),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

项目场景:

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

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

Baumer相机系列中偏振相机的特殊功能有助于在一些特殊应用场合使用。


技术背景

偏光工业相机相机旨在捕捉偏光,以提高图像质量,减少各种工业应用中的眩光。

这些相机的镜头中集成了偏振滤光片,可以帮助改善图像对比度,提高色彩饱和度,并减少闪亮表面的反射。

偏光工业相机的一些关键特征可能包括高分辨率、快速帧率、适用于工业环境的坚固设计,以及与不同照明条件的兼容性。

此外,它们可能具有触发、曝光控制和图像处理能力等功能,有助于为检查和分析目的捕获清晰和详细的图像。

  

  


代码分析

Baumer工业相机堡盟相机SDK示例中020_Polarized.cpp详细介绍了如何配置相机偏振功能。

软件SDK示例地址如下所示:Baumer_GAPI_SDK_2.12.0_win_x86_64_cpp\examples\src\0_Common\020_Polarized\020_Polarized.cpp

Baumer工业相机系列中VCXU-50MP和VCXG-50MP为偏振工业相机。 

Model

Resolution

Sensor

Frame rate           GigE          USB3

VCXG-50MP

5 MP

2448 × 2048

Sony IMX250MZR (2/3″, 3.45 µm)

35|24

-

VCXU-50MP

5 MP

2448 × 2048

Sony IMX250MZR (2/3″, 3.45 µm)

-

77

该示例描述了如何使用所提供的堡盟GAPI API功能来配置相机并计算所需的偏振数据(AOL、DOP、ADOLP、Intensity)

代码整体结构相对简单,在相机初始化后进行相机的偏振功能使用,部分核心代码如下: 

std::cout << std::endl;
std::cout << "POLARIZER CONFIGURATION" << std::endl;
std::cout << "#######################" << std::endl << std::endl;try {// Enable or disable interpolationpolarizer.EnableInterpolation(enableInterpolation);std::cout << "Interpolation " << (enableInterpolation ? "on" : "off") << std::endl;// Configure the polarizer to use the calibration values from the camera devicepolarizer.ReadCalibrationData(pDevice);
}
catch (BGAPI2::Exceptions::IException& ex) {std::cout << "ExceptionType:    " << ex.GetType() << std::endl;std::cout << "ErrorDescription: " << ex.GetErrorDescription() << std::endl;std::cout << "in function:      " << ex.GetFunctionName() << std::endl;
}// Enable requested polarisation formats and create image containers
try {for (std::set<std::string>::const_iterator component = sComponents.begin();component != sComponents.end(); component++) {std::map<std::string, BGAPI2::Polarizer::Formats>::const_iterator c = supportedComponents.find(*component);if (c == supportedComponents.end()) {std::cout << *component << ":" << " not supported" << std::endl;returncode = (returncode == 0) ? 1 : returncode;} else if (requestedComponents.find(c->second) == requestedComponents.end()) {polarizer.Enable(c->second, true);std::cout << *component << ":" << " enabled" << std::endl;requestedComponents.insert(std::pair<BGAPI2::Polarizer::Formats, BGAPI2::Image*>(c->second, imgProc.CreateImage()));}}
}
catch (BGAPI2::Exceptions::IException& ex) {returncode = (returncode == 0) ? 1 : returncode;std::cout << "ExceptionType:    " << ex.GetType() << std::endl;std::cout << "ErrorDescription: " << ex.GetErrorDescription() << std::endl;std::cout << "in function:      " << ex.GetFunctionName() << std::endl;
}if (returncode) {ReleaseAllResources(pSystem, pInterface, pDevice, pDataStream, &requestedComponents);return returncode;
}

下面是几个偏振相机常使用的函数方法代码:

void GetSupportedComponents(BGAPI2::Polarizer* const polarizer,const bool is_color,std::string* const help) {BGAPI2::Polarizer::formatlist list;for (BGAPI2::Polarizer::formatlist::const_iterator it = list.begin(); it != list.end(); it++) {if (BGAPI2::Polarizer::IsFormatAvailable(*it, is_color)) {std::string componentName = polarizer->GetFormatString(*it).get();supportedComponents.insert(std::pair<std::string, BGAPI2::Polarizer::Formats>(componentName, *it));if (help->length() > 0) {*help += "/";}*help += componentName;}}
}// Get the required components from the command line argument
void argumentComponent(const Argument& /*argument*/, const ArgumentMode mode, const char* const pParam) {static bool bClearComponents = true;if (mode == eArgumentInit) {sComponents.clear();const char* components[] = { "Intensity", "AOP", "DOLP", "POL", "UNPOL", "ADOLP" };for (unsigned int i = 0; i < sizeof(components) / sizeof(components[0]); i++) {if (supportedComponents.find(components[i]) != supportedComponents.end()) {sComponents.insert(components[i]);}}bClearComponents = true;} else {if (bClearComponents) {sComponents.clear();bClearComponents = false;}if (pParam != NULL) {if (sComponents.find(pParam) == sComponents.end()) {sComponents.insert(pParam);}}}
}// Get the Angle Offset from the command line parameter (if provided) and use it for the calculation
void argumentAopOffset(const Argument& /*argument*/, const ArgumentMode mode, const char* const pParam) {if (mode == eArgumentInit) {g_aopOffset = 0.0;g_bAopOffset = false;} else {double value = 0.0;int ret_value = 0;
#if defined(_WIN32)ret_value = sscanf_s(pParam, "%lf", &value);
#elseret_value = sscanf(pParam, "%lf", &value);
#endifif ((pParam != NULL) && (ret_value == 1)) {g_aopOffset = value;g_bAopOffset = true;}}
}// Helper to filter found cameras devices and select only polarization camera for this example
bool PolarizationDeviceFilter(BGAPI2::Device* const pDevice) {return BGAPI2::Polarizer::IsPolarized(pDevice, NULL);
}int GetFirstDevice(DeviceMatch* const pMatch,bool(*pSystemFilter)(BGAPI2::System* pSystem),bool(*pInterfaceFilter)(BGAPI2::Interface* pInterface),bool(*pDeviceFilter)(BGAPI2::Device* pDevice),std::ostream* log) {int returncode = 0;*log << "SYSTEM LIST" << std::endl;*log << "###########" << std::endl << std::endl;try {BGAPI2::SystemList* pSystemList = BGAPI2::SystemList::GetInstance();// Counting available systems (TL producers)pSystemList->Refresh();*log << "5.1.2   Detected systems:  " << pSystemList->size() << std::endl;// System device informationfor (BGAPI2::SystemList::iterator sysIterator = pSystemList->begin();sysIterator != pSystemList->end();sysIterator++) {BGAPI2::System* const pSystem = *sysIterator;*log << "  5.2.1   System Name:     " << pSystem->GetFileName() << std::endl;*log << "          System Type:     " << pSystem->GetTLType() << std::endl;*log << "          System Version:  " << pSystem->GetVersion() << std::endl;*log << "          System PathName: " << pSystem->GetPathName() << std::endl << std::endl;}for (BGAPI2::SystemList::iterator sysIterator = pSystemList->begin();sysIterator != pSystemList->end();sysIterator++) {*log << "SYSTEM" << std::endl;*log << "######" << std::endl << std::endl;BGAPI2::System* const pSystem = *sysIterator;pMatch->pSystem = pSystem;try {pSystem->Open();*log << "5.1.3   Open next system " << std::endl;*log << "  5.2.1   System Name:     " << pSystem->GetFileName() << std::endl;*log << "          System Type:     " << pSystem->GetTLType() << std::endl;*log << "          System Version:  " << pSystem->GetVersion() << std::endl;*log << "          System PathName: " << pSystem->GetPathName() << std::endl << std::endl;*log << "        Opened system - NodeList Information " << std::endl;*log << "          GenTL Version:   " << pSystem->GetNode("GenTLVersionMajor")->GetValue() << "."<< pSystem->GetNode("GenTLVersionMinor")->GetValue() << std::endl << std::endl;const char* pCloseSystemReason = "???";if ((pSystemFilter != NULL) && (pSystemFilter(pSystem) == false)) {pCloseSystemReason = "skipped";} else {*log << "INTERFACE LIST" << std::endl;*log << "##############" << std::endl << std::endl;try {BGAPI2::InterfaceList* pInterfaceList = pSystem->GetInterfaces();// Count available interfacespInterfaceList->Refresh(100);  // timeout of 100 msec*log << "5.1.4   Detected interfaces: " << pInterfaceList->size() << std::endl;// Interface informationfor (BGAPI2::InterfaceList::iterator ifIterator = pInterfaceList->begin();ifIterator != pInterfaceList->end();ifIterator++) {BGAPI2::Interface* const pInterface = *ifIterator;*log << "  5.2.2   Interface ID:      " << pInterface->GetID() << std::endl;*log << "          Interface Type:    " << pInterface->GetTLType() << std::endl;*log << "          Interface Name:    " << pInterface->GetDisplayName() << std::endl<< std::endl;}*log << "INTERFACE" << std::endl;*log << "#########" << std::endl << std::endl;for (BGAPI2::InterfaceList::iterator ifIterator = pInterfaceList->begin();ifIterator != pInterfaceList->end();ifIterator++) {try {// Open the next interface in the listBGAPI2::Interface* const pInterface = *ifIterator;pMatch->pInterface = pInterface;*log << "5.1.5   Open interface " << std::endl;*log << "  5.2.2   Interface ID:      " << pInterface->GetID() << std::endl;*log << "          Interface Type:    " << pInterface->GetTLType() << std::endl;*log << "          Interface Name:    " << pInterface->GetDisplayName() << std::endl;pInterface->Open();const char* pReason = "???";if ((pInterfaceFilter != NULL) && (pInterfaceFilter(pInterface) == false)) {pReason = "skipped";} else {// Search for any camera is connected to this interfaceBGAPI2::DeviceList* const pDeviceList = pInterface->GetDevices();pDeviceList->Refresh(100);if (pDeviceList->size() == 0) {pReason = "no camera found";} else {*log << "   " << std::endl;*log << "        Opened interface - NodeList Information " << std::endl;if (pInterface->GetTLType() == "GEV") {*log << "          GevInterfaceSubnetIPAddress: "<< pInterface->GetNode("GevInterfaceSubnetIPAddress")->GetValue()<< std::endl;*log << "          GevInterfaceSubnetMask:      "<< pInterface->GetNode("GevInterfaceSubnetMask")->GetValue()<< std::endl;}if (pInterface->GetTLType() == "U3V") {// log << "          NodeListCount:     "// << pInterface->GetNodeList()->GetNodeCount() << std::endl;}// Open the first matching camera in the listtry {// Counting available cameras*log << "5.1.6   Detected devices:         "<< pDeviceList->size() << std::endl;// Device information before openingfor (BGAPI2::DeviceList::iterator devIterator = pDeviceList->begin();devIterator != pDeviceList->end();devIterator++) {BGAPI2::Device* const pDevice = *devIterator;*log << "  5.2.3   Device DeviceID:        "<< pDevice->GetID() << std::endl;*log << "          Device Model:           "<< pDevice->GetModel() << std::endl;*log << "          Device SerialNumber:    "<< pDevice->GetSerialNumber() << std::endl;*log << "          Device Vendor:          "<< pDevice->GetVendor() << std::endl;*log << "          Device TLType:          "<< pDevice->GetTLType() << std::endl;*log << "          Device AccessStatus:    "<< pDevice->GetAccessStatus() << std::endl;*log << "          Device UserID:          "<< pDevice->GetDisplayName() << std::endl << std::endl;}for (BGAPI2::DeviceList::iterator devIterator = pDeviceList->begin();devIterator != pDeviceList->end();devIterator++) {try {BGAPI2::Device* const pDevice = *devIterator;pMatch->pDevice = pDevice;GetDeviceInfo(log, pDevice, true);if ((pDeviceFilter == NULL) || (pDeviceFilter(pDevice) == true)) {return returncode;}*log << "        Close device (skipped) "<< std::endl << std::endl;pDevice->Close();pMatch->pDevice = NULL;}catch (BGAPI2::Exceptions::ResourceInUseException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << " Device  " << devIterator->GetID() << " already opened "<< std::endl;*log << " ResourceInUseException: " << ex.GetErrorDescription()<< std::endl;}catch (BGAPI2::Exceptions::AccessDeniedException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << " Device  " << devIterator->GetID() << " already opened "<< std::endl;*log << " AccessDeniedException " << ex.GetErrorDescription()<< std::endl;}}}catch (BGAPI2::Exceptions::IException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << "ExceptionType:    " << ex.GetType() << std::endl;*log << "ErrorDescription: " << ex.GetErrorDescription() << std::endl;*log << "in function:      " << ex.GetFunctionName() << std::endl;}pReason = "no camera match";}}*log << "5.1.13   Close interface (" << pReason << ") " << std::endl << std::endl;pInterface->Close();pMatch->pInterface = NULL;}catch (BGAPI2::Exceptions::ResourceInUseException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << " Interface " << ifIterator->GetID() << " already opened " << std::endl;*log << " ResourceInUseException: " << ex.GetErrorDescription() << std::endl;}}}catch (BGAPI2::Exceptions::IException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << "ExceptionType:    " << ex.GetType() << std::endl;*log << "ErrorDescription: " << ex.GetErrorDescription() << std::endl;*log << "in function:      " << ex.GetFunctionName() << std::endl;}pCloseSystemReason = "no camera match";}*log << "        Close system (" << pCloseSystemReason << ") " << std::endl << std::endl;pSystem->Close();pMatch->pSystem = NULL;}catch (BGAPI2::Exceptions::ResourceInUseException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << " System " << sysIterator->GetID() << " already opened " << std::endl;*log << " ResourceInUseException: " << ex.GetErrorDescription() << std::endl;}}}catch (BGAPI2::Exceptions::IException& ex) {returncode = (returncode == 0) ? 1 : returncode;*log << "ExceptionType:    " << ex.GetType() << std::endl;*log << "ErrorDescription: " << ex.GetErrorDescription() << std::endl;*log << "in function:      " << ex.GetFunctionName() << std::endl;}return returncode;
}// Helper to Display various information of the camera
void GetDeviceInfo(std::ostream* log, BGAPI2::Device* const pDevice, const bool bOpen) {*log << "5.1.7   Open device " << std::endl;*log << "          Device DeviceID:        " << pDevice->GetID() << std::endl;*log << "          Device Model:           " << pDevice->GetModel() << std::endl;*log << "          Device SerialNumber:    " << pDevice->GetSerialNumber() << std::endl;*log << "          Device Vendor:          " << pDevice->GetVendor() << std::endl;*log << "          Device TLType:          " << pDevice->GetTLType() << std::endl;*log << "          Device AccessStatus:    " << pDevice->GetAccessStatus() << std::endl;*log << "          Device UserID:          " << pDevice->GetDisplayName() << std::endl << std::endl;if (bOpen)pDevice->Open();*log << "        Opened device - RemoteNodeList Information " << std::endl;*log << "          Device AccessStatus:    " << pDevice->GetAccessStatus() << std::endl;BGAPI2::NodeMap* const pRemoteNodeList = pDevice->GetRemoteNodeList();// Serial numberif (pRemoteNodeList->GetNodePresent("DeviceSerialNumber")) {*log << "          DeviceSerialNumber:     "<< pRemoteNodeList->GetNode("DeviceSerialNumber")->GetValue() << std::endl;} else if (pRemoteNodeList->GetNodePresent("DeviceID")) {*log << "          DeviceID (SN):          "<< pRemoteNodeList->GetNode("DeviceID")->GetValue() << std::endl;} else {*log << "          SerialNumber:           Not Available " << std::endl;}// Display DeviceManufacturerInfoif (pRemoteNodeList->GetNodePresent("DeviceManufacturerInfo")) {*log << "          DeviceManufacturerInfo: "<< pRemoteNodeList->GetNode("DeviceManufacturerInfo")->GetValue() << std::endl;}// Display DeviceFirmwareVersion or DeviceVersionif (pRemoteNodeList->GetNodePresent("DeviceFirmwareVersion")) {*log << "          DeviceFirmwareVersion:  "<< pRemoteNodeList->GetNode("DeviceFirmwareVersion")->GetValue() << std::endl;} else if (pRemoteNodeList->GetNodePresent("DeviceVersion")) {*log << "          DeviceVersion:          "<< pRemoteNodeList->GetNode("DeviceVersion")->GetValue() << std::endl;} else {*log << "          DeviceVersion:          Not Available " << std::endl;}if (pDevice->GetTLType() == "GEV") {*log << "          GevCCP:                 "<< pRemoteNodeList->GetNode("GevCCP")->GetValue() << std::endl;*log << "          GevCurrentIPAddress:    "<< pRemoteNodeList->GetNode("GevCurrentIPAddress")->GetValue() << std::endl;*log << "          GevCurrentSubnetMask:   "<< pRemoteNodeList->GetNode("GevCurrentSubnetMask")->GetValue() << std::endl;}*log << std::endl;
}// Release all allocated resources
int ReleaseAllResources(BGAPI2::System* pSystem,BGAPI2::Interface* pInterface,BGAPI2::Device* pDevice,BGAPI2::DataStream* pDataStream,std::map<BGAPI2::Polarizer::Formats, BGAPI2::Image*>* requestedComponents) {try {if (pDataStream) {pDataStream->Close();}if (pDevice) {pDevice->Close();}if (pInterface) {pInterface->Close();}if (pSystem) {pSystem->Close();}BGAPI2::SystemList::ReleaseInstance();for (std::map<BGAPI2::Polarizer::Formats, BGAPI2::Image*>::iterator it = requestedComponents->begin();it != requestedComponents->end(); it++) {if (it->second != NULL) {it->second->Release();it->second = NULL;}}requestedComponents->clear();}catch (BGAPI2::Exceptions::IException& ex) {std::cout << "ExceptionType:    " << ex.GetType() << std::endl;std::cout << "ErrorDescription: " << ex.GetErrorDescription() << std::endl;std::cout << "in function:      " << ex.GetFunctionName() << std::endl;return 1;}return 0;
}

偏振功能的优点

1、减少闪亮或光亮表面的眩光和反射,提高对比度以更好地检测缺陷或表面特征,并加强颜色区分。

2、它们还可以帮助提高汽车、电子和制造业等行业的自动检测和质量控制过程的准确性和速度。

3、偏振照相机在户外应用中很有用,因为那里有大量的阳光或大气雾霾,否则可能会干扰图像的清晰度。


偏振工业相机相对于普通工业相机的优势


偏光工业相机与普通工业相机相比有几个优点。

1、它们使用偏振滤光片来捕捉在单一方向上振动的光波,减少眩光和闪亮表面的反射。这导致了更清晰和更精确的图像,使其更容易识别高反射表面的缺陷或异常情况。

2、偏光相机还提供更好的对比度和颜色精度,允许精确的颜色测量和分析。

3、偏光相机可以在恶劣的环境条件下使用,并能捕捉到普通相机难以看到的物体的图像。


Baumer偏振相机的行业应用

偏光工业相机通常用于各种工业应用,如质量控制、缺陷检查、材料分析和表面检查。

它们有助于消除眩光和反射,提高玻璃、塑料、金属等各种材料的图像对比度和准确性。

偏光工业相机在检测隐藏的缺陷或污染物、识别材料中的应力点和检查隐藏结构方面也很有用。它们通常用于汽车、航空航天、电子和制造业等行业。

下面简单介绍几个能体现出偏振特性的行业应用:

  

  

  


这篇关于Baumer工业相机堡盟相机如何使用偏振功能(偏振相机优点和行业应用)(C++)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/344517

相关文章

Java学习手册之Filter和Listener使用方法

《Java学习手册之Filter和Listener使用方法》:本文主要介绍Java学习手册之Filter和Listener使用方法的相关资料,Filter是一种拦截器,可以在请求到达Servl... 目录一、Filter(过滤器)1. Filter 的工作原理2. Filter 的配置与使用二、Listen

Pandas使用AdaBoost进行分类的实现

《Pandas使用AdaBoost进行分类的实现》Pandas和AdaBoost分类算法,可以高效地进行数据预处理和分类任务,本文主要介绍了Pandas使用AdaBoost进行分类的实现,具有一定的参... 目录什么是 AdaBoost?使用 AdaBoost 的步骤安装必要的库步骤一:数据准备步骤二:模型

使用Pandas进行均值填充的实现

《使用Pandas进行均值填充的实现》缺失数据(NaN值)是一个常见的问题,我们可以通过多种方法来处理缺失数据,其中一种常用的方法是均值填充,本文主要介绍了使用Pandas进行均值填充的实现,感兴趣的... 目录什么是均值填充?为什么选择均值填充?均值填充的步骤实际代码示例总结在数据分析和处理过程中,缺失数

C语言中位操作的实际应用举例

《C语言中位操作的实际应用举例》:本文主要介绍C语言中位操作的实际应用,总结了位操作的使用场景,并指出了需要注意的问题,如可读性、平台依赖性和溢出风险,文中通过代码介绍的非常详细,需要的朋友可以参... 目录1. 嵌入式系统与硬件寄存器操作2. 网络协议解析3. 图像处理与颜色编码4. 高效处理布尔标志集合

如何使用 Python 读取 Excel 数据

《如何使用Python读取Excel数据》:本文主要介绍使用Python读取Excel数据的详细教程,通过pandas和openpyxl,你可以轻松读取Excel文件,并进行各种数据处理操... 目录使用 python 读取 Excel 数据的详细教程1. 安装必要的依赖2. 读取 Excel 文件3. 读

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

Python使用getopt处理命令行参数示例解析(最佳实践)

《Python使用getopt处理命令行参数示例解析(最佳实践)》getopt模块是Python标准库中一个简单但强大的命令行参数处理工具,它特别适合那些需要快速实现基本命令行参数解析的场景,或者需要... 目录为什么需要处理命令行参数?getopt模块基础实际应用示例与其他参数处理方式的比较常见问http

C 语言中enum枚举的定义和使用小结

《C语言中enum枚举的定义和使用小结》在C语言里,enum(枚举)是一种用户自定义的数据类型,它能够让你创建一组具名的整数常量,下面我会从定义、使用、特性等方面详细介绍enum,感兴趣的朋友一起看... 目录1、引言2、基本定义3、定义枚举变量4、自定义枚举常量的值5、枚举与switch语句结合使用6、枚

使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)

《使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)》PPT是一种高效的信息展示工具,广泛应用于教育、商务和设计等多个领域,PPT文档中常常包含丰富的图片内容,这些图片不仅提升了... 目录一、引言二、环境与工具三、python 提取PPT背景图片3.1 提取幻灯片背景图片3.2 提取