您的位置:首页 > 其它

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: