3289
- 收藏
- 点赞
- 分享
- 举报
我在VO上叠了一张图片,但是没有效果
HI_S32 SAMPLE_RGN_CreateOverlayex(RGN_HANDLE Handle, HI_U32 ChnId,HI_U32 u32Num,MOD_ID_E u32ModId)
{
HI_S32 i;
HI_S32 s32Ret;
MPP_CHN_S stChn;
RGN_ATTR_S stRgnAttr;
RGN_CHN_ATTR_S stChnAttr;
/* Add cover to vpss group */
stChn.enModId = u32ModId;
stChn.s32DevId = 0;
stChn.s32ChnId = ChnId;
for (i=Handle; i<(Handle + u32Num); i++)
{
stRgnAttr.enType = OVERLAYEX_RGN;
stRgnAttr.unAttr.stOverlayEx.enPixelFmt = PIXEL_FORMAT_RGB_1555;
stRgnAttr.unAttr.stOverlayEx.stSize.u32Width = 128;
stRgnAttr.unAttr.stOverlayEx.stSize.u32Height = 128;
//stRgnAttr.unAttr.stOverlayEx.u32BgColor = 0x00007c00;
stRgnAttr.unAttr.stOverlayEx.u32BgColor = 0xff007c00;
printf("RGN_HANDLE_MAX:%d\n",RGN_HANDLE_MAX);
s32Ret = HI_MPI_RGN_Create(i, &stRgnAttr);
if(s32Ret != HI_SUCCESS)
{
SAMPLE_RGN_NOT_PASS(s32Ret);
}
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAYEX_RGN;
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32X = 0;
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32Y = 0;
stChnAttr.unChnAttr.stOverlayExChn.u32BgAlpha = 128;
stChnAttr.unChnAttr.stOverlayExChn.u32FgAlpha = 128;
stChnAttr.unChnAttr.stOverlayExChn.u32Layer = i;
#if 0
stChnAttr.unChnAttr.stOverlayExChn.stQpInfo.bAbsQp = HI_FALSE;
stChnAttr.unChnAttr.stOverlayExChn.stQpInfo.s32Qp = 0;
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.stInvColArea.u32Height = 16*(i%2+1);
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.stInvColArea.u32Width = 16*(i%2+1);
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.u32LumThresh = 128;
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.bInvColEn = HI_TRUE;
if (i%2)
{
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.bInvColEn = HI_FALSE;
}
#endif
s32Ret = HI_MPI_RGN_AttachToChn(i, &stChn, &stChnAttr);
if(s32Ret != HI_SUCCESS)
{
SAMPLE_RGN_NOT_PASS(s32Ret);
}
}
return HI_SUCCESS;
}
HI_S32 MY_RGN_UpdateCanvas(const char *filename, BITMAP_S *pstBitmap, HI_BOOL bFil,
HI_U32 u16FilColor, SIZE_S *pstSize, HI_U32 u32Stride, PIXEL_FORMAT_E enPixelFmt)
{
OSD_SURFACE_S Surface;
OSD_BITMAPFILEHEADER bmpFileHeader;
OSD_BITMAPINFO bmpInfo;
if(GetBmpInfo(filename, &bmpFileHeader, &bmpInfo) < 0)
{
printf("GetBmpInfo err!\n");
return HI_FAILURE;
}
if (PIXEL_FORMAT_RGB_1555 == enPixelFmt)
{
Surface.enColorFmt = OSD_COLOR_FMT_RGB1555;
}
else if (PIXEL_FORMAT_RGB_4444 == enPixelFmt)
{
Surface.enColorFmt = OSD_COLOR_FMT_RGB4444;
}
else if (PIXEL_FORMAT_RGB_8888 == enPixelFmt)
{
Surface.enColorFmt = OSD_COLOR_FMT_RGB8888;
}
else
{
printf("Pixel format is not support!\n");
return HI_FAILURE;
}
if(NULL == pstBitmap->pData)
{
printf("malloc osd memroy err!\n");
return HI_FAILURE;
}
int ret=0;
ret=CreateSurfaceByCanvas(filename, &Surface, (HI_U8*)(pstBitmap->pData), pstSize->u32Width, pstSize->u32Height, u32Stride);
if(ret==-1)printf("CreateSurfaceByCanvas err\n");
pstBitmap->u32Width = Surface.u16Width;
pstBitmap->u32Height = Surface.u16Height;
if (PIXEL_FORMAT_RGB_1555 == enPixelFmt)
{
pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_1555;
}
else if (PIXEL_FORMAT_RGB_4444 == enPixelFmt)
{
pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_4444;
}
else if (PIXEL_FORMAT_RGB_8888 == enPixelFmt)
{
pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_8888;
}
int i,j;
HI_U16 *pu16Temp;
pu16Temp = (HI_U16*)pstBitmap->pData;
if (bFil)
{
for (i=0; iu32Height; i++)
{
for (j=0; ju32Width; j++)
{
if (u16FilColor == *pu16Temp)
{
*pu16Temp &= 0x7FFF;
}
pu16Temp++;
}
}
}
return HI_SUCCESS;
}
HI_S32 Rgn_AddOsdTo_Vo(HI_VOID)
{
HI_S32 s32Ret = HI_SUCCESS;
HI_S32 u32OverlayexRgnNum;
HI_S32 u32CoverexRgnNum;
HI_S32 u32LineRgnNum;
RGN_HANDLE OverlayexHandle;
RGN_ATTR_S stRgnAttrSet;
RGN_CANVAS_INFO_S stCanvasInfo;
BITMAP_S stBitmap;
VO_DEV VoDev;
VO_LAYER VoLayer;
HI_U32 s32VoChnNum;
VO_INTF_SYNC_E enIntfSync;
RGN_ATTR_INFO_S stRgnAttrInfo0;
RGN_ATTR_INFO_S stRgnAttrInfo1;
SIZE_S stSize;
HI_U32 ChnID;
HI_U32 i;
/*************************************************
step 1: create region and attach to vpss group
*************************************************/
OverlayexHandle = 0;
u32OverlayexRgnNum = 1;
ChnID =2;
printf("OVERLAYEX_MAX_NUM_VO:%d\n",OVERLAYEX_MAX_NUM_VO);
s32Ret = SAMPLE_RGN_CreateOverlayex(OverlayexHandle, ChnID, u32OverlayexRgnNum, HI_ID_VOU);
if(HI_SUCCESS != s32Ret)
{
printf("SAMPLE_RGN_CreateOverlayex failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU1;
}
printf("SAMPLE_RGN_CreateOverlayex 0ver\n");
/*************************************************
step 5: load bitmap to region
*************************************************/
while(1)
{
for(i=0; i
{
s32Ret = HI_MPI_RGN_GetAttr(OverlayexHandle+i, &stRgnAttrSet);
if(HI_SUCCESS != s32Ret)
{
printf("HI_MPI_RGN_GetAttr failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU7;
}
s32Ret = HI_MPI_RGN_GetCanvasInfo(OverlayexHandle+i, &stCanvasInfo);
if(HI_SUCCESS != s32Ret)
{
printf("HI_MPI_RGN_GetCanvasInfo failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU7;
}
stBitmap.pData = (HI_VOID *)stCanvasInfo.u32VirtAddr;
stSize.u32Width = stCanvasInfo.stSize.u32Width;
stSize.u32Height = stCanvasInfo.stSize.u32Height;
s32Ret = MY_RGN_UpdateCanvas("mm2.bmp", &stBitmap, HI_FALSE, 0, &stSize, stCanvasInfo.u32Stride, stRgnAttrSet.unAttr.stOverlay.enPixelFmt);
//s32Ret = SAMPLE_RGN_UpdateCanvas(&stBitmap, HI_FALSE, 0, &stSize, stCanvasInfo.u32Stride,
stRgnAttrSet.unAttr.stOverlay.enPixelFmt);
if(HI_SUCCESS != s32Ret)
{
printf("MY_RGN_UpdateCanvas failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU7;
}
s32Ret = HI_MPI_RGN_UpdateCanvas(OverlayexHandle+i);
if(HI_SUCCESS != s32Ret)
{
printf("HI_MPI_RGN_UpdateCanvas failed! s32Ret: 0x%x.\n", s32Ret);
// goto END_OCL_VOU7;
}
else printf("HI_MPI_RGN_UpdateCanvas success \n");
}
//sleep(1);
}
/*************************************************
step 6: create a thread to change region's
layer, position, alpha and other display attribute
*************************************************/
//RgnAttrInfo0.Handle = OverlayexHandle;
//tRgnAttrInfo0.u32RgnNum = u32OverlayexRgnNum;
//read_create(&g_stRgnCoverThread, NULL, SAMPLE_RGN_VouOverlayexDynamicDisplay, (HI_VOID*)&stRgnAttrInfo0);
//stRgnAttrInfo1.Handle = CoverexHandle;
//stRgnAttrInfo1.u32RgnNum = u32CoverexRgnNum;
//pthread_create(&g_stRgnOsdThread, NULL, SAMPLE_RGN_VouCoverexDynamicDisplay, (HI_VOID*)&stRgnAttrInfo1);
}
{
HI_S32 i;
HI_S32 s32Ret;
MPP_CHN_S stChn;
RGN_ATTR_S stRgnAttr;
RGN_CHN_ATTR_S stChnAttr;
/* Add cover to vpss group */
stChn.enModId = u32ModId;
stChn.s32DevId = 0;
stChn.s32ChnId = ChnId;
for (i=Handle; i<(Handle + u32Num); i++)
{
stRgnAttr.enType = OVERLAYEX_RGN;
stRgnAttr.unAttr.stOverlayEx.enPixelFmt = PIXEL_FORMAT_RGB_1555;
stRgnAttr.unAttr.stOverlayEx.stSize.u32Width = 128;
stRgnAttr.unAttr.stOverlayEx.stSize.u32Height = 128;
//stRgnAttr.unAttr.stOverlayEx.u32BgColor = 0x00007c00;
stRgnAttr.unAttr.stOverlayEx.u32BgColor = 0xff007c00;
printf("RGN_HANDLE_MAX:%d\n",RGN_HANDLE_MAX);
s32Ret = HI_MPI_RGN_Create(i, &stRgnAttr);
if(s32Ret != HI_SUCCESS)
{
SAMPLE_RGN_NOT_PASS(s32Ret);
}
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAYEX_RGN;
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32X = 0;
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32Y = 0;
stChnAttr.unChnAttr.stOverlayExChn.u32BgAlpha = 128;
stChnAttr.unChnAttr.stOverlayExChn.u32FgAlpha = 128;
stChnAttr.unChnAttr.stOverlayExChn.u32Layer = i;
#if 0
stChnAttr.unChnAttr.stOverlayExChn.stQpInfo.bAbsQp = HI_FALSE;
stChnAttr.unChnAttr.stOverlayExChn.stQpInfo.s32Qp = 0;
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.stInvColArea.u32Height = 16*(i%2+1);
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.stInvColArea.u32Width = 16*(i%2+1);
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.u32LumThresh = 128;
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.bInvColEn = HI_TRUE;
if (i%2)
{
stChnAttr.unChnAttr.stOverlayExChn.stInvertColor.bInvColEn = HI_FALSE;
}
#endif
s32Ret = HI_MPI_RGN_AttachToChn(i, &stChn, &stChnAttr);
if(s32Ret != HI_SUCCESS)
{
SAMPLE_RGN_NOT_PASS(s32Ret);
}
}
return HI_SUCCESS;
}
HI_S32 MY_RGN_UpdateCanvas(const char *filename, BITMAP_S *pstBitmap, HI_BOOL bFil,
HI_U32 u16FilColor, SIZE_S *pstSize, HI_U32 u32Stride, PIXEL_FORMAT_E enPixelFmt)
{
OSD_SURFACE_S Surface;
OSD_BITMAPFILEHEADER bmpFileHeader;
OSD_BITMAPINFO bmpInfo;
if(GetBmpInfo(filename, &bmpFileHeader, &bmpInfo) < 0)
{
printf("GetBmpInfo err!\n");
return HI_FAILURE;
}
if (PIXEL_FORMAT_RGB_1555 == enPixelFmt)
{
Surface.enColorFmt = OSD_COLOR_FMT_RGB1555;
}
else if (PIXEL_FORMAT_RGB_4444 == enPixelFmt)
{
Surface.enColorFmt = OSD_COLOR_FMT_RGB4444;
}
else if (PIXEL_FORMAT_RGB_8888 == enPixelFmt)
{
Surface.enColorFmt = OSD_COLOR_FMT_RGB8888;
}
else
{
printf("Pixel format is not support!\n");
return HI_FAILURE;
}
if(NULL == pstBitmap->pData)
{
printf("malloc osd memroy err!\n");
return HI_FAILURE;
}
int ret=0;
ret=CreateSurfaceByCanvas(filename, &Surface, (HI_U8*)(pstBitmap->pData), pstSize->u32Width, pstSize->u32Height, u32Stride);
if(ret==-1)printf("CreateSurfaceByCanvas err\n");
pstBitmap->u32Width = Surface.u16Width;
pstBitmap->u32Height = Surface.u16Height;
if (PIXEL_FORMAT_RGB_1555 == enPixelFmt)
{
pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_1555;
}
else if (PIXEL_FORMAT_RGB_4444 == enPixelFmt)
{
pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_4444;
}
else if (PIXEL_FORMAT_RGB_8888 == enPixelFmt)
{
pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_8888;
}
int i,j;
HI_U16 *pu16Temp;
pu16Temp = (HI_U16*)pstBitmap->pData;
if (bFil)
{
for (i=0; i
{
for (j=0; j
{
if (u16FilColor == *pu16Temp)
{
*pu16Temp &= 0x7FFF;
}
pu16Temp++;
}
}
}
return HI_SUCCESS;
}
HI_S32 Rgn_AddOsdTo_Vo(HI_VOID)
{
HI_S32 s32Ret = HI_SUCCESS;
HI_S32 u32OverlayexRgnNum;
HI_S32 u32CoverexRgnNum;
HI_S32 u32LineRgnNum;
RGN_HANDLE OverlayexHandle;
RGN_ATTR_S stRgnAttrSet;
RGN_CANVAS_INFO_S stCanvasInfo;
BITMAP_S stBitmap;
VO_DEV VoDev;
VO_LAYER VoLayer;
HI_U32 s32VoChnNum;
VO_INTF_SYNC_E enIntfSync;
RGN_ATTR_INFO_S stRgnAttrInfo0;
RGN_ATTR_INFO_S stRgnAttrInfo1;
SIZE_S stSize;
HI_U32 ChnID;
HI_U32 i;
/*************************************************
step 1: create region and attach to vpss group
*************************************************/
OverlayexHandle = 0;
u32OverlayexRgnNum = 1;
ChnID =2;
printf("OVERLAYEX_MAX_NUM_VO:%d\n",OVERLAYEX_MAX_NUM_VO);
s32Ret = SAMPLE_RGN_CreateOverlayex(OverlayexHandle, ChnID, u32OverlayexRgnNum, HI_ID_VOU);
if(HI_SUCCESS != s32Ret)
{
printf("SAMPLE_RGN_CreateOverlayex failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU1;
}
printf("SAMPLE_RGN_CreateOverlayex 0ver\n");
/*************************************************
step 5: load bitmap to region
*************************************************/
while(1)
{
for(i=0; i
s32Ret = HI_MPI_RGN_GetAttr(OverlayexHandle+i, &stRgnAttrSet);
if(HI_SUCCESS != s32Ret)
{
printf("HI_MPI_RGN_GetAttr failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU7;
}
s32Ret = HI_MPI_RGN_GetCanvasInfo(OverlayexHandle+i, &stCanvasInfo);
if(HI_SUCCESS != s32Ret)
{
printf("HI_MPI_RGN_GetCanvasInfo failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU7;
}
stBitmap.pData = (HI_VOID *)stCanvasInfo.u32VirtAddr;
stSize.u32Width = stCanvasInfo.stSize.u32Width;
stSize.u32Height = stCanvasInfo.stSize.u32Height;
s32Ret = MY_RGN_UpdateCanvas("mm2.bmp", &stBitmap, HI_FALSE, 0, &stSize, stCanvasInfo.u32Stride, stRgnAttrSet.unAttr.stOverlay.enPixelFmt);
//s32Ret = SAMPLE_RGN_UpdateCanvas(&stBitmap, HI_FALSE, 0, &stSize, stCanvasInfo.u32Stride,
stRgnAttrSet.unAttr.stOverlay.enPixelFmt);
if(HI_SUCCESS != s32Ret)
{
printf("MY_RGN_UpdateCanvas failed! s32Ret: 0x%x.\n", s32Ret);
//goto END_OCL_VOU7;
}
s32Ret = HI_MPI_RGN_UpdateCanvas(OverlayexHandle+i);
if(HI_SUCCESS != s32Ret)
{
printf("HI_MPI_RGN_UpdateCanvas failed! s32Ret: 0x%x.\n", s32Ret);
// goto END_OCL_VOU7;
}
else printf("HI_MPI_RGN_UpdateCanvas success \n");
}
//sleep(1);
}
/*************************************************
step 6: create a thread to change region's
layer, position, alpha and other display attribute
*************************************************/
//RgnAttrInfo0.Handle = OverlayexHandle;
//tRgnAttrInfo0.u32RgnNum = u32OverlayexRgnNum;
//read_create(&g_stRgnCoverThread, NULL, SAMPLE_RGN_VouOverlayexDynamicDisplay, (HI_VOID*)&stRgnAttrInfo0);
//stRgnAttrInfo1.Handle = CoverexHandle;
//stRgnAttrInfo1.u32RgnNum = u32CoverexRgnNum;
//pthread_create(&g_stRgnOsdThread, NULL, SAMPLE_RGN_VouCoverexDynamicDisplay, (HI_VOID*)&stRgnAttrInfo1);
}
我来回答
回答1个
时间排序
认可量排序
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2019-01-21 14:24:34
-
2023-09-06 11:16:18
-
2018-12-29 14:53:50
-
2021-03-26 18:11:26
-
2017-09-15 15:09:30
-
2019-01-07 13:42:38
-
2021-02-22 14:32:38
-
2020-10-22 19:51:42
-
2021-07-12 16:43:05
-
2022-08-24 16:39:19
-
2019-01-21 14:33:12
-
2017-07-20 15:59:05
-
2020-11-21 16:47:55
-
2018-10-26 01:20:03
-
2018-11-08 14:47:04
-
2018-04-14 15:01:04
-
2020-12-12 12:34:59
-
2018-10-25 15:22:15
-
2018-10-22 14:24:49
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认