7240
- 收藏
- 点赞
- 分享
- 举报
HI_MPI_IVE_GMM 背景建模程序还是跑不通,大家能不能帮我看看是什么原因
[code]
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 "<
cout<<"u16Height "<
if(NULL == pimgGray)
{
printf("coming into pimgGray\n");
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"<
break;
}
cvCvtColor(pimg,pimgGray,CV_BGR2GRAY);
cout<<"pimg->nChannels(): "<nChannels<
cout<<"pimgGray->nChannels(): "<nChannels<
// 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 "<
}
cout<
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 "<
}
cout<
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 "<
//HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
}
cout<
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 fail\n");
}
memset(pstDst->pu8VirAddr, 0, pstDst->u32Size);
time_t start_t,end_t;
start_t = clock();
//cout<<"will get into GMM"<
cout<
cout<
cout<
cout<u32PhyAddr<<" "<<"pstDst->u32PhyAddr"<
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: "<
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
}
[/code]
[img]D:\bbb.png[/img]
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 "<
if(NULL == pimgGray)
{
printf("coming into pimgGray\n");
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"<
}
cvCvtColor(pimg,pimgGray,CV_BGR2GRAY);
cout<<"pimg->nChannels(): "<
// 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 "<
cout<
//foreground
if(HI_NULL == stIveFg.pu8VirAddr[0])
{
s32Result = SAMPLE_COMM_IVE_CreateImage(&stIveFg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Fg HI_CreateIveImage "<
}
cout<
// background
if(HI_NULL == stIveBg.pu8VirAddr[0])
{
s32Result = SAMPLE_COMM_IVE_CreateImage(&stIveBg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Bg HI_CreateIveImage "<
}
cout<
//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 fail\n");
}
memset(pstDst->pu8VirAddr, 0, pstDst->u32Size);
time_t start_t,end_t;
start_t = clock();
//cout<<"will get into GMM"<
cout<
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: "<
{
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
}
[/code]
[img]D:\bbb.png[/img]
我来回答
回答25个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
认可0
加载中···
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2016-10-20 10:15:46
-
2016-10-27 17:32:44
-
102016-07-25 19:46:59
-
2018-05-18 09:54:29
-
2021-03-03 14:53:39
-
2016-07-20 11:05:28
-
2019-01-16 15:51:16
-
2016-09-08 09:11:55
-
2018-11-21 15:49:19
-
2018-11-12 11:08:09
-
2021-04-06 16:49:38
-
2016-06-11 22:32:48
-
2019-07-11 15:24:32
-
2019-01-16 09:32:49
-
2020-05-11 18:36:33
-
2019-01-28 16:44:19
-
2019-12-14 11:11:33
-
2023-08-14 16:57:39
-
2018-05-03 17:01:08
无更多相似问答 去提问
点击登录
-- 积分
-- 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币)
取消
确认