[摄像机]Linux系统配置Basler相机驱动(软件触发和硬件触发)OpenCV格式转换/配置文件解析及加载代码

由于学校实验室需要用到Basler相机,然而网上Basler相机的说明文档是全英文的,对新手不太友好,而且国内关于Basler的硬件触发代码没有。在研究了Basler相机的SDK之后总结出了触发的驱动,还有照片与OpenCV格式转换的代码,希望可以对你们有帮助。

测试环境

  • Ubuntu14.04
  • Pylon5.0.5
  • OpenCV3.4.14
  • 相机型号acA1600-60gm/acA2500-14gm

使用步骤

下载Basler相机的SDK(pylon)

在Pylon下载网站下载对应的SDK,此处我下载的是Pylon5.0.5

安装pylon

下载的文件名为pylonSDK-5.0.5.9000-x86_64.tar.gz,将这个文件夹随便解压到一个地方。

进入解压的文件,打开终端,此时的目录为 解压的目录/pylon-5.0.5.9000-x86_64

输入命令,将SDK解压到opt目录下面

 sudo tar -C /opt -xzf pylonSDK*.tar.gz

至此,Basler的SDK(Pylon)安装完成

软件触发

前期准备

将摄像机的电源线插上,电源线的制作方法详见Basler相机的说明PDF

网线也插上,用/opt/pylon5/ipconfiguretion将相机的ip和主机的ip设置在同一网段内

/opt/pylon5/bin/pylon查看相机是否连接成功,是否可以拍摄照片

代码编写

softwareTrigger.cpp源文件

软件触发的源文件,用死循环一直循环取图像,包含拍照的图像转成OpenCV的Mat矩阵

//#include 
#include 
using namespace Pylon;
using namespace GenApi;
//using namespace cv;
using namespace std;

int main(){
    try{
        PylonInitialize();          //初始化相机
        CInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice());

        cout << "Using device " << camera.GetDeviceInfo().GetModelName() << endl;
        camera.Open();

        camera.StartGrabbing(GrabStrategy_LatestImages);

        CGrabResultPtr ptrGrabResult;   
        CPylonImage image;           //图片结构体

        while(1){
            camera.RetrieveResult(5000, ptrGrabResult, TimeoutHandling_ThrowException);

            CImageFormatConverter fc;
            fc.OutputPixelFormat = PixelType_BGR8packed;
            if (ptrGrabResult->GrabSucceeded())
            {
                cout << "Please wait. Images are grabbed." << endl;
                cout << ptrGrabResult->GetWidth()<GetHeight()<GetWidth() / 3;
                // int imCols = ptrGrabResult->GetHeight() / 3;
                // Mat cv_img = Mat(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC3, (uint8_t*)image.GetBuffer());
                // imshow("OpenCVimg",cv_img);
                // waitKey(0);
                */
            }
        }
        camera.Close();//一定要记得关闭,不然重新连接连不上相机
    }
    catch (const GenericException &e)
    {
        // Error handling.
        cerr << "An exception occurred." << endl
        << e.GetDescription() << endl;
    }
    return 0;
}

制作makefile文件,将库引入进来

 

作者:魁爷的黑作坊 来源:简书 https://www.jianshu.com/p/cee63023b8c7


pylon界面中文说明-德国basler工业相机\

basler/pylon-5.2.0.13457-x86_64/pylon5/share/doc

https://wenku.baidu.com/view/1e80d8c8647d27284b7351e9.html


Basler相机配置文件解析 及 加载代码

# {05D8C294-F295-4dfb-9D01-096BD04049F4}
# GenApi persistence file (version 3.1.0)
# Device = Basler::GigECamera -- Basler generic GigEVision camera interface -- Device version = 3.8.0 -- Product GUID = 1F3C6A72-7842-4edd-9130-E2E90A2058BA -- Product version GUID = 3EFB0F43-DD0C-4A24-9AEC-898FEDCFE564
GainAuto    Continuous
BlackLevelSelector    All
BlackLevelRaw    0
BlackLevelSelector    All
GammaEnable    1
GammaSelector    sRGB
DigitalShift    0
PixelFormat    BayerRG8
ReverseX    0
ReverseY    0
TestImageSelector    Off
ColorTransformationSelector    RGBtoRGB
LightSourceSelector    Daylight
ColorTransformationSelector    RGBtoRGB
BalanceWhiteAuto    Continuous
ColorTransformationMatrixFactorRaw    65536
ColorAdjustmentEnable    1
ColorAdjustmentSelector    Red
ColorAdjustmentHueRaw    -3
ColorAdjustmentSelector    Yellow
ColorAdjustmentHueRaw    2
ColorAdjustmentSelector    Green
ColorAdjustmentHueRaw    3
ColorAdjustmentSelector    Cyan
ColorAdjustmentHueRaw    8
ColorAdjustmentSelector    Blue
ColorAdjustmentHueRaw    -2
ColorAdjustmentSelector    Magenta
ColorAdjustmentHueRaw    18
ColorAdjustmentSelector    Red
ColorAdjustmentSelector    Red
ColorAdjustmentSaturationRaw    130
ColorAdjustmentSelector    Yellow
ColorAdjustmentSaturationRaw    122
ColorAdjustmentSelector    Green
ColorAdjustmentSaturationRaw    144
ColorAdjustmentSelector    Cyan
ColorAdjustmentSaturationRaw    130
ColorAdjustmentSelector    Blue
ColorAdjustmentSaturationRaw    128
ColorAdjustmentSelector    Magenta
ColorAdjustmentSaturationRaw    124
ColorAdjustmentSelector    Red
Width    1920   ##图像宽
Height    1200   ##图像高
CenterX    1
CenterY    1
ROIZoneSelector    Zone0
ROIZoneMode    Off
ROIZoneSelector    Zone1
ROIZoneMode    Off
ROIZoneSelector    Zone2
ROIZoneMode    Off
ROIZoneSelector    Zone3
ROIZoneMode    Off
ROIZoneSelector    Zone0
ROIZoneSelector    Zone0
ROIZoneSize    2
ROIZoneSelector    Zone1
ROIZoneSize    4
ROIZoneSelector    Zone2
ROIZoneSize    4
ROIZoneSelector    Zone3
ROIZoneSize    4
ROIZoneSelector    Zone0
ROIZoneSelector    Zone0
ROIZoneOffset    2
ROIZoneSelector    Zone1
ROIZoneOffset    0
ROIZoneSelector    Zone2
ROIZoneOffset    0
ROIZoneSelector    Zone3
ROIZoneOffset    0
ROIZoneSelector    Zone0
AcquisitionFrameCount    1
TriggerSelector    AcquisitionStart
TriggerMode    Off
TriggerSelector    FrameStart
TriggerMode    Off
TriggerSelector    FrameStart
TriggerSelector    AcquisitionStart
TriggerSource    Line1
TriggerSelector    FrameStart
TriggerSource    Line1
TriggerSelector    FrameStart
TriggerSelector    AcquisitionStart
TriggerActivation    RisingEdge
TriggerSelector    FrameStart
TriggerActivation    RisingEdge
TriggerSelector    FrameStart
TriggerSelector    AcquisitionStart
TriggerDelayAbs    0
TriggerSelector    FrameStart
TriggerDelayAbs    0
TriggerSelector    FrameStart
ExposureMode    Timed
ExposureAuto    Continuous           ## 自动曝光
ShutterMode    Global
AcquisitionFrameRateEnable    1
AcquisitionFrameRateAbs    100
LineSelector    Line1
LineMode    Input
LineSelector    Line2
LineMode    Output
LineSelector    Line3
LineMode    Input
LineSelector    Line1
LineSelector    Line1
LineFormat    OptoCoupled
LineSelector    Line2
LineFormat    OptoCoupled
LineSelector    Line3
LineFormat    TTL
LineSelector    Line1
LineSelector    Line2
LineSource    UserOutput1
LineSelector    Line1
LineSelector    Line1
LineInverter    0
LineSelector    Line2
LineInverter    0
LineSelector    Line3
LineInverter    0
LineSelector    Line1
LineSelector    Line1
LineDebouncerTimeRaw    10000
LineSelector    Line3
LineDebouncerTimeRaw    0
LineSelector    Line1
LineSelector    Line2
MinOutPulseWidthRaw    0
LineSelector    Line1
UserOutputValueAll    0
SyncUserOutputValueAll    0
TimerDelayTimebaseAbs    1
TimerDurationTimebaseAbs    1
TimerSelector    Timer1
TimerDelayAbs    0
TimerSelector    Timer1
TimerSelector    Timer1
TimerDelayRaw    0
TimerSelector    Timer1
TimerSelector    Timer1
TimerDurationAbs    4095
TimerSelector    Timer1
TimerSelector    Timer1
TimerDurationRaw    4095
TimerSelector    Timer1
CounterSelector    Counter1
CounterEventSource    FrameTrigger
CounterSelector    Counter2
CounterEventSource    FrameStart
CounterSelector    Counter1
CounterSelector    Counter1
CounterResetSource    Off
CounterSelector    Counter2
CounterResetSource    Off
CounterSelector    Counter1
LUTSelector    Luminance
LUTEnable    0
LUTSelector    Luminance
LUTSelector    Luminance
LUTValueAll    0x00000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006800000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000880000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009800000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d800000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e800000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000f80000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010800000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000118000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001280000000000000000000000000000000000000000000000000000000000000130000000000000000000000000000000000000000000000000000000000000013800000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000148000000000000000000000000000000000000000000000000000000000000015000000000000000000000000000000000000000000000000000000000000001580000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000016800000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000178000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001880000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000019800000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001a800000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001b800000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c800000000000000000000000000000000000000000000000000000000000001d000000000000000000000000000000000000000000000000000000000000001d800000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000001e800000000000000000000000000000000000000000000000000000000000001f000000000000000000000000000000000000000000000000000000000000001f80000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020800000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000218000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002280000000000000000000000000000000000000000000000000000000000000230000000000000000000000000000000000000000000000000000000000000023800000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000248000000000000000000000000000000000000000000000000000000000000025000000000000000000000000000000000000000000000000000000000000002580000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000026800000000000000000000000000000000000000000000000000000000000002700000000000000000000000000000000000000000000000000000000000000278000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002880000000000000000000000000000000000000000000000000000000000000290000000000000000000000000000000000000000000000000000000000000029800000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002a800000000000000000000000000000000000000000000000000000000000002b000000000000000000000000000000000000000000000000000000000000002b800000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c800000000000000000000000000000000000000000000000000000000000002d000000000000000000000000000000000000000000000000000000000000002d800000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000002e800000000000000000000000000000000000000000000000000000000000002f000000000000000000000000000000000000000000000000000000000000002f80000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000030800000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000000318000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000003280000000000000000000000000000000000000000000000000000000000000330000000000000000000000000000000000000000000000000000000000000033800000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000348000000000000000000000000000000000000000000000000000000000000035000000000000000000000000000000000000000000000000000000000000003580000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000036800000000000000000000000000000000000000000000000000000000000003700000000000000000000000000000000000000000000000000000000000000378000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000003880000000000000000000000000000000000000000000000000000000000000390000000000000000000000000000000000000000000000000000000000000039800000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000003a800000000000000000000000000000000000000000000000000000000000003b000000000000000000000000000000000000000000000000000000000000003b800000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000003c800000000000000000000000000000000000000000000000000000000000003d000000000000000000000000000000000000000000000000000000000000003d800000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000003f000000000000000000000000000000000000000000000000000000000000003f80000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040800000000000000000000000000000000000000000000000000000000000004100000000000000000000000000000000000000000000000000000000000000418000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000004280000000000000000000000000000000000000000000000000000000000000430000000000000000000000000000000000000000000000000000000000000043800000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000448000000000000000000000000000000000000000000000000000000000000045000000000000000000000000000000000000000000000000000000000000004580000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000046800000000000000000000000000000000000000000000000000000000000004700000000000000000000000000000000000000000000000000000000000000478000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000004880000000000000000000000000000000000000000000000000000000000000490000000000000000000000000000000000000000000000000000000000000049800000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000004a800000000000000000000000000000000000000000000000000000000000004b000000000000000000000000000000000000000000000000000000000000004b800000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000000004c800000000000000000000000000000000000000000000000000000000000004d000000000000000000000000000000000000000000000000000000000000004d800000000000000000000000000000000000000000000000000000000000004e000000000000000000000000000000000000000000000000000000000000004e800000000000000000000000000000000000000000000000000000000000004f000000000000000000000000000000000000000000000000000000000000004f80000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000050800000000000000000000000000000000000000000000000000000000000005100000000000000000000000000000000000000000000000000000000000000518000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000005280000000000000000000000000000000000000000000000000000000000000530000000000000000000000000000000000000000000000000000000000000053800000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000548000000000000000000000000000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000005580000000000000000000000000000000000000000000000000000000000000560000000000000000000000000000000000000000000000000000000000000056800000000000000000000000000000000000000000000000000000000000005700000000000000000000000000000000000000000000000000000000000000578000000000000000000000000000000000000000000000000000000000000058000000000000000000000000000000000000000000000000000000000000005880000000000000000000000000000000000000000000000000000000000000590000000000000000000000000000000000000000000000000000000000000059800000000000000000000000000000000000000000000000000000000000005a000000000000000000000000000000000000000000000000000000000000005a800000000000000000000000000000000000000000000000000000000000005b000000000000000000000000000000000000000000000000000000000000005b800000000000000000000000000000000000000000000000000000000000005c000000000000000000000000000000000000000000000000000000000000005c800000000000000000000000000000000000000000000000000000000000005d000000000000000000000000000000000000000000000000000000000000005d800000000000000000000000000000000000000000000000000000000000005e000000000000000000000000000000000000000000000000000000000000005e800000000000000000000000000000000000000000000000000000000000005f000000000000000000000000000000000000000000000000000000000000005f80000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060800000000000000000000000000000000000000000000000000000000000006100000000000000000000000000000000000000000000000000000000000000618000000000000000000000000000000000000000000000000000000000000062000000000000000000000000000000000000000000000000000000000000006280000000000000000000000000000000000000000000000000000000000000630000000000000000000000000000000000000000000000000000000000000063800000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000648000000000000000000000000000000000000000000000000000000000000065000000000000000000000000000000000000000000000000000000000000006580000000000000000000000000000000000000000000000000000000000000660000000000000000000000000000000000000000000000000000000000000066800000000000000000000000000000000000000000000000000000000000006700000000000000000000000000000000000000000000000000000000000000678000000000000000000000000000000000000000000000000000000000000068000000000000000000000000000000000000000000000000000000000000006880000000000000000000000000000000000000000000000000000000000000690000000000000000000000000000000000000000000000000000000000000069800000000000000000000000000000000000000000000000000000000000006a000000000000000000000000000000000000000000000000000000000000006a800000000000000000000000000000000000000000000000000000000000006b000000000000000000000000000000000000000000000000000000000000006b800000000000000000000000000000000000000000000000000000000000006c000000000000000000000000000000000000000000000000000000000000006c800000000000000000000000000000000000000000000000000000000000006d000000000000000000000000000000000000000000000000000000000000006d800000000000000000000000000000000000000000000000000000000000006e000000000000000000000000000000000000000000000000000000000000006e800000000000000000000000000000000000000000000000000000000000006f000000000000000000000000000000000000000000000000000000000000006f80000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000070800000000000000000000000000000000000000000000000000000000000007100000000000000000000000000000000000000000000000000000000000000718000000000000000000000000000000000000000000000000000000000000072000000000000000000000000000000000000000000000000000000000000007280000000000000000000000000000000000000000000000000000000000000730000000000000000000000000000000000000000000000000000000000000073800000000000000000000000000000000000000000000000000000000000007400000000000000000000000000000000000000000000000000000000000000748000000000000000000000000000000000000000000000000000000000000075000000000000000000000000000000000000000000000000000000000000007580000000000000000000000000000000000000000000000000000000000000760000000000000000000000000000000000000000000000000000000000000076800000000000000000000000000000000000000000000000000000000000007700000000000000000000000000000000000000000000000000000000000000778000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000007880000000000000000000000000000000000000000000000000000000000000790000000000000000000000000000000000000000000000000000000000000079800000000000000000000000000000000000000000000000000000000000007a000000000000000000000000000000000000000000000000000000000000007a800000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000007b800000000000000000000000000000000000000000000000000000000000007c000000000000000000000000000000000000000000000000000000000000007c800000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000007d800000000000000000000000000000000000000000000000000000000000007e000000000000000000000000000000000000000000000000000000000000007e800000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000007f80000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000080800000000000000000000000000000000000000000000000000000000000008100000000000000000000000000000000000000000000000000000000000000818000000000000000000000000000000000000000000000000000000000000082000000000000000000000000000000000000000000000000000000000000008280000000000000000000000000000000000000000000000000000000000000830000000000000000000000000000000000000000000000000000000000000083800000000000000000000000000000000000000000000000000000000000008400000000000000000000000000000000000000000000000000000000000000848000000000000000000000000000000000000000000000000000000000000085000000000000000000000000000000000000000000000000000000000000008580000000000000000000000000000000000000000000000000000000000000860000000000000000000000000000000000000000000000000000000000000086800000000000000000000000000000000000000000000000000000000000008700000000000000000000000000000000000000000000000000000000000000878000000000000000000000000000000000000000000000000000000000000088000000000000000000000000000000000000000000000000000000000000008880000000000000000000000000000000000000000000000000000000000000890000000000000000000000000000000000000000000000000000000000000089800000000000000000000000000000000000000000000000000000000000008a000000000000000000000000000000000000000000000000000000000000008a800000000000000000000000000000000000000000000000000000000000008b000000000000000000000000000000000000000000000000000000000000008b800000000000000000000000000000000000000000000000000000000000008c000000000000000000000000000000000000000000000000000000000000008c800000000000000000000000000000000000000000000000000000000000008d000000000000000000000000000000000000000000000000000000000000008d800000000000000000000000000000000000000000000000000000000000008e000000000000000000000000000000000000000000000000000000000000008e800000000000000000000000000000000000000000000000000000000000008f000000000000000000000000000000000000000000000000000000000000008f80000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000090800000000000000000000000000000000000000000000000000000000000009100000000000000000000000000000000000000000000000000000000000000918000000000000000000000000000000000000000000000000000000000000092000000000000000000000000000000000000000000000000000000000000009280000000000000000000000000000000000000000000000000000000000000930000000000000000000000000000000000000000000000000000000000000093800000000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000000000000000000000000000948000000000000000000000000000000000000000000000000000000000000095000000000000000000000000000000000000000000000000000000000000009580000000000000000000000000000000000000000000000000000000000000960000000000000000000000000000000000000000000000000000000000000096800000000000000000000000000000000000000000000000000000000000009700000000000000000000000000000000000000000000000000000000000000978000000000000000000000000000000000000000000000000000000000000098000000000000000000000000000000000000000000000000000000000000009880000000000000000000000000000000000000000000000000000000000000990000000000000000000000000000000000000000000000000000000000000099800000000000000000000000000000000000000000000000000000000000009a000000000000000000000000000000000000000000000000000000000000009a800000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000009b800000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000009c800000000000000000000000000000000000000000000000000000000000009d000000000000000000000000000000000000000000000000000000000000009d800000000000000000000000000000000000000000000000000000000000009e000000000000000000000000000000000000000000000000000000000000009e800000000000000000000000000000000000000000000000000000000000009f000000000000000000000000000000000000000000000000000000000000009f80000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a080000000000000000000000000000000000000000000000000000000000000a100000000000000000000000000000000000000000000000000000000000000a180000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000a280000000000000000000000000000000000000000000000000000000000000a300000000000000000000000000000000000000000000000000000000000000a380000000000000000000000000000000000000000000000000000000000000a400000000000000000000000000000000000000000000000000000000000000a480000000000000000000000000000000000000000000000000000000000000a500000000000000000000000000000000000000000000000000000000000000a580000000000000000000000000000000000000000000000000000000000000a600000000000000000000000000000000000000000000000000000000000000a680000000000000000000000000000000000000000000000000000000000000a700000000000000000000000000000000000000000000000000000000000000a780000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000a880000000000000000000000000000000000000000000000000000000000000a900000000000000000000000000000000000000000000000000000000000000a980000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000aa80000000000000000000000000000000000000000000000000000000000000ab00000000000000000000000000000000000000000000000000000000000000ab80000000000000000000000000000000000000000000000000000000000000ac00000000000000000000000000000000000000000000000000000000000000ac80000000000000000000000000000000000000000000000000000000000000ad00000000000000000000000000000000000000000000000000000000000000ad80000000000000000000000000000000000000000000000000000000000000ae00000000000000000000000000000000000000000000000000000000000000ae80000000000000000000000000000000000000000000000000000000000000af00000000000000000000000000000000000000000000000000000000000000af80000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000b080000000000000000000000000000000000000000000000000000000000000b100000000000000000000000000000000000000000000000000000000000000b180000000000000000000000000000000000000000000000000000000000000b200000000000000000000000000000000000000000000000000000000000000b280000000000000000000000000000000000000000000000000000000000000b300000000000000000000000000000000000000000000000000000000000000b380000000000000000000000000000000000000000000000000000000000000b400000000000000000000000000000000000000000000000000000000000000b480000000000000000000000000000000000000000000000000000000000000b500000000000000000000000000000000000000000000000000000000000000b580000000000000000000000000000000000000000000000000000000000000b600000000000000000000000000000000000000000000000000000000000000b680000000000000000000000000000000000000000000000000000000000000b700000000000000000000000000000000000000000000000000000000000000b780000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000b880000000000000000000000000000000000000000000000000000000000000b900000000000000000000000000000000000000000000000000000000000000b980000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000ba80000000000000000000000000000000000000000000000000000000000000bb00000000000000000000000000000000000000000000000000000000000000bb80000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000000bc80000000000000000000000000000000000000000000000000000000000000bd00000000000000000000000000000000000000000000000000000000000000bd80000000000000000000000000000000000000000000000000000000000000be00000000000000000000000000000000000000000000000000000000000000be80000000000000000000000000000000000000000000000000000000000000bf00000000000000000000000000000000000000000000000000000000000000bf80000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c080000000000000000000000000000000000000000000000000000000000000c100000000000000000000000000000000000000000000000000000000000000c180000000000000000000000000000000000000000000000000000000000000c200000000000000000000000000000000000000000000000000000000000000c280000000000000000000000000000000000000000000000000000000000000c300000000000000000000000000000000000000000000000000000000000000c380000000000000000000000000000000000000000000000000000000000000c400000000000000000000000000000000000000000000000000000000000000c480000000000000000000000000000000000000000000000000000000000000c500000000000000000000000000000000000000000000000000000000000000c580000000000000000000000000000000000000000000000000000000000000c600000000000000000000000000000000000000000000000000000000000000c680000000000000000000000000000000000000000000000000000000000000c700000000000000000000000000000000000000000000000000000000000000c780000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000c880000000000000000000000000000000000000000000000000000000000000c900000000000000000000000000000000000000000000000000000000000000c980000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000ca80000000000000000000000000000000000000000000000000000000000000cb00000000000000000000000000000000000000000000000000000000000000cb80000000000000000000000000000000000000000000000000000000000000cc00000000000000000000000000000000000000000000000000000000000000cc80000000000000000000000000000000000000000000000000000000000000cd00000000000000000000000000000000000000000000000000000000000000cd80000000000000000000000000000000000000000000000000000000000000ce00000000000000000000000000000000000000000000000000000000000000ce80000000000000000000000000000000000000000000000000000000000000cf00000000000000000000000000000000000000000000000000000000000000cf80000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d080000000000000000000000000000000000000000000000000000000000000d100000000000000000000000000000000000000000000000000000000000000d180000000000000000000000000000000000000000000000000000000000000d200000000000000000000000000000000000000000000000000000000000000d280000000000000000000000000000000000000000000000000000000000000d300000000000000000000000000000000000000000000000000000000000000d380000000000000000000000000000000000000000000000000000000000000d400000000000000000000000000000000000000000000000000000000000000d480000000000000000000000000000000000000000000000000000000000000d500000000000000000000000000000000000000000000000000000000000000d580000000000000000000000000000000000000000000000000000000000000d600000000000000000000000000000000000000000000000000000000000000d680000000000000000000000000000000000000000000000000000000000000d700000000000000000000000000000000000000000000000000000000000000d780000000000000000000000000000000000000000000000000000000000000d800000000000000000000000000000000000000000000000000000000000000d880000000000000000000000000000000000000000000000000000000000000d900000000000000000000000000000000000000000000000000000000000000d980000000000000000000000000000000000000000000000000000000000000da00000000000000000000000000000000000000000000000000000000000000da80000000000000000000000000000000000000000000000000000000000000db00000000000000000000000000000000000000000000000000000000000000db80000000000000000000000000000000000000000000000000000000000000dc00000000000000000000000000000000000000000000000000000000000000dc80000000000000000000000000000000000000000000000000000000000000dd00000000000000000000000000000000000000000000000000000000000000dd80000000000000000000000000000000000000000000000000000000000000de00000000000000000000000000000000000000000000000000000000000000de80000000000000000000000000000000000000000000000000000000000000df00000000000000000000000000000000000000000000000000000000000000df80000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e080000000000000000000000000000000000000000000000000000000000000e100000000000000000000000000000000000000000000000000000000000000e180000000000000000000000000000000000000000000000000000000000000e200000000000000000000000000000000000000000000000000000000000000e280000000000000000000000000000000000000000000000000000000000000e300000000000000000000000000000000000000000000000000000000000000e380000000000000000000000000000000000000000000000000000000000000e400000000000000000000000000000000000000000000000000000000000000e480000000000000000000000000000000000000000000000000000000000000e500000000000000000000000000000000000000000000000000000000000000e580000000000000000000000000000000000000000000000000000000000000e600000000000000000000000000000000000000000000000000000000000000e680000000000000000000000000000000000000000000000000000000000000e700000000000000000000000000000000000000000000000000000000000000e780000000000000000000000000000000000000000000000000000000000000e800000000000000000000000000000000000000000000000000000000000000e880000000000000000000000000000000000000000000000000000000000000e900000000000000000000000000000000000000000000000000000000000000e980000000000000000000000000000000000000000000000000000000000000ea00000000000000000000000000000000000000000000000000000000000000ea80000000000000000000000000000000000000000000000000000000000000eb00000000000000000000000000000000000000000000000000000000000000eb80000000000000000000000000000000000000000000000000000000000000ec00000000000000000000000000000000000000000000000000000000000000ec80000000000000000000000000000000000000000000000000000000000000ed00000000000000000000000000000000000000000000000000000000000000ed80000000000000000000000000000000000000000000000000000000000000ee00000000000000000000000000000000000000000000000000000000000000ee80000000000000000000000000000000000000000000000000000000000000ef00000000000000000000000000000000000000000000000000000000000000ef80000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000f080000000000000000000000000000000000000000000000000000000000000f100000000000000000000000000000000000000000000000000000000000000f180000000000000000000000000000000000000000000000000000000000000f200000000000000000000000000000000000000000000000000000000000000f280000000000000000000000000000000000000000000000000000000000000f300000000000000000000000000000000000000000000000000000000000000f380000000000000000000000000000000000000000000000000000000000000f400000000000000000000000000000000000000000000000000000000000000f480000000000000000000000000000000000000000000000000000000000000f500000000000000000000000000000000000000000000000000000000000000f580000000000000000000000000000000000000000000000000000000000000f600000000000000000000000000000000000000000000000000000000000000f680000000000000000000000000000000000000000000000000000000000000f700000000000000000000000000000000000000000000000000000000000000f780000000000000000000000000000000000000000000000000000000000000f800000000000000000000000000000000000000000000000000000000000000f880000000000000000000000000000000000000000000000000000000000000f900000000000000000000000000000000000000000000000000000000000000f980000000000000000000000000000000000000000000000000000000000000fa00000000000000000000000000000000000000000000000000000000000000fa80000000000000000000000000000000000000000000000000000000000000fb00000000000000000000000000000000000000000000000000000000000000fb80000000000000000000000000000000000000000000000000000000000000fc00000000000000000000000000000000000000000000000000000000000000fc80000000000000000000000000000000000000000000000000000000000000fd00000000000000000000000000000000000000000000000000000000000000fd80000000000000000000000000000000000000000000000000000000000000fe00000000000000000000000000000000000000000000000000000000000000fe80000000000000000000000000000000000000000000000000000000000000ff00000000000000000000000000000000000000000000000000000000000000ff800000000000000000000000000000000000000000000000000000000
LUTSelector    Luminance
GevStreamChannelSelector    StreamChannel0
GevSCPSPacketSize    1500
GevStreamChannelSelector    StreamChannel0
GevStreamChannelSelector    StreamChannel0
GevSCPD    0
GevStreamChannelSelector    StreamChannel0
GevStreamChannelSelector    StreamChannel0
GevSCFTD    0
GevStreamChannelSelector    StreamChannel0
GevStreamChannelSelector    StreamChannel0
GevSCBWR    10
GevStreamChannelSelector    StreamChannel0
GevStreamChannelSelector    StreamChannel0
GevSCBWRA    10
GevStreamChannelSelector    StreamChannel0
AutoTargetValue    128
GrayValueAdjustmentDampingRaw    700
BalanceWhiteAdjustmentDampingRaw    1000
AutoGainRawLowerLimit    0
AutoGainRawUpperLimit    239
AutoExposureTimeAbsLowerLimit    63         ## 自动曝光上下限,如果自动曝光关闭,就需要手动设置曝光值
AutoExposureTimeAbsUpperLimit    500000
AutoFunctionProfile    GainMinimum
AutoFunctionAOISelector    AOI1
AutoFunctionAOIWidth    1920                ## aeroi 测光区域wid
AutoFunctionAOISelector    AOI2
AutoFunctionAOIWidth    1920
AutoFunctionAOISelector    AOI1
AutoFunctionAOISelector    AOI1
AutoFunctionAOIHeight    400                ## aeroi 测光区域height
AutoFunctionAOISelector    AOI2
AutoFunctionAOIHeight    400
AutoFunctionAOISelector    AOI1
AutoFunctionAOISelector    AOI1
AutoFunctionAOIOffsetX    8                 ## aeroi 测光区域 offsetx
AutoFunctionAOISelector    AOI2
AutoFunctionAOIOffsetX    8 
AutoFunctionAOISelector    AOI1
AutoFunctionAOISelector    AOI1
AutoFunctionAOIOffsetY    8                 ## aeroi 测光区域 offsety
AutoFunctionAOISelector    AOI2
AutoFunctionAOIOffsetY    8
AutoFunctionAOISelector    AOI1
UserDefinedValueSelector    Value1
UserDefinedValue    0
UserDefinedValueSelector    Value2
UserDefinedValue    0
UserDefinedValueSelector    Value3
UserDefinedValue    0
UserDefinedValueSelector    Value4
UserDefinedValue    0
UserDefinedValueSelector    Value5
UserDefinedValue    0
UserDefinedValueSelector    Value1
ParameterSelector    Gain
RemoveLimits    0
ParameterSelector    AutoTargetValue
RemoveLimits    0
ParameterSelector    Gain
ChunkModeActive    0
EventSelector    ExposureEnd
EventNotification    Off
EventSelector    FrameStartOvertrigger
EventNotification    Off
EventSelector    AcquisitionStartOvertrigger
EventNotification    Off
EventSelector    FrameStart
EventNotification    Off
EventSelector    AcquisitionStart
EventNotification    Off
EventSelector    CriticalTemperature
EventNotification    Off
EventSelector    OverTemperature
EventNotification    Off
EventSelector    ActionLate
EventNotification    Off
EventSelector    FrameStartWait
EventNotification    Off
EventSelector    AcquisitionStartWait
EventNotification    Off
EventSelector    EventOverrun
EventNotification    Off
EventSelector    ExposureEnd

 

代码加载:

        nodeFile = "./Camera/camera_config.pfs"  ##加载相机配置文件
        camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())  ##加载相机
        # Grabing Continusely (video) with minimal delay
        camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly)  ##抓取图像
        converter = pylon.ImageFormatConverter()  ##格式转换
        # converting to opencv bgr format
        converter.OutputPixelFormat = pylon.PixelType_BGR8packed   ##转换成opencv——bgr格式的转换器
        converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned ##输出位对齐
        pylon.FeaturePersistence.Load(nodeFile, camera.GetNodeMap(), True)  ## loading camera_config
        try:
            while camera.IsGrabbing():  ##相机是否成功抓取图像
                time_1 = time.time()
                grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)   ##相机抓取图像结果保存在grabResult中
                if grabResult.GrabSucceeded():
                    # Access the image data
                    image = converter.Convert(grabResult) ##使用转换器进行格式转换
                    img = image.GetArray()  ##获取图像数据
                    print("cap image  time is ", time.time() - time_1)
                    if img is not None:
                        common_deal(img)  ##对图像进行处理
                        print("the all time is ", time.time() - time_1)
                        ...
                        ...

 

你可能感兴趣的:([摄像机]Linux系统配置Basler相机驱动(软件触发和硬件触发)OpenCV格式转换/配置文件解析及加载代码)