首页 > 其他 > 详细

Basler Pylon 简单抓图

时间:2019-10-28 14:30:34      阅读:335      评论:0      收藏:0      [点我收藏+]

简单抓图步骤:

  • StartGrabbing 开始抓取,状态 isGrabbing
  • RetrieveResult 接收数据,完成后触发 StopGrabbing
  • 数据由 CGrabResultPtr 指针接收,状态 GrabSucceeded
  • runtime 由 PylonInitialize 初始化,并由 PylonTerminate 销毁

具体代码如下:

 Step0:初始化 Pylonruntime

    // Before using any pylon methods, the pylon runtime must be initialized.
    PylonInitialize();
    //Pylon::PylonAutoInitTerm autoInitTerm;

 

Step1: 创建 Camera 实例

        // Create an instant camera object with the camera device found first.
        IPylonDevice *pDevice = CTlFactory::GetInstance().CreateFirstDevice();
        CInstantCamera camera;
        camera.Attach(pDevice);

 

Name of ClassUsable for Device TypeDevice-specific
Pylon::CInstantCamera (recommended) All cameras No
Pylon::CBaslerUniversalInstantCamera (recommended for novice users) All cameras No
Pylon::CBasler1394InstantCamera IIDC 1394 compliant cameras Yes
Pylon::CBaslerGigEInstantCamera GigE Vision compliant cameras Yes
Pylon::CBaslerUsbInstantCamera USB3 Vision compliant cameras Yes
Pylon::CBaslerCameraLinkInstantCamera Camera Link compliant cameras Yes

 

step2:开始抓取

        // Start the grabbing of 1 images.
        // The camera device is parameterized with a default configuration which
        // sets up free-running continuous acquisition.
        camera.StartGrabbing(1);

 

step3:构造智能指针接收抓取数据

        // This smart pointer will receive the grab result data.
        CGrabResultPtr ptrGrabResult;

 

step4:判断抓取状态,并接收数据

        // Camera.StopGrabbing() is called automatically by the RetrieveResult() method
        // when c_countOfImagesToGrab images have been retrieved.
        int flag = 0;
        while ( camera.IsGrabbing())
        {
            // Wait for an image and then retrieve it. A timeout of 5000 ms is used.
            camera.RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);

 

step5:判断抓取结果,并处理

            // 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();

 

step6:释放 plyon runtime

    // Releases all pylon resources.
    PylonTerminate();

 

Basler Pylon 简单抓图

原文:https://www.cnblogs.com/5free/p/11751655.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!