海思3531获取多个摄像头在整个屏幕的画面

要想获取整个摄像头画面在整个屏幕的画面只需要比平常的操作多一步即可,例如通常海思SDK通常提供的VENC例子里的流程是:VI->VPSS->VENC,而我们把他修改成VI->VPSS->虚拟VO->VENC,这样我们就可以获取所有摄像头在屏幕显示的画面。虚拟VO配置如下:

    s32Ret = SAMPLE_COMM_VO_MemConfig(VO_VIRT, "ddr1");
    if (HI_SUCCESS != s32Ret)
    {
        SAMPLE_PRT("BJ_Multimedia_VO_MemConfig failed with %d!\n", s32Ret);
        goto END_4HD_HOMO_0;
    }
HI_S32 startVoVirtual(VIDEO_NORM_E gs_enNorm)
{
    HI_S32 s32Ret;
    VO_DEV voDev = VO_VIRT;
    VO_PUB_ATTR_S stVoPubAttr;
    VO_VIDEO_LAYER_ATTR_S stLayerAttr;
    VO_CHN_ATTR_S stChnAttr;
    HI_U32 u32Width = 1920;
    HI_U32 u32Height = 1080;
    HI_S32 WIN_NUM = 4;
 
    int i;
    VO_CHN chn;
 
    stVoPubAttr.u32BgColor = 0x00000000;
    stVoPubAttr.enIntfType = VO_INTF_VGA | VO_INTF_HDMI;
    stVoPubAttr.enIntfSync =(VIDEO_ENCODING_MODE_PAL == gs_enNorm) ? VO_OUTPUT_1080P50 : VO_OUTPUT_1080P60;
    stVoPubAttr.bDoubleFrame = HI_FALSE;
    s32Ret = HI_MPI_VO_SetPubAttr(voDev, &stVoPubAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_SetPubAttr failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }
 
    s32Ret = HI_MPI_VO_Enable(voDev);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_Enable failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }
 
    stLayerAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;
    stLayerAttr.u32DispFrmRt = (VIDEO_ENCODING_MODE_PAL == gs_enNorm)?25:30;
    stLayerAttr.stDispRect.s32X       = 0;
    stLayerAttr.stDispRect.s32Y       = 0;
    stLayerAttr.stDispRect.u32Width   = u32Width;
    stLayerAttr.stDispRect.u32Height  = u32Height;
    stLayerAttr.stImageSize.u32Width  = u32Width;
    stLayerAttr.stImageSize.u32Height = u32Height;
 
    s32Ret = HI_MPI_VO_SetVideoLayerAttr(voDev, &stLayerAttr);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_SetVideoLayerAttr failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }
 
    s32Ret = HI_MPI_VO_EnableVideoLayer(voDev);
    if (s32Ret != HI_SUCCESS) {
        SAMPLE_PRT("HI_MPI_VO_EnableVideoLayer failed with 0x%#x!\n", s32Ret);
        return HI_FAILURE;
    }
 
    for (i = 0; i < WIN_NUM; i++) {
 
        chn = i;
 
        stChnAttr.stRect.s32X       = (i % 2) * u32Width / 2;   //开启画面显示的通道
        stChnAttr.stRect.s32Y       = (i / 2) * u32Height / 2;
        stChnAttr.stRect.u32Width   = u32Width/2;
        stChnAttr.stRect.u32Height  = u32Height/2;
        stChnAttr.u32Priority       = i;
        stChnAttr.bDeflicker        = HI_FALSE;
 
        s32Ret = HI_MPI_VO_SetChnAttr(voDev, chn, &stChnAttr);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("HI_MPI_VO_SetChnAttr failed with %#x!\n", s32Ret);
        }
 
        s32Ret = HI_MPI_VO_EnableChn(voDev, chn);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("HI_MPI_VO_EnableChn failed with %#x!\n", s32Ret);
            return HI_FAILURE;
        }
    }
 
    return HI_SUCCESS;
 
}
配置好了就是VPSS绑定虚拟VO了,在这里千万要注意,要绑定虚拟VO与真实VO是有区别的,必须用VPSS的 VPSS_BYPASS_CHN来绑定,原因如图:

如何要想看到显示器显示界面同时我们将虚拟vo绑定vo设备就可以了

HI_S32 VoVirtualBindVo()
{
    HI_S32 s32Ret = HI_SUCCESS;
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;
 
    stSrcChn.enModId = HI_ID_VOU;
    stSrcChn.s32DevId = VO_VIRT;
    stSrcChn.s32ChnId = 0;
 
    stDestChn.enModId = HI_ID_VOU;
    stDestChn.s32DevId = VO_DHD0;
    stDestChn.s32ChnId = 0;
 
    s32Ret = HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("failed with %#x!\n", s32Ret);
        return HI_FAILURE;
    }
 
    return s32Ret;
 
}
最后附上代码:https://download.csdn.net/download/yinsui1839/10436592 

这份代码是在Qt上打的,建议装个Qt查看,要想正常编译得移植Qt
--------------------- 
作者:hello_paidaxing 
来源:CSDN 
原文:https://blog.csdn.net/yinsui1839/article/details/80446319 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/xswy1/article/details/83616009