如何使用纯 C 在 Linux 上使用 GigE 相机获取图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14890964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Acquire Images with GigE Cameras on Linux with Plain C
提问by Bitterblue
Is there a library that I can use for acquiring images from a GigE camera with plain C on Linux ? To be more specific I have a Basler GigE camera and the pylon software installed. There is also sample code in C++. But I want and need to use C (in my job this is actually THEright thing to do to use C). It would be great if there was something useful as libdc1394just for GigE.
是否有一个库可用于在 Linux 上使用纯 C 从 GigE 相机获取图像?更具体地说,我安装了 Basler GigE 相机和 pylon 软件。在 C++ 中也有示例代码。但我想,需要使用C(在我的工作,这其实是THE做正确的事情用C)。如果有像libdc1394 那样仅适用于 GigE 的东西,那就太好了。
回答by sfx
"GigE Vision"is actually a computer vision camera standard, and most cameras also implement the Genicam standard for adjusting parameters. At least that is the theory - I have a high-speed GigE camera that is not found by Pylon or AVT for some unknown reason (officially it's only supported by eBus from Pleora). You might be able to get the specifications for those standards, but I'm not sure if they are freely available.
“GigE Vision”其实是一个计算机视觉相机标准,大部分相机也执行了Genicam标准来调整参数。至少这是理论 - 我有一个高速 GigE 相机,由于某种未知原因,它没有被 Pylon 或 AVT 发现(官方仅支持来自 Pleora 的 eBus)。您也许可以获得这些标准的规范,但我不确定它们是否可以免费获得。
Regarding a library, I just tried Aravisunder Ubuntu12.04 and it worked for my camera (streaming 512x512 pixel at 190 frames/second). It's written in C as far as I can tell. As a hint, to compile the Viewer that is included you have to install all the gstreamer-dev packages, including libgstreamer-plugins-base0.10-dev.
关于库,我刚刚在 Ubuntu12.04 下尝试了Aravis,它适用于我的相机(以 190 帧/秒的速度流式传输 512x512 像素)。据我所知,它是用 C 编写的。作为提示,要编译包含的查看器,您必须安装所有 gstreamer-dev 软件包,包括 libgstreamer-plugins-base0.10-dev。
回答by Ph0t0n
The GigE standard isn't very open-source friendly - you have to pay annual license fees to the standards organization, which is why most of the software that uses GigE Vision costs a substantial amount of money. A group of companies came together to make the standard and they're not likely to publish it to the world anytime soon.
GigE 标准对开源不是很友好——你必须每年向标准组织支付许可费用,这就是为什么大多数使用 GigE Vision 的软件都要花费大量资金的原因。一群公司聚集在一起制定标准,他们不太可能很快将其发布给全世界。
So here are some of your options (that I can think of)...
所以这里有一些你的选择(我能想到的)......
1) Reverse engineer the protocol yourself. It's pretty complicated so that would be a big project.
1) 自己对协议进行逆向工程。这非常复杂,所以这将是一个大项目。
2) Maybe you'll get lucky and find a company that has a C-version of the SDK they can sell you?
2) 也许你会很幸运,找到一家拥有 C 版 SDK 的公司可以卖给你?
3) Use C++ :-) (jk...)
3) 使用 C++ :-) (jk...)
4) Pay the standards organization to give you access or partner with a company that is on it.
4) 向标准组织付款,让您访问或与在其上的公司合作。
5) Use open-source projects that are attempting to reverse-engineer the standard. (I don't know what the legality rules are on that). Examples: Aravis, and OpenGigEVision. These solutions will probably be incomplete for a while, but they should at least support the basics.
5) 使用试图对标准进行逆向工程的开源项目。(我不知道合法性规则是什么)。示例:Aravis 和 OpenGigEVision。这些解决方案可能会暂时不完整,但它们至少应该支持基础知识。
I think #5 is your best bet if you don't have a lot of time or money to spend.
如果您没有很多时间或金钱可花费,我认为 #5 是您最好的选择。
回答by Jason Newton
Most implementations will use C++ and at best expose a c-api building on that because GenICam is a very complicated thing to implement - and the reference implementation works, is free and is used by nearly all SDK vendors. You can implement alot of the acquisition without that much in C but it is very difficult to cut GenICam out of the loop - this is because vendors have used GenICam XML documents as a sort of domain specific programming language/environment - the effort is comparable to implementing a web-browser from scratch.
大多数实现将使用 C++,并且充其量公开一个基于它的 c-api,因为 GenICam 是一个非常复杂的实现 - 参考实现有效,是免费的,几乎所有 SDK 供应商都在使用。您可以在 C 语言中实现很多收购,但很难将 GenICam 排除在循环之外——这是因为供应商已经使用 GenICam XML 文档作为一种特定领域的编程语言/环境——这种努力与从头开始实现网络浏览器。
Aravisdoes exist but depends on gstreamer and does seem to be mainly in C but it will only go so far on the complex XML support needed for many cameras. I'd never use gstreamer in a mission critical setting or where reliable operation is required in addition to where high performance or high efficiency is required. I believe the best option on the market is Pleora's SDK FYI - no relation. Having said that - I've written such a library (with C++ :-) which I cannot share to address problems I've mentioned.
Aravis确实存在,但依赖于 gstreamer,并且似乎主要是用 C 语言编写的,但它只能在许多相机所需的复杂 XML 支持上走得更远。我绝不会在关键任务环境中使用 gstreamer,或者除了需要高性能或高效率之外还需要可靠操作的地方。我相信市场上最好的选择是 Pleora 的 SDK FYI - 没有关系。话虽如此 - 我已经编写了这样一个库(使用 C++ :-),我无法共享它来解决我提到的问题。