Pylon 以实时图像采集讲解PylonCppSDK使用流程
2015-05-15 13:04
477 查看
在工业控制当中,用到basler工业相机sdk编程,主要是使用c或者c++,当项目庞大时,又需要良好的用户界面,用C++是不错的选择。
以实例和看过的一些参照讲讲PylonCppSDK使用流程,
首先,同C一样,这里给出一个bolg链接,写的不错,http://blog.csdn.net/wenzhou1219/article/details/7543420。
从中我们知道,总的开发流程图如下:
那么,用C++开发也大抵如此。
这里我们看一个basler的cpp sample,
把这个和上面的流程图对比理解,再看看文档和sdk的结构,理解起来就容易多了。
以实例和看过的一些参照讲讲PylonCppSDK使用流程,
首先,同C一样,这里给出一个bolg链接,写的不错,http://blog.csdn.net/wenzhou1219/article/details/7543420。
从中我们知道,总的开发流程图如下:
那么,用C++开发也大抵如此。
这里我们看一个basler的cpp sample,
This sample illustrates how to grab and process images using the CInstantCamera class. // Include files to use the PYLON API. *#include <pylon/PylonIncludes.h> *#ifdef PYLON_WIN_BUILD* *# include <pylon/PylonGUI.h>* *#endif** // Namespace for using pylon objects. using namespace Pylon; // Namespace for using cout. using namespace std; // Number of images to be grabbed. static const uint32_t c_countOfImagesToGrab = 100; int main(int argc, char* argv[]) { // The exit code of the sample application. int exitCode = 0; // Automagically call PylonInitialize and PylonTerminate to ensure the pylon runtime system // is initialized during the lifetime of this object. Pylon::PylonAutoInitTerm autoInitTerm; try { // 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; // The parameter MaxNumBuffer can be used to control the count of buffers // allocated for grabbing. The default value of this parameter is 10. camera.MaxNumBuffer = 5; // 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; *#ifdef PYLON_WIN_BUILD* // Display the grabbed image. Pylon::DisplayImage(1, ptrGrabResult); *#endif* } else { cout << "Error: " << ptrGrabResult->GetErrorCode() << " " << ptrGrabResult->GetErrorDescription() << endl; } } } catch (GenICam::GenericException &e) { // Error handling. cerr << "An exception occurred." << endl << e.GetDescription() << endl; exitCode = 1; } // Comment the following two lines to disable waiting on exit. cerr << endl << "Press Enter to exit." << endl; while( cin.get() != '\n'); return exitCode; }
把这个和上面的流程图对比理解,再看看文档和sdk的结构,理解起来就容易多了。
相关文章推荐
- 3.Pylon 以实时图像采集讲解PylonC SDK使用流程
- [Pylon]3.以实时图像采集讲解PylonC SDK使用流程 .
- Jetson TX1开发笔记(五):TX1使用OpenCV3.1实时采集视频图像
- Halcon+VisualStudio2015使用线程实现大恒水星相机实时图像采集
- javacpp-opencv图像处理3:使用opencv原生方法遍历摄像头设备及调用(增加实时帧率计算方法)
- javacpp-opencv图像处理3:使用opencv原生方法遍历摄像头设备及调用(增加实时帧率计算方法)
- EM2040D数据采集软件SIS使用过程中图像实时显示问题(三)
- C#用basler相机sdk采集图像并用halcon显示的小程序
- 利用realsense官方SDK进行rgb图像和深度数据采集
- 讲解Python的Scrapy爬虫框架使用代理进行采集的方法
- Kinect2.0之使用KinectSDK自带的KinectStudio进行数据采集
- 基于PCI总线的嵌入式实时DSP图像采集系统(转)
- 【Android】Android Camera实时数据采集及通过MediaCodec硬编码编码数据的流程
- iOS:使用集成的支付宝SDK的支付流程
- 聚合支付ping++流程和SDK使用,你没看错,是一样的
- LEADTOOLS HTML5 SDK使用教程:DICOM图像注释
- 利用USB2.0接口的芯片CY7C68013和单片机实现全数字图像的实时采集
- 图文讲解godaddy注册购买域名使用30%域名优惠码流程,带godaddy30%优惠码
- 使用多线程实现数据实时采集
- android中使用百度定位sdk实时的计算移动距离