海思鱼眼矫正

查看具体芯片的GDC 硬件规格,主要看以下参数:

视频输入数据格式
输入图像分辨率
视频输出数据格式
输出图像分辨率
PTZ参数范围
性能

一般鱼眼矫正是在 VI的扩展通道

即:初始化VI模块后:

VI_EXT_CHN_ATTR_S   stExtChnAttr;
VI_CHN   ViExtChn    = VI_EXT_CHN_START;
SIZE_S              stDstSize;

    s32Ret = HI_MPI_VI_GetChnAttr(ViPipe, ViChn, &stChnAttr);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("get vi chn:%d attr failed with:0x%x!\n", ViChn, s32Ret);
        goto EXIT_VI_STOP;
    }

    stExtChnAttr.s32BindChn                   = ViChn; //扩展通道绑定vi通道
    stExtChnAttr.enCompressMode               = stChnAttr.enCompressMode;
    stExtChnAttr.enPixFormat                  = stChnAttr.enPixelFormat;
    stExtChnAttr.stFrameRate.s32SrcFrameRate  = stChnAttr.stFrameRate.s32SrcFrameRate;
    stExtChnAttr.stFrameRate.s32DstFrameRate  = stChnAttr.stFrameRate.s32DstFrameRate;
    stExtChnAttr.stSize.u32Width              = stChnAttr.stSize.u32Width;
    stExtChnAttr.stSize.u32Height             = stChnAttr.stSize.u32Height;
    stExtChnAttr.u32Depth                     = 0;
    stExtChnAttr.enDynamicRange               = stChnAttr.enDynamicRange;
    stExtChnAttr.enSource                     = VI_EXT_CHN_SOURCE_TAIL;

    stDstSize.u32Width = stChnAttr.stSize.u32Width;
    stDstSize.u32Height = stChnAttr.stSize.u32Height;

    /* start vi dev extern chn */
    s32Ret = HI_MPI_VI_SetExtChnAttr(ViPipe, ViExtChn, &stExtChnAttr);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("set vi extern chn attr failed with: 0x%x.!\n", s32Ret);
        goto EXIT_VI_STOP;
    }

    /*Enable ext-channel*/
    s32Ret = HI_MPI_VI_EnableChn(ViPipe,ViExtChn);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("enable vi extern chn failed with: 0x%x.!\n", s32Ret);
        goto EXIT_VI_STOP;
    }

使能vi扩展通道后,将后面的绑定关系绑定在vi扩展通道上,例如:

VI -----VIEXT-----VPSS-----VENC

之后设置鱼眼属性:

    FISHEYE_ATTR_S      stFisheyeAttr;

    stFisheyeAttr.bEnable             = HI_TRUE;
    stFisheyeAttr.bLMF                = HI_FALSE;
    stFisheyeAttr.bBgColor            = HI_FALSE;
    stFisheyeAttr.u32BgColor          = COLOR_RGB_BLUE;
    stFisheyeAttr.s32HorOffset        = 0;
    stFisheyeAttr.s32VerOffset        = 0;
    stFisheyeAttr.u32TrapezoidCoef    = 10;
    stFisheyeAttr.s32FanStrength      = 300;
    stFisheyeAttr.enMountMode         = FISHEYE_WALL_MOUNT;
    stFisheyeAttr.u32RegionNum        = 1;


    stFisheyeAttr.astFishEyeRegionAttr[0].enViewMode            = FISHEYE_VIEW_180_PANORAMA;
    stFisheyeAttr.astFishEyeRegionAttr[0].u32InRadius           = 0;
    stFisheyeAttr.astFishEyeRegionAttr[0].u32OutRadius          = 1200;
    stFisheyeAttr.astFishEyeRegionAttr[0].u32Pan                = 180;
    stFisheyeAttr.astFishEyeRegionAttr[0].u32Tilt               = 165;
    stFisheyeAttr.astFishEyeRegionAttr[0].u32HorZoom            = 4095;
    stFisheyeAttr.astFishEyeRegionAttr[0].u32VerZoom            = 4095;
    stFisheyeAttr.astFishEyeRegionAttr[0].stOutRect.s32X        = 0;
    stFisheyeAttr.astFishEyeRegionAttr[0].stOutRect.s32Y        = 0;
    stFisheyeAttr.astFishEyeRegionAttr[0].stOutRect.u32Width    = stDstSize.u32Width;
    stFisheyeAttr.astFishEyeRegionAttr[0].stOutRect.u32Height    = ALIGN_DOWN(stDstSize.u32Height, 2);
   
    s32Ret =  HI_MPI_VI_SetExtChnFisheye(ViPipe,ViExtChn,&stFisheyeAttr);
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("set fisheye attr failed with s32Ret:0x%x!\n", s32Ret);
        goto END;
    }

具体参数设置参看GDC调试指南

你可能感兴趣的:(海思平台开发)