OPENCV 编译没问题 就是不能运行出来 错误在下面
错误提示Badargument(Eitheraloutputplanesoronlyoneoutputplaneshouldbennzero)infuctincvSpli...
错误提示
Bad argument(Either al output planes or only one output plane should be nn zero)in fuctin cvSplit
C:\User\VP\opencv\cxcore\src\cxconvert.cpp(532)
程序如下
。。。。前面是定义就不说了
//如果是第一帧,需要申请内存,并初始化
if(nFrmNum == 1)
{
pFrameT = cvCreateImage( cvGetSize(pFrame), 8, 3 );
pBkImg = cvCreateImage(cvSize(pFrame->width, pFrame->height), IPL_DEPTH_8U,1);
pFrImg = cvCreateImage(cvSize(pFrame->width, pFrame->height), IPL_DEPTH_8U,1);
pFrameTMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC3);
pFrameHMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrameSMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pBkMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrameMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
//转化成单通道图像再处理
cvCvtColor(pFrame, pFrameT, CV_BGR2HSV);
cvConvert(pFrameT,pFrameTMat);
cvSplit(pFrameTMat, pFrameHMat,pFrameSMat,0,0);
cvAddWeighted(pFrameHMat,0.5,pFrameSMat,0.5,0, pFrameMat);
cvCopy(pFrameMat, pFrMat,0);
cvCopy(pFrameMat, pBkMat,0);
}
else
{
cvCvtColor(pFrame, pFrameT, CV_BGR2HSV);
cvConvert(pFrameT,pFrameTMat);
cvSplit(pFrameTMat, pFrameHMat,pFrameSMat,NULL,NULL);
cvAddWeighted(pFrameHMat,0.5,pFrameSMat,0.5,0, pFrameMat);
//高斯滤波先,以平滑图像
cvSmooth(pFrameMat, pFrameMat, CV_GAUSSIAN, 3, 0, 0, 0);
//当前帧跟背景图相减
cvAbsDiff(pFrameMat, pBkMat, pFrMat);
//二值化前景图
cvThreshold(pFrMat, pFrImg, 60, 255.0, CV_THRESH_BINARY);
//进行形态学滤波,去掉噪音
//cvErode(pFrImg, pFrImg, 0, 1);
//cvDilate(pFrImg, pFrImg, 0, 1);
//更新背景
cvRunningAvg(pFrameMat, pBkMat, 0.003, 0);
//将背景转化为图像格式,用以显示
cvConvert(pBkMat, pBkImg);
//显示图像
cvShowImage("video", pFrame);
cvShowImage("background", pBkImg);
cvShowImage("foreground", pFrImg);
//如果有按键事件,则跳出循环
//此等待也为cvShowImage函数提供时间完成显示
//等待时间可以根据CPU速度调整
if( cvWaitKey(2) >= 0 )
break;
}
}
//销毁窗口
cvDestroyWindow("video");
cvDestroyWindow("background");
cvDestroyWindow("foreground");
//释放图像和矩阵
cvReleaseImage(&pFrImg);
cvReleaseImage(&pBkImg);
cvReleaseImage(&pFrameT);
cvReleaseMat(&pFrameMat);
cvReleaseMat(&pFrameTMat);
cvReleaseMat(&pFrameHMat);
cvReleaseMat(&pFrameSMat);
cvReleaseMat(&pFrMat);
cvReleaseMat(&pBkMat);
cvReleaseCapture(&pCapture);
return 0;
}
错误提示
Bad argument(Either all output planes or only one output plane should be non zero)in fuctin cvSplit
C:\User\VP\opencv\cxcore\src\cxconvert.cpp(532)
不好意思 打掉一个关键字母
那个 我自己解决了 告诉你们答案吧:初值我已经赋了,
SPLIT函数用法很变态,不好用,你要么就取一个通道,要么就把HSV的三个通道都取出来。。。BUG函数,我也很无语 展开
Bad argument(Either al output planes or only one output plane should be nn zero)in fuctin cvSplit
C:\User\VP\opencv\cxcore\src\cxconvert.cpp(532)
程序如下
。。。。前面是定义就不说了
//如果是第一帧,需要申请内存,并初始化
if(nFrmNum == 1)
{
pFrameT = cvCreateImage( cvGetSize(pFrame), 8, 3 );
pBkImg = cvCreateImage(cvSize(pFrame->width, pFrame->height), IPL_DEPTH_8U,1);
pFrImg = cvCreateImage(cvSize(pFrame->width, pFrame->height), IPL_DEPTH_8U,1);
pFrameTMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC3);
pFrameHMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrameSMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pBkMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrameMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
//转化成单通道图像再处理
cvCvtColor(pFrame, pFrameT, CV_BGR2HSV);
cvConvert(pFrameT,pFrameTMat);
cvSplit(pFrameTMat, pFrameHMat,pFrameSMat,0,0);
cvAddWeighted(pFrameHMat,0.5,pFrameSMat,0.5,0, pFrameMat);
cvCopy(pFrameMat, pFrMat,0);
cvCopy(pFrameMat, pBkMat,0);
}
else
{
cvCvtColor(pFrame, pFrameT, CV_BGR2HSV);
cvConvert(pFrameT,pFrameTMat);
cvSplit(pFrameTMat, pFrameHMat,pFrameSMat,NULL,NULL);
cvAddWeighted(pFrameHMat,0.5,pFrameSMat,0.5,0, pFrameMat);
//高斯滤波先,以平滑图像
cvSmooth(pFrameMat, pFrameMat, CV_GAUSSIAN, 3, 0, 0, 0);
//当前帧跟背景图相减
cvAbsDiff(pFrameMat, pBkMat, pFrMat);
//二值化前景图
cvThreshold(pFrMat, pFrImg, 60, 255.0, CV_THRESH_BINARY);
//进行形态学滤波,去掉噪音
//cvErode(pFrImg, pFrImg, 0, 1);
//cvDilate(pFrImg, pFrImg, 0, 1);
//更新背景
cvRunningAvg(pFrameMat, pBkMat, 0.003, 0);
//将背景转化为图像格式,用以显示
cvConvert(pBkMat, pBkImg);
//显示图像
cvShowImage("video", pFrame);
cvShowImage("background", pBkImg);
cvShowImage("foreground", pFrImg);
//如果有按键事件,则跳出循环
//此等待也为cvShowImage函数提供时间完成显示
//等待时间可以根据CPU速度调整
if( cvWaitKey(2) >= 0 )
break;
}
}
//销毁窗口
cvDestroyWindow("video");
cvDestroyWindow("background");
cvDestroyWindow("foreground");
//释放图像和矩阵
cvReleaseImage(&pFrImg);
cvReleaseImage(&pBkImg);
cvReleaseImage(&pFrameT);
cvReleaseMat(&pFrameMat);
cvReleaseMat(&pFrameTMat);
cvReleaseMat(&pFrameHMat);
cvReleaseMat(&pFrameSMat);
cvReleaseMat(&pFrMat);
cvReleaseMat(&pBkMat);
cvReleaseCapture(&pCapture);
return 0;
}
错误提示
Bad argument(Either all output planes or only one output plane should be non zero)in fuctin cvSplit
C:\User\VP\opencv\cxcore\src\cxconvert.cpp(532)
不好意思 打掉一个关键字母
那个 我自己解决了 告诉你们答案吧:初值我已经赋了,
SPLIT函数用法很变态,不好用,你要么就取一个通道,要么就把HSV的三个通道都取出来。。。BUG函数,我也很无语 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询