HikvisionSDK::ReadBuffer的两种取图方式

//读取相机中的图像
int HikvisionSDK::ReadBuffer(int camId, HObject &ho_Image)  //ho_Image
{
    HObject  getho_Image;
    unsigned int nRecvBufSize = 0;
    MVCC_INTVALUE stParam;
    memset(&stParam, 0, sizeof(MVCC_INTVALUE));
    int tempValue = MV_CC_GetIntValue(m_hDevHandle[camId], "PayloadSize", &stParam); //获取一帧数据的大小
    if (tempValue != 0)
    {
        return -1;
    }
    nRecvBufSize = stParam.nCurValue;
    unsigned char* pDate;
    pDate=(unsigned char *)malloc(nRecvBufSize);
    MV_FRAME_OUT_INFO_EX stImageInfo = {0};
    //MV_FRAME_OUT stImageInfo = {0};
    tempValue= MV_CC_GetOneFrameTimeout(m_hDevHandle[camId], pDate, nRecvBufSize, &stImageInfo, 700);  //stFrameInfo
    //tempValue= MV_CC_GetOneFrameTimeout(m_hDevHandle[camId], pDate, nRecvBufSize, &stImageInfo.stFrameInfo, 700);
    if(tempValue!=0)
    {
        free(pDate);
        return -1;
    }
    bool isMono;
    switch (stImageInfo.enPixelType)
    //switch (stImageInfo.stFrameInfo.enPixelType)
    {
    case PixelType_Gvsp_Mono8:
    case PixelType_Gvsp_Mono10:
    case PixelType_Gvsp_Mono10_Packed:
    case PixelType_Gvsp_Mono12:
    case PixelType_Gvsp_Mono12_Packed:
        isMono=true;
        break;
    default:
        isMono=false;
        break;
    }
    if(isMono)  //黑白图像
    {
        // MV_CC_SetPixelFormat(m_hDevHandle[camId],0);
        GenImage1(&getho_Image,"byte", stImageInfo.nWidth, stImageInfo.nHeight,(Hlong)pDate);
       // GenImage1(&getho_Image,"byte", stImageInfo.stFrameInfo.nWidth, stImageInfo.stFrameInfo.nHeight,(Hlong)pDate);
    }
    else   //彩色图像
    {
      //  MV_CC_SetPixelFormat(m_hDevHandle[camId],4);
        GenImageInterleaved(&getho_Image,(Hlong)pDate,"bgr",(int)stImageInfo.nWidth,(int)stImageInfo.nHeight,0,"byte",(int)stImageInfo.nWidth,(int)stImageInfo.nHeight, 0, 0, -1, 0   );
       // GenImageInterleaved(&getho_Image,(Hlong)pDate,"bgr",(int)stImageInfo.stFrameInfo.nWidth,(int)stImageInfo.stFrameInfo.nHeight,0,"byte",(int)stImageInfo.stFrameInfo.nWidth,(int)stImageInfo.stFrameInfo.nHeight, 0, 0, -1, 0   );
    }
    HalconCpp::CopyImage(getho_Image,&ho_Image);

    free(pDate);
   // MV_CC_FreeImageBuffer(m_hDevHandle[camId],&stImageInfo );
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值