我是靠谱客的博主 眯眯眼期待,最近开发中收集的这篇文章主要介绍3516a 尝试跑通GMM 模型之二,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

HI_VOID GMMSampleSingle()
{
#if 1
IVE_SRC_IMAGE_S stIveImg;
IVE_DST_IMAGE_S stIveFg;
IVE_DST_IMAGE_S stIveBg;
HI_BOOL bInstant = HI_TRUE;
// must be true
IVE_HANDLE hIveHandle;
// handle
IVE_MEM_INFO_S *pstDst;
//gmm model
IVE_GMM_CTRL_S stGMMCtrl;
//stGmmCtrl
IplImage *pimgGray=NULL;
IplImage *pfg=NULL;
IplImage *pfgRGB=NULL;
IplImage *pBgGray=NULL;
HI_S32 s32Result;
// if s32Result is 0 success
HI_U32
FrameNum = 1;
CvSize S;
string buff = "list1.txt";
const char * outputDir = "output";
ifstream infile;
infile.open(buff.c_str());
getline(infile, buff);
IplImage * pimg=cvLoadImage(buff.c_str());
HI_U16 u16Width=pimg->width;
HI_U16 u16Height=pimg->height;
cout<<"u16Width "<<u16Width<<endl;
cout<<"u16Height "<<u16Height<<endl;
if(NULL == pimgGray)
{
printf("coming into pimgGrayn");
S = cvSize(pimg->width,pimg->height);
pimgGray = cvCreateImage(S,8,1);
if(HI_NULL == pimgGray)
{
printf("pimgGray creat error");
goto FAILURE;
}
}
// pstDst
//pstDst = (IVE_DST_MEM_INFO_S *)malloc(sizeof(IVE_DST_MEM_INFO_S));
//HI_CHECK_ET_GOTO(pstDst,HI_NULL,FAILURE);
stGMMCtrl.u0q16InitWeight = 3276; //0.05
stGMMCtrl.u0q16BgRatio = 52428;
//0.8
stGMMCtrl.u22q10MaxVar = (2000 << 10);
stGMMCtrl.u22q10MinVar = (200 << 10);
stGMMCtrl.u22q10NoiseVar = (225 << 10);
stGMMCtrl.u8q8VarThr = 1600;
stGMMCtrl.u8ModelNum =3;
stGMMCtrl.u0q16LearnRate = 327;
// init
memset(&stIveImg, 0, sizeof(IVE_SRC_IMAGE_S));
memset(&stIveFg, 0,sizeof(IVE_DST_IMAGE_S));
memset(&stIveBg, 0, sizeof(IVE_DST_IMAGE_S));
//init
SAMPLE_COMM_IVE_CheckIveMpiInit();
while(getline(infile, buff))
{
pimg=cvLoadImage(buff.c_str());
if (!pimg)
{
cout<<"error input image"<<endl;
break;
}
cvCvtColor(pimg,pimgGray,CV_BGR2GRAY);
cout<<"pimg->nChannels(): "<<pimg->nChannels<<endl;
cout<<"pimgGray->nChannels():
"<<pimgGray->nChannels<<endl;
// source image
if(HI_NULL == stIveImg.pu8VirAddr[0])
{
s32Result = SAMPLE_COMM_IVE_CreateImage(&stIveImg,IVE_IMAGE_TYPE_U8C1,u16Width,u16Height);
cout<<"s32Result stIveImg HI_CreateIveImage "<<s32Result<<endl;
// if s32Result is 0 success
}
cout<<stIveImg.u32PhyAddr[0]<<" "<<"stIveImg.u32PhyAddr[0]"<<endl;
memcpy(stIveImg.pu8VirAddr[0],pimgGray->imageData,pimgGray->width * pimgGray->height);
//foreground
if(HI_NULL == stIveFg.pu8VirAddr[0])
{
s32Result = SAMPLE_COMM_IVE_CreateImage(&stIveFg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Fg HI_CreateIveImage "<<s32Result<<endl;
}
cout<<stIveFg.u32PhyAddr[0]<<" "<<"stIveFg.u32PhyAddr[0]"<<endl;
memcpy(stIveFg.pu8VirAddr[0],pimgGray->imageData, pimgGray->width * pimgGray->height);
// background
if(HI_NULL == stIveBg.pu8VirAddr[0])
{
s32Result = SAMPLE_COMM_IVE_CreateImage(&stIveBg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Bg HI_CreateIveImage "<<s32Result<<endl;
//HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
}
cout<<stIveBg.u32PhyAddr[0]<<" "<<"stIveBg.u32PhyAddr[0]"<<endl;
memcpy(stIveBg.pu8VirAddr[0],pimgGray->imageData, pimgGray->width * pimgGray->height);
//pstModel
pstDst->u32Size = stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height;
s32Result
= SAMPLE_COMM_IVE_CreateMemInfo(pstDst, pstDst->u32Size);
if (s32Result!= HI_SUCCESS)
{
printf("SAMPLE_COMM_IVE_CreateMemInfo failn");
}
memset(pstDst->pu8VirAddr, 0, pstDst->u32Size);
time_t start_t,end_t;
start_t = clock();
//cout<<"will get into GMM"<<endl;
cout<<stIveImg.u32PhyAddr[0]<<" "<<"stIveImg.u32PhyAddr[0]"<<endl;
cout<<stIveFg.u32PhyAddr[0]<<" "<<"stIveFg.u32PhyAddr[0]"<<endl;
cout<<stIveBg.u32PhyAddr[0]<<" "<<"stIveBg.u32PhyAddr[0]"<<endl;
cout<<pstDst->u32PhyAddr<<" "<<"pstDst->u32PhyAddr"<<endl;
s32Result = HI_MPI_IVE_GMM(&hIveHandle,&stIveImg,&stIveFg,&stIveBg,pstDst,&stGMMCtrl,bInstant);
if (HI_SUCCESS != s32Result)
{
printf("s32Result (%#x)n", s32Result);
}
end_t = clock();
long cost_t = (long)(end_t - start_t);
cout<<"cost_t: "<<cost_t<<endl;
if(HI_SUCCESS != s32Result)
{
goto FAILURE;
}
if(pfg == HI_NULL)
{
S = cvSize(pimg->width,pimg->height);
pfg = cvCreateImage(S,8,1);
if(HI_NULL == pfg)
{
goto FAILURE;
}
}
if(HI_NULL == pfgRGB)
{
S = cvSize(pimg->width,pimg->height);
pfgRGB = cvCreateImage(S,8,3);
if(HI_NULL == pfgRGB)
{
goto FAILURE;
}
}
if(HI_NULL == pBgGray)
{
S = cvSize(pimg->width,pimg->height);
pBgGray = cvCreateImage(S,8,1);
if(HI_NULL == pBgGray)
{
goto FAILURE;
}
}
memcpy(pfg->imageData, stIveFg.pu8VirAddr[0],pimg->width * pimg->height);
memcpy(pBgGray->imageData,stIveBg.pu8VirAddr[0],pimg->height * stIveBg.u16Stride[0]);
cvCvtColor( pfg, pfgRGB, CV_GRAY2BGR );
FrameNum++;
}
FAILURE:
IVE_MMZ_FREE(stIveImg.u32PhyAddr[0],stIveImg.pu8VirAddr[0]);
IVE_MMZ_FREE(stIveFg.u32PhyAddr[0], stIveFg.pu8VirAddr[0]);
IVE_MMZ_FREE(stIveBg.u32PhyAddr[0], stIveBg.pu8VirAddr[0]);
IVE_MMZ_FREE(pstDst->u32PhyAddr, pstDst->pu8VirAddr);
if(HI_NULL != pstDst->pu8VirAddr)
{
free(pstDst->pu8VirAddr);
}
if(HI_NULL != pstDst)
{
free(pstDst);
}
if(HI_NULL != pfgRGB)
cvReleaseImage(&pfgRGB);
if(HI_NULL != pfg)
cvReleaseImage(&pfg);
if(HI_NULL != pBgGray)
cvReleaseImage(&pBgGray);
HI_MPI_SYS_Exit();
return;
#endif
}


0xA01D8003  HI_ERR_IVE_ILLEGAL_PARAM 参数超出合法范围

看上去很好解决的样子,可是我就是不知道该怎么改

最后

以上就是眯眯眼期待为你收集整理的3516a 尝试跑通GMM 模型之二的全部内容,希望文章能够帮你解决3516a 尝试跑通GMM 模型之二所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(81)

评论列表共有 0 条评论

立即
投稿
返回
顶部