4264
- 收藏
- 点赞
- 分享
- 举报
HI3516DV300用OSD给画框贴标签但不显示的问题
我的方案是在3516平台上做实时检测。现在有一段mp4视频,用ffmpeg转码成h264后,好像并不能解码,所以现在是把视频分解成一帧一帧的jpeg图片,送如VDEC解码。VDEC解码后送如VPSS,从VPSS中获取缩放大小的图像,送入网络模型处理。处理后获得画框的坐标,并用VGS画框。画好框后送如VENC编码,并推流至服务器。目前这个流程已经成功,能看见编码的图像以及分类的画框。现在又要添加新的功能,就是在每个画框上添加标签。我事先已经用SDL生成了标签的bmp图片,然后用Region贴图。现在服务器上的图像只有框,并没有标签。代码如下:
[code]HI_VOID * SAMPLE_COMM_VPSS_getYUV(HI_VOID* p)
{
VIDEO_FRAME_INFO_S stVideoFrame[2];
SAMPLE_VPSS_PARA_S *pstPara = (SAMPLE_VPSS_PARA_S*)p;
VPSS_CHN *CHN = (VPSS_CHN*)pstPara->VpssChn;
HI_CHAR cSaveFile[256];
HI_S32 s32Ret, s32Cnt = 0;
FILE *fp = HI_NULL;
HI_S32 s32VpssChnFd = -1;
fd_set read_fds;
struct timeval TimeoutVal;
HI_S32 maxfd = 0;
VO_LAYER voLayer = 0;
VO_CHN voChn = 0;
HI_S32 s32MilliSec = 2000;
VENC_CHN VencChn[4] = {0, 1, 2, 3};
int flag = 0;
int w_ = 608;
int h_ = 608;
float scale_[2] = {0};
std::vector bboxes;
int cnt = 0;
float sum = 0.0;
while(pstPara->bThreadStart)
{
s32Ret = HI_MPI_VPSS_GetChnFrame(pstPara->VpssGrp,CHN[1],&stVideoFrame[1], s32MilliSec);
s32Ret |= HI_MPI_VPSS_GetChnFrame(pstPara->VpssGrp,CHN[0],&stVideoFrame[0], s32MilliSec);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("HI_MPI_VPSS_GetChnFrame failed with %#x\n", s32Ret);
continue;
}
else
{
bboxes.clear();
process2result(&stVideoFrame[1].stVFrame,bboxes);//送如模型处理,并获得画框的坐标
// ///!然后将框画在原图上----------
if(!bboxes.empty())
{
SAMPLE_RECT_ARRAY_S stRect;
stRect.u16Num = 0;
int xmin,ymin,xmax,ymax;
for (int loop = 0;loop < bboxes.size() && loop < IVE_RECT_NUM;++loop) {
xmin = (int)bboxes[loop].getCoordinate(0).first;
ymin = (int)bboxes[loop].getCoordinate(0).second;
xmax = (int)bboxes[loop].getCoordinate(1).first;
ymax = (int)bboxes[loop].getCoordinate(1).second;
xmin = (xmin >> 1) << 1;
ymin = (ymin >> 1) << 1;
xmax = (xmax >> 1) << 1;
ymax = (ymax >> 1) << 1;
stRect.astRect[loop].astPoint[0].s32X = xmin;
stRect.astRect[loop].astPoint[0].s32Y = ymin;
stRect.astRect[loop].astPoint[1].s32X = xmax;
stRect.astRect[loop].astPoint[1].s32Y = ymin;
stRect.astRect[loop].astPoint[2].s32X = xmax;
stRect.astRect[loop].astPoint[2].s32Y = ymax;
stRect.astRect[loop].astPoint[3].s32X = xmin;
stRect.astRect[loop].astPoint[3].s32Y = ymax;
++stRect.u16Num;
}
drawLabel(bboxes);//把标签画出来
s32Ret = drawRectangle(stVideoFrame[0], stRect, (UINT32)0x0000FF00);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Error(%#x),SAMPLE_COMM_VGS_FillRect failed!\n", s32Ret);
}
}
s32Ret = HI_MPI_VENC_SendFrame(VencChn[1],&stVideoFrame[0],s32MilliSec);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Error(%#x),HI_MPI_VENC_SendFrame failed!\n", s32Ret);
return nullptr;
}
s32Cnt++;
}
s32Ret=HI_MPI_VPSS_ReleaseChnFrame(pstPara->VpssGrp, CHN[0], &stVideoFrame[0]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("chn %d HI_MPI_VDEC_ReleaseFrame fail for s32Ret=0x%x!\n", CHN[0], s32Ret);
break;
}
s32Ret=HI_MPI_VPSS_ReleaseChnFrame(pstPara->VpssGrp, CHN[1], &stVideoFrame[1]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("chn %d HI_MPI_VDEC_ReleaseFrame fail for s32Ret=0x%x!\n", CHN[1], s32Ret);
break;
}
}
return 0;
}
[/code]
画标签的代码:
[code]HI_S32 drawLabel(const std::vector& bboxes)
{
HI_S32 s32Ret;
HI_S32 HandleNum;
RGN_TYPE_E enType;
MPP_CHN_S stChn;
HI_S32 i;
HI_S32 MinHandle;
HandleNum =bboxes.size();
enType = OVERLAY_RGN;
stChn.enModId = HI_ID_VENC;
stChn.s32DevId = 0;
stChn.s32ChnId = 1;
s32Ret = COMM_REGION_Create(HandleNum,enType);
if(s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("COMM_REGION_Create failed!\n");
goto EXIT1;
}
s32Ret = COMM_REGION_AttachToChn(HandleNum,enType,&stChn,bboxes);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_AttachToChn failed!\n");
goto EXIT2;
}
MinHandle = COMM_REGION_GetMinHandle(enType);
if(OVERLAY_RGN == enType || OVERLAYEX_RGN == enType)
{
for(i= MinHandle; i
{
s32Ret = COMM_REGION_SetBitMap(i,PIXEL_FORMAT_ARGB_1555,bboxes[i - MinHandle]);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_SetBitMap failed!\n");
goto EXIT2;
}
}
}
EXIT2:
s32Ret = COMM_REGION_DetachFrmChn(HandleNum,enType,&stChn);
if(HI_SUCCESS!= s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_AttachToChn failed!\n");
}
EXIT1:
s32Ret = COMM_REGION_Destroy(HandleNum,enType);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_AttachToChn failed!\n");
}
return s32Ret;
}
HI_S32 COMM_REGION_Create(HI_S32 HandleNum,RGN_TYPE_E enType)
{
HI_S32 s32Ret;
if(HandleNum <= 0 || HandleNum > 16)
{
SAMPLE_PRT("HandleNum is illegal %d!\n", HandleNum);
return HI_FAILURE;
}
if(enType < 0 || enType > 4)
{
SAMPLE_PRT("enType is illegal %d!\n", enType);
return HI_FAILURE;
}
switch(enType)
{
case OVERLAY_RGN:
s32Ret = REGION_CreateOverLay(HandleNum);
break;
case OVERLAYEX_RGN:
s32Ret = REGION_CreateOverLayEx(HandleNum);
break;
default:
break;
}
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_Create failed! HandleNum%d,entype:%d!\n",HandleNum, enType);
return HI_FAILURE;
}
return s32Ret;
}
HI_S32 REGION_CreateOverLay(HI_S32 HandleNum)
{
HI_S32 s32Ret;
HI_S32 i;
RGN_ATTR_S stRegion;
stRegion.enType = OVERLAY_RGN;
stRegion.unAttr.stOverlay.enPixelFmt = PIXEL_FORMAT_ARGB_1555;
stRegion.unAttr.stOverlay.stSize.u32Height = 200;
stRegion.unAttr.stOverlay.stSize.u32Width = 200;
stRegion.unAttr.stOverlay.u32BgColor = 0x00ff00ff;
stRegion.unAttr.stOverlay.u32CanvasNum = 1;
for(i = OverlayMinHandle;i < HandleNum;i++)
{
s32Ret = HI_MPI_RGN_Create(i, &stRegion);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_Create failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
return s32Ret;
}
HI_S32 REGION_CreateOverLayEx(HI_S32 HandleNum)
{
HI_S32 s32Ret;
HI_S32 i;
RGN_ATTR_S stRegion;
stRegion.enType = OVERLAYEX_RGN;
stRegion.unAttr.stOverlayEx.enPixelFmt = PIXEL_FORMAT_ARGB_1555;
stRegion.unAttr.stOverlayEx.stSize.u32Height = 18;
stRegion.unAttr.stOverlayEx.stSize.u32Width = 128;
stRegion.unAttr.stOverlayEx.u32BgColor = 0xfc;
stRegion.unAttr.stOverlayEx.u32CanvasNum =2;
for(i = OverlayExMinHandle;i < OverlayExMinHandle + HandleNum;i++)
{
s32Ret = HI_MPI_RGN_Create(i, &stRegion);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_Create failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
return s32Ret;
}
HI_S32 COMM_REGION_AttachToChn(HI_S32 HandleNum,RGN_TYPE_E enType, MPP_CHN_S *pstMppChn,const std::vector& bboxes)
{
HI_S32 i;
HI_S32 s32Ret;
HI_S32 MinHadle;
RGN_CHN_ATTR_S stChnAttr;
if(HandleNum <= 0 || HandleNum > 16)
{
SAMPLE_PRT("HandleNum is illegal %d!\n", HandleNum);
return HI_FAILURE;
}
if(enType < 0 || enType > 4)
{
SAMPLE_PRT("enType is illegal %d!\n", enType);
return HI_FAILURE;
}
if(HI_NULL == pstMppChn)
{
SAMPLE_PRT("pstMppChn is NULL !\n");
return HI_FAILURE;
}
/*set the chn config*/
stChnAttr.bShow = HI_TRUE;
switch(enType)
{
case OVERLAY_RGN:
MinHadle = OverlayMinHandle;
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAY_RGN;
stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 128;
stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 128;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bQpDisable = HI_FALSE;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bAbsQp = HI_TRUE;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.s32Qp = 30;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Height = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Width = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.u32LumThresh = 128;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.bInvColEn = HI_FALSE;
stChnAttr.unChnAttr.stOverlayChn.u16ColorLUT[0] = 0x2abc;
stChnAttr.unChnAttr.stOverlayChn.u16ColorLUT[1] = 0x7FF0;
stChnAttr.unChnAttr.stOverlayChn.enAttachDest = ATTACH_JPEG_MAIN;
break;
case OVERLAYEX_RGN:
MinHadle = OverlayExMinHandle;
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAYEX_RGN;
stChnAttr.unChnAttr.stOverlayExChn.u32BgAlpha = 128;
stChnAttr.unChnAttr.stOverlayExChn.u32FgAlpha = 128;
break;
default:
break;
}
/*attach to Chn*/
for(i =MinHadle; i < MinHadle+HandleNum ;i++)
{
int xmin = static_cast(bboxes.getCoordinate(MINC).first);
int ymin = static_cast(bboxes.getCoordinate(MINC).second);
// int label = bboxes.getLabel();
if(OVERLAY_RGN == enType)
{
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = 20 + ((xmin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 20 + ((ymin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayChn.u32Layer = i - OverlayMinHandle;
}
if(OVERLAYEX_RGN == enType)
{
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32X = 20 + ((xmin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32Y = 20 + ((ymin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayExChn.u32Layer = i - OverlayExMinHandle;
}
s32Ret = REGION_AttachToChn(i,pstMppChn,&stChnAttr);
if(HI_SUCCESS !=s32Ret)
{
SAMPLE_PRT("SAMPLE_REGION_AttachToChn failed!\n");
break;
}
}
/*detach region from chn */
if(HI_SUCCESS != s32Ret && i>0)
{
i--;
for(;i>=MinHadle;i--)
{
s32Ret = REGION_DetachFromChn(i,pstMppChn);
}
}
return s32Ret;
}
HI_S32 REGION_AttachToChn(RGN_HANDLE Handle,MPP_CHN_S *pstChn, RGN_CHN_ATTR_S *pstChnAttr)
{
HI_S32 s32Ret;
s32Ret = HI_MPI_RGN_AttachToChn(Handle, pstChn,pstChnAttr);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_AttachToChn failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
return s32Ret;
}
HI_S32 REGION_DetachFromChn(RGN_HANDLE Handle,MPP_CHN_S *pstChn)
{
HI_S32 s32Ret;
s32Ret = HI_MPI_RGN_DetachFromChn(Handle, pstChn);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_DetachFromChn failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
return s32Ret;
}
HI_S32 COMM_REGION_DetachFrmChn(HI_S32 HandleNum,RGN_TYPE_E enType, MPP_CHN_S *pstMppChn)
{
HI_S32 i;
HI_S32 s32Ret = HI_SUCCESS;
HI_S32 MinHadle;
if(HandleNum <= 0 || HandleNum > 16)
{
SAMPLE_PRT("HandleNum is illegal %d!\n", HandleNum);
return HI_FAILURE;
}
if(enType < 0 || enType > 4)
{
SAMPLE_PRT("enType is illegal %d!\n", enType);
return HI_FAILURE;
}
if(HI_NULL == pstMppChn)
{
SAMPLE_PRT("pstMppChn is NULL !\n");
return HI_FAILURE;
}
switch(enType)
{
case OVERLAY_RGN:
MinHadle = OverlayMinHandle;
break;
case OVERLAYEX_RGN:
MinHadle = OverlayExMinHandle;
break;
default:
break;
}
for(i = MinHadle;i< MinHadle + HandleNum;i++)
{
s32Ret = REGION_DetachFromChn(i, pstMppChn);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_REGION_DetachFromChn failed! Handle:%d\n",i);
}
}
return s32Ret;
}
HI_S32 REGION_SetBitMap(RGN_HANDLE Handle, BITMAP_S *pstBitmap)
{
HI_S32 s32Ret;
s32Ret = HI_MPI_RGN_SetBitMap(Handle,pstBitmap);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_SetBitMap failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
// printf("HI_MPI_RGN_SetBitMap\n");
return s32Ret;
}
HI_S32 COMM_REGION_GetMinHandle(RGN_TYPE_E enType)
{
HI_S32 MinHandle;
switch(enType)
{
case OVERLAY_RGN:
MinHandle = OverlayMinHandle;
break;
case OVERLAYEX_RGN:
MinHandle = OverlayExMinHandle;
break;
default:
MinHandle = -1;
break;
}
return MinHandle;
}[/code]
[code]HI_S32 COMM_REGION_SetBitMap(RGN_HANDLE Handle,PIXEL_FORMAT_E enPixelFmt,const BBox& bbox)
{
HI_S32 s32Ret;
BITMAP_S stBitmap;
const char* bmpFile = ImageSet::getInstance()->getLabelBMPName(bbox.getLabel());
SampleLoadRgnBmp(bmpFile,&stBitmap,HI_FALSE,enPixelFmt);
s32Ret = REGION_SetBitMap(Handle, &stBitmap);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("SAMPLE_REGION_SetBitMap failed!Handle:%d\n",Handle);
}
free(stBitmap.pData);
return s32Ret;
}[/code]
[code]HI_VOID * SAMPLE_COMM_VPSS_getYUV(HI_VOID* p)
{
VIDEO_FRAME_INFO_S stVideoFrame[2];
SAMPLE_VPSS_PARA_S *pstPara = (SAMPLE_VPSS_PARA_S*)p;
VPSS_CHN *CHN = (VPSS_CHN*)pstPara->VpssChn;
HI_CHAR cSaveFile[256];
HI_S32 s32Ret, s32Cnt = 0;
FILE *fp = HI_NULL;
HI_S32 s32VpssChnFd = -1;
fd_set read_fds;
struct timeval TimeoutVal;
HI_S32 maxfd = 0;
VO_LAYER voLayer = 0;
VO_CHN voChn = 0;
HI_S32 s32MilliSec = 2000;
VENC_CHN VencChn[4] = {0, 1, 2, 3};
int flag = 0;
int w_ = 608;
int h_ = 608;
float scale_[2] = {0};
std::vector
int cnt = 0;
float sum = 0.0;
while(pstPara->bThreadStart)
{
s32Ret = HI_MPI_VPSS_GetChnFrame(pstPara->VpssGrp,CHN[1],&stVideoFrame[1], s32MilliSec);
s32Ret |= HI_MPI_VPSS_GetChnFrame(pstPara->VpssGrp,CHN[0],&stVideoFrame[0], s32MilliSec);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("HI_MPI_VPSS_GetChnFrame failed with %#x\n", s32Ret);
continue;
}
else
{
bboxes.clear();
process2result(&stVideoFrame[1].stVFrame,bboxes);//送如模型处理,并获得画框的坐标
// ///!然后将框画在原图上----------
if(!bboxes.empty())
{
SAMPLE_RECT_ARRAY_S stRect;
stRect.u16Num = 0;
int xmin,ymin,xmax,ymax;
for (int loop = 0;loop < bboxes.size() && loop < IVE_RECT_NUM;++loop) {
xmin = (int)bboxes[loop].getCoordinate(0).first;
ymin = (int)bboxes[loop].getCoordinate(0).second;
xmax = (int)bboxes[loop].getCoordinate(1).first;
ymax = (int)bboxes[loop].getCoordinate(1).second;
xmin = (xmin >> 1) << 1;
ymin = (ymin >> 1) << 1;
xmax = (xmax >> 1) << 1;
ymax = (ymax >> 1) << 1;
stRect.astRect[loop].astPoint[0].s32X = xmin;
stRect.astRect[loop].astPoint[0].s32Y = ymin;
stRect.astRect[loop].astPoint[1].s32X = xmax;
stRect.astRect[loop].astPoint[1].s32Y = ymin;
stRect.astRect[loop].astPoint[2].s32X = xmax;
stRect.astRect[loop].astPoint[2].s32Y = ymax;
stRect.astRect[loop].astPoint[3].s32X = xmin;
stRect.astRect[loop].astPoint[3].s32Y = ymax;
++stRect.u16Num;
}
drawLabel(bboxes);//把标签画出来
s32Ret = drawRectangle(stVideoFrame[0], stRect, (UINT32)0x0000FF00);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Error(%#x),SAMPLE_COMM_VGS_FillRect failed!\n", s32Ret);
}
}
s32Ret = HI_MPI_VENC_SendFrame(VencChn[1],&stVideoFrame[0],s32MilliSec);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("Error(%#x),HI_MPI_VENC_SendFrame failed!\n", s32Ret);
return nullptr;
}
s32Cnt++;
}
s32Ret=HI_MPI_VPSS_ReleaseChnFrame(pstPara->VpssGrp, CHN[0], &stVideoFrame[0]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("chn %d HI_MPI_VDEC_ReleaseFrame fail for s32Ret=0x%x!\n", CHN[0], s32Ret);
break;
}
s32Ret=HI_MPI_VPSS_ReleaseChnFrame(pstPara->VpssGrp, CHN[1], &stVideoFrame[1]);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("chn %d HI_MPI_VDEC_ReleaseFrame fail for s32Ret=0x%x!\n", CHN[1], s32Ret);
break;
}
}
return 0;
}
[/code]
画标签的代码:
[code]HI_S32 drawLabel(const std::vector
{
HI_S32 s32Ret;
HI_S32 HandleNum;
RGN_TYPE_E enType;
MPP_CHN_S stChn;
HI_S32 i;
HI_S32 MinHandle;
HandleNum =bboxes.size();
enType = OVERLAY_RGN;
stChn.enModId = HI_ID_VENC;
stChn.s32DevId = 0;
stChn.s32ChnId = 1;
s32Ret = COMM_REGION_Create(HandleNum,enType);
if(s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("COMM_REGION_Create failed!\n");
goto EXIT1;
}
s32Ret = COMM_REGION_AttachToChn(HandleNum,enType,&stChn,bboxes);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_AttachToChn failed!\n");
goto EXIT2;
}
MinHandle = COMM_REGION_GetMinHandle(enType);
if(OVERLAY_RGN == enType || OVERLAYEX_RGN == enType)
{
for(i= MinHandle; i
s32Ret = COMM_REGION_SetBitMap(i,PIXEL_FORMAT_ARGB_1555,bboxes[i - MinHandle]);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_SetBitMap failed!\n");
goto EXIT2;
}
}
}
EXIT2:
s32Ret = COMM_REGION_DetachFrmChn(HandleNum,enType,&stChn);
if(HI_SUCCESS!= s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_AttachToChn failed!\n");
}
EXIT1:
s32Ret = COMM_REGION_Destroy(HandleNum,enType);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_AttachToChn failed!\n");
}
return s32Ret;
}
HI_S32 COMM_REGION_Create(HI_S32 HandleNum,RGN_TYPE_E enType)
{
HI_S32 s32Ret;
if(HandleNum <= 0 || HandleNum > 16)
{
SAMPLE_PRT("HandleNum is illegal %d!\n", HandleNum);
return HI_FAILURE;
}
if(enType < 0 || enType > 4)
{
SAMPLE_PRT("enType is illegal %d!\n", enType);
return HI_FAILURE;
}
switch(enType)
{
case OVERLAY_RGN:
s32Ret = REGION_CreateOverLay(HandleNum);
break;
case OVERLAYEX_RGN:
s32Ret = REGION_CreateOverLayEx(HandleNum);
break;
default:
break;
}
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_COMM_REGION_Create failed! HandleNum%d,entype:%d!\n",HandleNum, enType);
return HI_FAILURE;
}
return s32Ret;
}
HI_S32 REGION_CreateOverLay(HI_S32 HandleNum)
{
HI_S32 s32Ret;
HI_S32 i;
RGN_ATTR_S stRegion;
stRegion.enType = OVERLAY_RGN;
stRegion.unAttr.stOverlay.enPixelFmt = PIXEL_FORMAT_ARGB_1555;
stRegion.unAttr.stOverlay.stSize.u32Height = 200;
stRegion.unAttr.stOverlay.stSize.u32Width = 200;
stRegion.unAttr.stOverlay.u32BgColor = 0x00ff00ff;
stRegion.unAttr.stOverlay.u32CanvasNum = 1;
for(i = OverlayMinHandle;i < HandleNum;i++)
{
s32Ret = HI_MPI_RGN_Create(i, &stRegion);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_Create failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
return s32Ret;
}
HI_S32 REGION_CreateOverLayEx(HI_S32 HandleNum)
{
HI_S32 s32Ret;
HI_S32 i;
RGN_ATTR_S stRegion;
stRegion.enType = OVERLAYEX_RGN;
stRegion.unAttr.stOverlayEx.enPixelFmt = PIXEL_FORMAT_ARGB_1555;
stRegion.unAttr.stOverlayEx.stSize.u32Height = 18;
stRegion.unAttr.stOverlayEx.stSize.u32Width = 128;
stRegion.unAttr.stOverlayEx.u32BgColor = 0xfc;
stRegion.unAttr.stOverlayEx.u32CanvasNum =2;
for(i = OverlayExMinHandle;i < OverlayExMinHandle + HandleNum;i++)
{
s32Ret = HI_MPI_RGN_Create(i, &stRegion);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_Create failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
}
return s32Ret;
}
HI_S32 COMM_REGION_AttachToChn(HI_S32 HandleNum,RGN_TYPE_E enType, MPP_CHN_S *pstMppChn,const std::vector
{
HI_S32 i;
HI_S32 s32Ret;
HI_S32 MinHadle;
RGN_CHN_ATTR_S stChnAttr;
if(HandleNum <= 0 || HandleNum > 16)
{
SAMPLE_PRT("HandleNum is illegal %d!\n", HandleNum);
return HI_FAILURE;
}
if(enType < 0 || enType > 4)
{
SAMPLE_PRT("enType is illegal %d!\n", enType);
return HI_FAILURE;
}
if(HI_NULL == pstMppChn)
{
SAMPLE_PRT("pstMppChn is NULL !\n");
return HI_FAILURE;
}
/*set the chn config*/
stChnAttr.bShow = HI_TRUE;
switch(enType)
{
case OVERLAY_RGN:
MinHadle = OverlayMinHandle;
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAY_RGN;
stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 128;
stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 128;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bQpDisable = HI_FALSE;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bAbsQp = HI_TRUE;
stChnAttr.unChnAttr.stOverlayChn.stQpInfo.s32Qp = 30;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Height = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Width = 16;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.u32LumThresh = 128;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;
stChnAttr.unChnAttr.stOverlayChn.stInvertColor.bInvColEn = HI_FALSE;
stChnAttr.unChnAttr.stOverlayChn.u16ColorLUT[0] = 0x2abc;
stChnAttr.unChnAttr.stOverlayChn.u16ColorLUT[1] = 0x7FF0;
stChnAttr.unChnAttr.stOverlayChn.enAttachDest = ATTACH_JPEG_MAIN;
break;
case OVERLAYEX_RGN:
MinHadle = OverlayExMinHandle;
stChnAttr.bShow = HI_TRUE;
stChnAttr.enType = OVERLAYEX_RGN;
stChnAttr.unChnAttr.stOverlayExChn.u32BgAlpha = 128;
stChnAttr.unChnAttr.stOverlayExChn.u32FgAlpha = 128;
break;
default:
break;
}
/*attach to Chn*/
for(i =MinHadle; i < MinHadle+HandleNum ;i++)
{
int xmin = static_cast
int ymin = static_cast
// int label = bboxes.getLabel();
if(OVERLAY_RGN == enType)
{
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = 20 + ((xmin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 20 + ((ymin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayChn.u32Layer = i - OverlayMinHandle;
}
if(OVERLAYEX_RGN == enType)
{
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32X = 20 + ((xmin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayExChn.stPoint.s32Y = 20 + ((ymin >> 2) << 2);
stChnAttr.unChnAttr.stOverlayExChn.u32Layer = i - OverlayExMinHandle;
}
s32Ret = REGION_AttachToChn(i,pstMppChn,&stChnAttr);
if(HI_SUCCESS !=s32Ret)
{
SAMPLE_PRT("SAMPLE_REGION_AttachToChn failed!\n");
break;
}
}
/*detach region from chn */
if(HI_SUCCESS != s32Ret && i>0)
{
i--;
for(;i>=MinHadle;i--)
{
s32Ret = REGION_DetachFromChn(i,pstMppChn);
}
}
return s32Ret;
}
HI_S32 REGION_AttachToChn(RGN_HANDLE Handle,MPP_CHN_S *pstChn, RGN_CHN_ATTR_S *pstChnAttr)
{
HI_S32 s32Ret;
s32Ret = HI_MPI_RGN_AttachToChn(Handle, pstChn,pstChnAttr);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_AttachToChn failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
return s32Ret;
}
HI_S32 REGION_DetachFromChn(RGN_HANDLE Handle,MPP_CHN_S *pstChn)
{
HI_S32 s32Ret;
s32Ret = HI_MPI_RGN_DetachFromChn(Handle, pstChn);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_DetachFromChn failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
return s32Ret;
}
HI_S32 COMM_REGION_DetachFrmChn(HI_S32 HandleNum,RGN_TYPE_E enType, MPP_CHN_S *pstMppChn)
{
HI_S32 i;
HI_S32 s32Ret = HI_SUCCESS;
HI_S32 MinHadle;
if(HandleNum <= 0 || HandleNum > 16)
{
SAMPLE_PRT("HandleNum is illegal %d!\n", HandleNum);
return HI_FAILURE;
}
if(enType < 0 || enType > 4)
{
SAMPLE_PRT("enType is illegal %d!\n", enType);
return HI_FAILURE;
}
if(HI_NULL == pstMppChn)
{
SAMPLE_PRT("pstMppChn is NULL !\n");
return HI_FAILURE;
}
switch(enType)
{
case OVERLAY_RGN:
MinHadle = OverlayMinHandle;
break;
case OVERLAYEX_RGN:
MinHadle = OverlayExMinHandle;
break;
default:
break;
}
for(i = MinHadle;i< MinHadle + HandleNum;i++)
{
s32Ret = REGION_DetachFromChn(i, pstMppChn);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("SAMPLE_REGION_DetachFromChn failed! Handle:%d\n",i);
}
}
return s32Ret;
}
HI_S32 REGION_SetBitMap(RGN_HANDLE Handle, BITMAP_S *pstBitmap)
{
HI_S32 s32Ret;
s32Ret = HI_MPI_RGN_SetBitMap(Handle,pstBitmap);
if(HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_RGN_SetBitMap failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
// printf("HI_MPI_RGN_SetBitMap\n");
return s32Ret;
}
HI_S32 COMM_REGION_GetMinHandle(RGN_TYPE_E enType)
{
HI_S32 MinHandle;
switch(enType)
{
case OVERLAY_RGN:
MinHandle = OverlayMinHandle;
break;
case OVERLAYEX_RGN:
MinHandle = OverlayExMinHandle;
break;
default:
MinHandle = -1;
break;
}
return MinHandle;
}[/code]
[code]HI_S32 COMM_REGION_SetBitMap(RGN_HANDLE Handle,PIXEL_FORMAT_E enPixelFmt,const BBox& bbox)
{
HI_S32 s32Ret;
BITMAP_S stBitmap;
const char* bmpFile = ImageSet::getInstance()->getLabelBMPName(bbox.getLabel());
SampleLoadRgnBmp(bmpFile,&stBitmap,HI_FALSE,enPixelFmt);
s32Ret = REGION_SetBitMap(Handle, &stBitmap);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_PRT("SAMPLE_REGION_SetBitMap failed!Handle:%d\n",Handle);
}
free(stBitmap.pData);
return s32Ret;
}[/code]
我来回答
回答3个
时间排序
认可量排序
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2020-07-01 12:16:28
-
2019-06-03 11:16:42
-
2019-09-11 10:01:33
-
2020-09-10 17:52:03
-
2019-11-25 20:18:36
-
2019-10-16 14:59:34
-
2020-10-30 14:11:30
-
2019-12-30 22:31:09
-
192018-02-06 16:55:46
-
2019-09-20 16:32:04
-
2019-05-17 12:36:10
-
2024-01-30 23:38:02
-
2020-08-27 15:49:02
-
2020-08-15 21:14:41
-
2019-10-16 10:50:21
-
2020-08-08 22:18:33
-
2020-08-05 16:48:26
-
2022-01-14 14:26:53
-
2020-06-13 17:05:07
无更多相似问答 去提问
点击登录
-- 积分
-- 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币)
取消
确认