Basler CInstantCamera 使用 例子

// 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
    {

        //CTI:通用传输接口,基于GeniCam
        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;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码猿杂谈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值