在做车牌识别项目,通过先对识别区域内进行目标识别,能降低CPU的占用率,在检测到有运动目标的时候,再做车牌识别。
s32Ret = HI_MPI_IVE_Sub(&IveHandle, &pstGmm->stSrc,
&pstGmm->stbgImg, &pstGmm->stBgDiffFg, &pstGmm->stSubCtrl,
bInstant);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_IVE_Sub fail,Error(%#x)\n", s32Ret);
return
s32Ret;
}
//差分图像二值化
s32Ret = HI_MPI_IVE_Thresh(&IveHandle,
&pstGmm->stBgDiffFg, &pstGmm->stBinaryImg,
&pstGmm->stThrCtrl, bInstant);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_IVE_Thresh fail,Error(%#x)\n",
s32Ret);
return s32Ret;
}
s32Ret = HI_MPI_IVE_Erode(&IveHandle,
&pstGmm->stBinaryImg, &pstGmm->stErodeImg,
&pstGmm->stErodeCtrl, bInstant);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_IVE_Erode fail,Error(%#x)\n",
s32Ret);
return s32Ret;
}
s32Ret = HI_MPI_IVE_Integ(&IveHandle,
&pstGmm->stErodeImg, &pstGmm->stDiffInteg,
&pstGmm->stIntegCtrl, bInstant);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_PRT("HI_MPI_IVE_Integ fail,Error(%#x)\n",
s32Ret);
return s32Ret;
}
pu64VirDataDiff =
(HI_U32*)pstGmm->stDiffInteg.pu8VirAddr[0];
//x1-y1
HI_U32 index =
(g_recogArea.y+g_recogArea.height-1)*pstGmm->stInteg.u16Stride[0]+g_recogArea.x+g_recogArea.width-1;
HI_U32
sum_x1_y1 = (HI_U32) pu64VirDataDiff[index];
pu64VirDataDiff[pstGmm->stInteg.u16Height*pstGmm->stInteg.u16Stride[0]-1];
index =
g_recogArea.y*pstGmm->stInteg.u16Stride[0]+g_recogArea.x;
HI_U32
sum_x0_y0 = (HI_U32) pu64VirDataDiff[index]; // (HI_U32)
pu64VirDataDiff[0];
//x0-y1
(g_recogArea.y+g_recogArea.height-1)*pstGmm->stInteg.u16Stride[0]+g_recogArea.x;
HI_U32
sum_x0_y1 = (HI_U32) pu64VirDataDiff[index];
//x1-y0
=g_recogArea.y*pstGmm->stInteg.u16Stride[0]+g_recogArea.x+g_recogArea.width-1;
HI_U32
sum_x1_y0 = (HI_U32) pu64VirDataDiff[index];
HI_U32 motionArea = sum_x1_y1 + sum_x0_y0 - sum_x0_y1 -
sum_x1_y0;
----number=%d\n",sum_x1_y1, sum_x0_y0, motionArea, sum_x1_y1);
if(motionArea>300)
{
3;
}else
{
if(pstGmm->objectFlag>0)
{
pstGmm->objectFlag--;
}
}
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:海思hi3516 ive运动目标检测简单实现 - Python技术站