2916
- 收藏
- 点赞
- 分享
- 举报
HI_MPI_IVE_GMM 背景建模程序跑不通,大家能不能帮我看看是什么原因?
[code]#include "GMM.h"
#include "mpi_sys.h"
#include "hi_comm_sys.h"
#include "sample_assist.h"
#include "sample_file.h"
#include "sample_define.h"
#include "mpi_ive.h"
#include
#include
#include
#include "cv.h"
#include
#include
#include
#include "mpi_sys.h"
#include"time.h"
//add by ggj for using
#include
#include
using namespace std;
using namespace cv;
HI_VOID GMMSampleSingle()
{
#if 1
IVE_SRC_IMAGE_S stIveImg; // image
IVE_DST_IMAGE_S stIveFg; //forth ground
IVE_DST_IMAGE_S stIveBg; // back ground
HI_BOOL bInstant = HI_TRUE; // must be true
IVE_GMM_CTRL_S stGMMCtrl;
IVE_HANDLE hIveHandle;
IVE_MEM_INFO_S *pstDst;
IplImage *pimgGray=NULL;
IplImage *pfg=NULL;
IplImage *pfgRGB=NULL;
IplImage *pBgGray=NULL;
HI_S32 s32Result;
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.u0q16BgRatio = 45875;//0.7
stGMMCtrl.u0q16InitWeight = 3277;
stGMMCtrl.u22q10NoiseVar = 225 * 1024;
stGMMCtrl.u22q10MaxVar = 2000 * 1024;
stGMMCtrl.u22q10MinVar = 200 * 1024;
stGMMCtrl.u8q8VarThr = (HI_U16)(256 * 6.25) ; //2.5
stGMMCtrl.u8ModelNum = 3; // should be three model
//stGMMCtrl.u8ShadowVarThr = 16;
// 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));
HI_MPI_SYS_Init();
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<
if(HI_NULL == stIveImg.pu8VirAddr[0])
{
s32Result = HI_CreateIveImage(&stIveImg,IVE_IMAGE_TYPE_U8C1,u16Width,u16Height);
cout<<"s32Result stIveImg HI_CreateIveImage "<
HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
}
cout<<"stIveImg.u16Height :"<
s32Result =HI_MPI_SYS_MmzAlloc(&stIveImg.u32PhyAddr[0],(HI_VOID**)&stIveImg.pu8VirAddr[0],NULL,HI_NULL,stIveImg.u16Height*stIveImg.u16Stride[0]);
memcpy(stIveImg.pu8VirAddr[0],pimgGray->imageData,pimgGray->width * pimgGray->height);
cout<<"s32Result stIveImg HI_MPI_SYS_MmzAlloc "<
//foreground
if(HI_NULL == stIveFg.pu8VirAddr[0])
{
printf("coming into foreground\n");
s32Result = HI_CreateIveImage(&stIveFg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Fg HI_CreateIveImage "<
HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
}
s32Result =HI_MPI_SYS_MmzAlloc(&stIveFg.u32PhyAddr[0],(HI_VOID**)&stIveFg.pu8VirAddr[0],NULL,HI_NULL,stIveFg.u16Height*stIveFg.u16Stride[0]);
cout<<"s32Result stIveImg HI_MPI_SYS_MmzAlloc "<
memcpy(stIveFg.pu8VirAddr[0],pimgGray->imageData, pimgGray->width * pimgGray->height);
// background
if(HI_NULL == stIveBg.pu8VirAddr[0])
{
printf("coming into background\n");
s32Result = HI_CreateIveImage(&stIveBg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Bg HI_CreateIveImage "<
HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
}
//add by ggj 20160909
s32Result =HI_MPI_SYS_MmzAlloc(&stIveBg.u32PhyAddr[0],(HI_VOID**)&stIveBg.pu8VirAddr[0],NULL,HI_NULL,stIveBg.u16Height*stIveBg.u16Stride[0]);
cout<<"s32Result stIveBg HI_MPI_SYS_MmzAlloc "<
memcpy(stIveBg.pu8VirAddr[0],pimgGray->imageData, pimgGray->width * pimgGray->height);
if(1 == FrameNum)
{
pstDst->pu8VirAddr = (HI_U8 *)malloc(stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height);
HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
memset(pstDst->pu8VirAddr,0,stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height);
pstDst->u32PhyAddr = (HI_U32)pstDst->pu8VirAddr;
pstDst->u32Size = stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height;
}
if(FrameNum >= 500)
{
stGMMCtrl.u0q16LearnRate = 131; //0.02
}
else
{
//cout<<"FrameNum "<
stGMMCtrl.u0q16LearnRate = 65535/FrameNum;
}
time_t start_t,end_t;
start_t = clock();
//cout<<"will get into GMM"<
cout<
cout<
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: "<
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:
HI_DestroyIveImage(&stIveImg);
HI_DestroyIveImage(&stIveFg);
HI_DestroyIveImage(&stIveBg);
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]
打印输出结果:
u16Width 320
u16Height 240
coming into pimgGray
pimg->nChannels<>: 3
pimgGray->nChannels<>: 1
s32Result stIveImg HI_CreateIveImage 0
stIveImg.u16Height:240
stIveImg.u16Stride[0]:320
s32Result stIveImg HI_MPI_SYS_MmzAlloc 0
coming into foreground
s32Result Fg HI_CreateIveImage 0
s32Result Fg HI_MPI_SYS_MmzAlloc 0
coming into background
s32Result Bg HI_CreateIveImage 0
s32Result Bg HI_MPI_SYS_MmzAlloc 0
2401460224 stIveImg.u32PhyAddr[0]
2401538048 stIveFg.u32PhyAddr[0]
2401615872 stIveBg.u32PhyAddr[0]
pstImage-> u32PhyAddr[0] can not be zero
check image pstSrc failed
check GMM parameters failed.
#include "mpi_sys.h"
#include "hi_comm_sys.h"
#include "sample_assist.h"
#include "sample_file.h"
#include "sample_define.h"
#include "mpi_ive.h"
#include
#include
#include
#include "cv.h"
#include
#include
#include
#include "mpi_sys.h"
#include"time.h"
//add by ggj for using
#include
#include
using namespace std;
using namespace cv;
HI_VOID GMMSampleSingle()
{
#if 1
IVE_SRC_IMAGE_S stIveImg; // image
IVE_DST_IMAGE_S stIveFg; //forth ground
IVE_DST_IMAGE_S stIveBg; // back ground
HI_BOOL bInstant = HI_TRUE; // must be true
IVE_GMM_CTRL_S stGMMCtrl;
IVE_HANDLE hIveHandle;
IVE_MEM_INFO_S *pstDst;
IplImage *pimgGray=NULL;
IplImage *pfg=NULL;
IplImage *pfgRGB=NULL;
IplImage *pBgGray=NULL;
HI_S32 s32Result;
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.u0q16BgRatio = 45875;//0.7
stGMMCtrl.u0q16InitWeight = 3277;
stGMMCtrl.u22q10NoiseVar = 225 * 1024;
stGMMCtrl.u22q10MaxVar = 2000 * 1024;
stGMMCtrl.u22q10MinVar = 200 * 1024;
stGMMCtrl.u8q8VarThr = (HI_U16)(256 * 6.25) ; //2.5
stGMMCtrl.u8ModelNum = 3; // should be three model
//stGMMCtrl.u8ShadowVarThr = 16;
// 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));
HI_MPI_SYS_Init();
while(getline(infile, buff))
{
pimg=cvLoadImage(buff.c_str());
if (!pimg)
{
cout<<"error input image"<
}
cvCvtColor(pimg,pimgGray,CV_BGR2GRAY);
cout<<"pimg->nChannels(): "<
{
s32Result = HI_CreateIveImage(&stIveImg,IVE_IMAGE_TYPE_U8C1,u16Width,u16Height);
cout<<"s32Result stIveImg HI_CreateIveImage "<
}
cout<<"stIveImg.u16Height :"<
memcpy(stIveImg.pu8VirAddr[0],pimgGray->imageData,pimgGray->width * pimgGray->height);
cout<<"s32Result stIveImg HI_MPI_SYS_MmzAlloc "<
//foreground
if(HI_NULL == stIveFg.pu8VirAddr[0])
{
printf("coming into foreground\n");
s32Result = HI_CreateIveImage(&stIveFg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Fg HI_CreateIveImage "<
}
s32Result =HI_MPI_SYS_MmzAlloc(&stIveFg.u32PhyAddr[0],(HI_VOID**)&stIveFg.pu8VirAddr[0],NULL,HI_NULL,stIveFg.u16Height*stIveFg.u16Stride[0]);
cout<<"s32Result stIveImg HI_MPI_SYS_MmzAlloc "<
// background
if(HI_NULL == stIveBg.pu8VirAddr[0])
{
printf("coming into background\n");
s32Result = HI_CreateIveImage(&stIveBg,IVE_IMAGE_TYPE_U8C1, u16Width,u16Height);
cout<<"s32Result Bg HI_CreateIveImage "<
}
//add by ggj 20160909
s32Result =HI_MPI_SYS_MmzAlloc(&stIveBg.u32PhyAddr[0],(HI_VOID**)&stIveBg.pu8VirAddr[0],NULL,HI_NULL,stIveBg.u16Height*stIveBg.u16Stride[0]);
cout<<"s32Result stIveBg HI_MPI_SYS_MmzAlloc "<
if(1 == FrameNum)
{
pstDst->pu8VirAddr = (HI_U8 *)malloc(stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height);
HI_CHECK_ET_GOTO(s32Result,HI_FAILURE,FAILURE);
memset(pstDst->pu8VirAddr,0,stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height);
pstDst->u32PhyAddr = (HI_U32)pstDst->pu8VirAddr;
pstDst->u32Size = stGMMCtrl.u8ModelNum * 7 * pimg->width * pimg->height;
}
if(FrameNum >= 500)
{
stGMMCtrl.u0q16LearnRate = 131; //0.02
}
else
{
//cout<<"FrameNum "<
}
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:
HI_DestroyIveImage(&stIveImg);
HI_DestroyIveImage(&stIveFg);
HI_DestroyIveImage(&stIveBg);
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]
打印输出结果:
u16Width 320
u16Height 240
coming into pimgGray
pimg->nChannels<>: 3
pimgGray->nChannels<>: 1
s32Result stIveImg HI_CreateIveImage 0
stIveImg.u16Height:240
stIveImg.u16Stride[0]:320
s32Result stIveImg HI_MPI_SYS_MmzAlloc 0
coming into foreground
s32Result Fg HI_CreateIveImage 0
s32Result Fg HI_MPI_SYS_MmzAlloc 0
coming into background
s32Result Bg HI_CreateIveImage 0
s32Result Bg HI_MPI_SYS_MmzAlloc 0
2401460224 stIveImg.u32PhyAddr[0]
2401538048 stIveFg.u32PhyAddr[0]
2401615872 stIveBg.u32PhyAddr[0]
pstImage-> u32PhyAddr[0] can not be zero
check image pstSrc failed
check GMM parameters failed.
我来回答
回答1个
时间排序
认可量排序
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2016-10-21 14:43:43
-
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
-
2018-11-21 15:49:19
-
2016-09-08 09:11:55
-
2018-11-12 11:08:09
-
2021-04-06 16:49:38
-
2016-06-11 22:32:48
-
2019-01-16 09:32:49
-
2019-01-28 16:44:19
-
2019-07-11 15:24:32
-
2023-08-14 16:57:39
-
2018-05-03 17:01:08
-
2020-05-11 18:36:33
-
2016-08-18 16:00:38
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
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板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
-
5有偿求HI3516DV500 + OV5647驱动
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认