CInstantCamera 例子1
2015-06-26 12:20
411 查看
// Include files to use the PYLON API.
#include <pylon/PylonIncludes.h>
#include <pylon/PylonGUI.h>
using namespace Pylon;
using namespace std;
static const uint32_t c_countOfImagesToGrab = 100;
int main(int argc, char* argv[])
{
int exitCode = 0;
Pylon::PylonAutoInitTerm autoInitTerm;
try
{
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;
camera.MaxNumBuffer = 5;
camera.StartGrabbing( c_countOfImagesToGrab);
CGrabResultPtr ptrGrabResult;
while ( camera.IsGrabbing())
{
camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);
if (ptrGrabResult->GrabSucceeded())
{
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;
Pylon::DisplayImage(1, ptrGrabResult);
}
else
cout << "Error: " << ptrGrabResult->GetErrorCode() << " " << ptrGrabResult->GetErrorDescription();
}
}
catch (GenICam::GenericException &e)
{
cerr << "An exception occurred." << endl
<< e.GetDescription() << endl;
exitCode = 1;
}
cerr << endl << "Press Enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
#include <pylon/PylonIncludes.h>
#include <pylon/PylonGUI.h>
using namespace Pylon;
using namespace std;
static const uint32_t c_countOfImagesToGrab = 100;
int main(int argc, char* argv[])
{
int exitCode = 0;
Pylon::PylonAutoInitTerm autoInitTerm;
try
{
CInstantCamera camera( CTlFactory::GetInstance().CreateFirstDevice());
cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;
camera.MaxNumBuffer = 5;
camera.StartGrabbing( c_countOfImagesToGrab);
CGrabResultPtr ptrGrabResult;
while ( camera.IsGrabbing())
{
camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);
if (ptrGrabResult->GrabSucceeded())
{
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;
Pylon::DisplayImage(1, ptrGrabResult);
}
else
cout << "Error: " << ptrGrabResult->GetErrorCode() << " " << ptrGrabResult->GetErrorDescription();
}
}
catch (GenICam::GenericException &e)
{
cerr << "An exception occurred." << endl
<< e.GetDescription() << endl;
exitCode = 1;
}
cerr << endl << "Press Enter to exit." << endl;
while( cin.get() != '\n');
return exitCode;
}
相关文章推荐
- java学习之旅21--for语句
- Activiti初学者教程
- JAVA网络编程之——TCP通信
- Step into Kotlin - 02 - 数据类型
- Uncaught TypeError: Illegal invocation
- 递归与分治:循环赛日程表
- [SoapUI] 按照 Test Step Type 获取所有满足条件的 Test Step
- Android中Parcelable接口用法
- 学习记录:对maven项目使用命令下载jar包
- 《爱编程,爱c++-十八期-对象》
- Linux touch 命令
- AFNetworking框架的使用
- ADI实验室电路:带抗混叠滤波器的宽带接收机
- SQL SERVER性能分析
- 《中华人民共和国著作权法》
- HBase学习总结(1):HBase的下载与安装
- Android Service创建USB HOST通信
- jquery引用的异常
- 新工作加油
- jQuery实现网站添加高亮突出显示效果的方法