海思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
版權宣告:本文為博主原創文章,轉載請附上博文連結!