近红外摄像头Point-Grey开发日志

近红外摄像头的sdk在官网下载:
Point Grey SDK

安装好sdk后,在Point Grey Research文件夹下(下面称为根目录),找到example程序:根目录/FlyCapture2/src/FlyCapture2Test

src文件夹下大部分都是示例程序,这里用Vs2010加载FlyCapture2Test工程,工程配置文件在根目录/FlyCapture2/src/vsprops下,选择对应的配置文件加载到项目中。

由于sdk是x64版本的,在VS中选择release, x64平台。

分析项目中FlyCapture2Test.cpp中的代码,发现摄像头的操作(打开摄像头,保存图像)其实很简单。

const int k_numImages = 10;

    Error error;
    Camera cam;

    // Connect to a camera
    error = cam.Connect(&guid);//连接摄像头,如果连接成功,返回PGRERROR_OK
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    // Get the camera information
    CameraInfo camInfo;
    error = cam.GetCameraInfo(&camInfo);//获取摄像头信息
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    PrintCameraInfo(&camInfo);        

    // Start capturing images
    error = cam.StartCapture();//启动摄像头,如果成功启动,返回PGRERROR_OK
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    Image rawImage;    
    for ( int imageCnt=0; imageCnt < k_numImages; imageCnt++ )
    {                
        // Retrieve an image
        error = cam.RetrieveBuffer( &rawImage );//获取帧,存储在Image rawImage里面
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            continue;
        }

        cout << "Grabbed image " << imageCnt << endl; 

        // Create a converted image
        Image convertedImage;

        // Convert the raw image
        error = rawImage.Convert( PIXEL_FORMAT_MONO8, &convertedImage );//转换图像,转换原因有待研究
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            return -1;
        }  

        // Create a unique filename

        ostringstream filename;
        filename << "FlyCapture2Test-" << camInfo.serialNumber << "-" << imageCnt << ".jpg";

        // Save the image. If a file format is not passed in, then the file
        // extension is parsed to attempt to determine the file format.
        error = convertedImage.Save( filename.str().c_str() );//将转换后的图像存储起来,文件名为filename字符串的内容,以.jpg格式存储。
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            return -1;
        }  
    }            

    // Stop capturing images
    error = cam.StopCapture();//停用摄像头
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }      

    // Disconnect the camera
    error = cam.Disconnect();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    return 0;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值