Pylon C++ Programmer's Guide
移步至Pylon C++ Programmer's Guide观看效果更佳
Getting Started
pylon编程指南是一个关于如何使用Basler pylon C++ API进行编程的快速指南。它可以与pylon示例代码一起使用,以帮助初学者入门。此外,API renfence提供了有关Basler pylon C++接口的描述。接口的描述也可在pylon的头文件中找到。在使用Microsoft Visual Studio 时,右键点击所需的方法或类,并从上下文菜单中选择“转到声明”,以访问相关的文档。
对于为Basler blaze相机编程的信息,请参考pylon为blaze提供的补充包(可在Basler网站上下载)。这包括了一个C++ API和一个.NET API,以及示例代码。
Common Settings for Building Applications with pylon (Linux)
这一部分展示了使用pylon和GNU工具链构建应用程序的最常见的Linux构建设置。有关更多信息,请查阅Advanced Topics部分。
为了集中管理负责构建基于pylon的应用程序所需的所有参数,我们创建了pylon-config工具。它的工作方式类似于pkg-config,您可以调用pylon-config --help来获取支持的参数列表。
在典型的基于GNU Make的项目中,您可以在Makefile中添加以下行:
PYLON_ROOT ?= /opt/pylon
CPPFLAGS += $(shell $(PYLON_ROOT)/bin/pylon-config --cflags)
LDFLAGS += $(shell $(PYLON_ROOT)/bin/pylon-config --libs-rpath)
LDLIBS += $(shell $(PYLON_ROOT)/bin/pylon-config --libs)
如有需要,您现在可以使用环境变量<PYLON_ROOT>覆盖默认的安装路径。例如:
PYLON_ROOT=/path/to/your/pylon/install make
Initialization/Uninitialization of the pylon Runtime Library
在使用pylon API前必须初始化pylon运行时系统。基于pylon的应用程序在使用pylon运行时系统的任何其他功能之前必须调用PylonInitialize()。应用程序退出前,必须调用PylonTerminate()方法以释放pylon运行时系统分配的资源。
Pylon::PylonAutoInitTerm便利类有助于执行上述操作。Pylon::PylonAutoInitTerm的构造函数调用PylonInitialize(),析构函数调用PylonTerminate()。这确保了在Pylon::PylonAutoInitTerm类型对象的生命周期内,pylon运行时系统被初始化。
示例如下:
#include <pylon/PylonIncludes.h>
using namespace Pylon;
int main(int argc, char* argv[])
{
Pylon::PylonAutoInitTerm autoInitTerm; // PylonInitialize() will be called now
// Use pylon
// ..
} // autoInitTerm's destructor calls PylonTerminate() now
Advanced Topics包含MFC用户的附加信息
Error Handling
在出现错误的情况下,pylon类中的方法可能会抛出C++异常。pylon C++ API抛出的异常类型为GenericException或其子类。您应该使用捕获GenericException的异常处理程序来保护pylon调用。例如:
try
{
camera.Width.SetValue(640);
}
catch (const GenericException & e)
{
cerr << "设置AOI宽度失败。原因:"
<< e.GetDescription() << endl;
}
Creating a pylon Device
在 pylon 中,物理相机设备由pylon Devices表示。以下示例展示了如何创建一个pylon设备:
CInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice());
创建第一个找到的相机设备,例如用于仅使用一个相机的视觉系统。Advanced Topics展示了如何处理多个相机设备以及如何找到特定的相机设备。
The Instant Camera Classes
即时相机(Instant Camera)类使得仅通过几行代码就可以抓取图像,将编程工作量降至最低。即时相机类内部使用一个pylon设备(ptlon Device)。需要创建pylon设备并将其附加到即时相机对象上以进行操作。
示例:
// Create an instant camera object with the camera device found first.
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice() );
// Print the model name of the camera.
cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;
// Start the grabbing of c_countOfImagesToGrab images.
// The camera device is parameterized with a default configuration which
// sets up free-running continuous acquisition.
camera.StartGrabbing( c_countOfImagesToGrab );
// This smart pointer will receive the grab result data.
CGrabResultPtr ptrGrabResult;
// Camera.StopGrabbing() is called automatically by the RetrieveResult() method
// when c_countOfImagesToGrab images have been retrieved.
while (camera.IsGrabbing())
{
// Wait for an image and then retrieve it. A timeout of 5000 ms is used.
camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException );
// Image grabbed successfully?
if (ptrGrabResult->GrabSucceeded())
{
// Access the image data.
cout << "SizeX: " << ptrGrabResult->GetWidth() << endl;
cout << "SizeY: " << ptrGrabResult->GetHeight() << endl;
const uint8_t* pImageBuffer = (uint8_t*) ptrGrabResult->GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t) pImageBuffer[0] << endl << endl;
}
else
{
cout << "Error: " << std::hex << ptrGrabResult->GetErrorCode() << std::dec << " " << ptrGrabResult->GetErrorDescription() << endl;
}
}
上述代码可以在示例代码中的Grab Sample中找到。
The Main Features of an Instant Camera Class
即时相机类为访问相机设备提供了便捷的途径,同时具有高度的可定制性。以下列表展示了即时相机类的主要功能:
- 它作为单一访问点用于访问相机功能。
- 它可以“开箱即用”,无需设置任何参数。相机使用设备的默认配置。默认配置可以被覆盖。
- 它管理pylon设备的生命周期。
- 它自动打开和关闭pylon设备。
- 它处理缓冲区的创建、重用和销毁。
- 如有需要,它提供一个抓取循环线程。
- 它可以检测相机设备的移除。
- 它支持高级相机功能,如块模式和事件报告(相机事件)。
- 可以通过派生来扩展。
- 可以通过注册额外的事件处理器对象来扩展。
Types of Instant Camera Classes
在开始编程之前,你需要确定要使用哪种即时相机类。下表显示了可用的即时相机类:
| Name of Class | Usable for Device Type | Device-specific |
|---|---|---|
| Pylon::CInstantCamera (推荐) | All cameras | No |
| Pylon::CBaslerUniversalInstantCamera (新手推荐) | All cameras | No |
CInstantCamera和CBaslerUniversalInstantCamera允许你操作所有类型的相机设备。
CBaslerUniversalInstantCamera类是CInstantCamera类的一个特化,它通过一个参数类对其进行了扩展。参数类为每个相机参数提供了一个成员。附加的参数类提供了IDE自动补全功能(例如,Visual Studio中的IntelliSense),在开发应用程序时非常有帮助。虽然这会增加一点运行时开销,但这种开销非常小,可以忽略不计。
后续内容请移步至Pylon C++ Programmer's Guide
Pylon C++ Programmer's Guide的更多相关文章
- [转帖]Programmer’s guide to the big tech companies 💻
Programmer’s guide to the big tech companies
- TensorFlow 官方文档 Programmer's Guide 中文翻译 —— 引言
TensorFlow Programmer's Guide (Introduction) TensorFlow 编程手册 (引言) #(本项目对tensorflow官网上给出的指导手册(TF1.3版本 ...
- [翻译] TensorFlow Programmer's Guide之Frequently Asked Questions(问得频率最多的几个问题)
目录: 特点和兼容性(Features and Compatibility) 建立一个TensorFlow图(Building a TensorFlow graph) 运行一个TensorFlow计算 ...
- 转载:ZooKeeper Programmer's Guide(中文翻译)
本文是为想要创建使用ZooKeeper协调服务优势的分布式应用的开发者准备的.本文包含理论信息和实践信息. 本指南的前四节对各种ZooKeeper概念进行较高层次的讨论.这些概念对于理解ZooKeep ...
- chapter3:Collaborative Filtering ---------A Programmer's Guide to Data Mining
Implicit rating and item based filtering Explicit rating: 用户明确的对item评分 Implicit rating:反之 明确评分所存在的问题 ...
- zookeeper[1] (转)ZooKeeper Programmer's Guide(zookeeper编程向导)---中文
原文:http://www.cnblogs.com/Xrinehart/p/3512509.html 本文是为想要创建使用ZooKeeper协调服务优势的分布式应用的开发者准备的.本文包含理论信息和实 ...
- Zookeeper Tutorial 2 -- Programmer's Guide
数据模型 ZooKeeper跟分布式文件系统一样, 有一系列的命名空间. 唯一不同的地方是命名空间中的每个节点都有数据和他相关联. 它类似于一个允许文件同时是一个目录的文件系统. 节点的路径永远是以斜 ...
- ZooKeeper Getting Started Guide
http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html What is ZooKeeper? ZooKeeper is a centra ...
- ZooKeeper Administrator's Guide A Guide to Deployment and Administration(吃别人嚼过的馍没意思,直接看官网资料)
Deployment System Requirements Supported Platforms Required Software Clustered (Multi-Server) Setup ...
- Apache ZooKeeper Getting Started Guide 翻译
ZooKeeper 開始向导 開始:用zookeeper协调分布式程序 单例操作 管理zookeeper存储 连接zookeeper 执行zookeeper 以复制模式执行zookeeper 其他优化 ...
随机推荐
- 记一次 .NET某实验室自动进样系统 崩溃分析
一:背景 1. 讲故事 前些天有位朋友在微信上联系到我,说他们的程序在客户那边崩掉了,让我帮忙看下怎么回事,dump也拿到了,那就上手分析吧. 二:WinDbg 分析 1. 哪里的崩溃 既然是程序的崩 ...
- 最详细STL(二)deque
deque其实也是数组,也可以动态的添加和减少元素,但是和vector不同的是,deque可以快速的在头部和尾部添加减少元素(vector只能快速的在尾部添加),然而在插入元素的时候因为头部和尾部都可 ...
- .proto文件的作用
在网络通信和通用数据交换等应用场景中经常使用的技术是 JSON 或 XML,而在最近的开发中接触到了 Google 的 ProtoBuf. 在查阅相关资料学习 ProtoBuf 以及研读其源码之后,发 ...
- el-popover - 问题
背景:elemet - ui和vue , el-table中使用了 el-popover , el-popover 中使用了form, 每编辑一行数据,点击编辑按钮,出现el-popover弹窗,页面 ...
- 使用Hexo主题搭建个人博客(markdown)
依赖环境 安装node.js:node.js下载可以从其官方界面开始https://nodejs.org/zh-cn/ 安装git:git下载则可以从其官方界面开始https://git-scm.co ...
- 小tips:vue结合百度UEditor富文本编辑器实现vue-ueditor-wrap
1.下载vue-ueditor-wrap cnpm i vue-ueditor-wrap -S 下载最新的 UEditor 资源文件放入你项目的静态资源目录中(比如 static 或者 public, ...
- Azure Computer Vision 之 Smart Crop 智能裁剪图片
前言 一个网站通常有许多地方会用到同一张图,但是比例又不一样. 一般的做法就是用 CSS 的 cover 和 contain 来处理. 由于 cover 只会保留中间信息, 所以很多时候需要人工裁剪. ...
- ASP.NET Core – Web API Versioning
前言 项目持续维护, API 就需要版本控制. ASP.NET Core 有官方的插件专门处理 API 版本控制. 主要参考 Your Guide to REST API Versioning in ...
- OxyPlot公共属性一览
一.PlotModel 1.构造函数中设置的属性 public PlotModel() { this.Axes = new ElementCollection(this); //坐标轴集合; this ...
- Linux_动态库与静态库(其一)
1.动态库和静态库的定义 动态库(.so):动态库是编译后不嵌入目标文件中的共享库,在程序运行的时候才去链接动态库的代码,可以被多个程序共享使用,通常以 .so 结尾. 静态库(.a):静态库是将一组 ...