我不明白爲什麼我的程序不能在我的電腦上運行,而在學校電腦上工作正常!也許這是配置上的問題。我與Ubuntu 9.10的工作和OpenCV 2.2OpenCV錯誤:輸入參數的格式不匹配
這裏的最後一個版本的代碼:
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
int main (int argc, char *argv[])
{
double a[9]={1,0,-1,2,0,-2,1,0,-1};
double b[9]={1,2,1,0,0,0,-1,-2,-1};
IplImage* img=cvLoadImage(argv[1], 0);
if(!img){
printf("could not load image file: %s\n",argv[1]);
exit(0);
}
IplImage* dst=cvCreateImage(cvGetSize(img),IPL_DEPTH_64F,1);
IplImage* dst1=cvCreateImage(cvGetSize(img),IPL_DEPTH_64F,1);
IplImage* dst2=cvCreateImage(cvGetSize(img),IPL_DEPTH_64F,1);
IplImage* dst_f=cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1);
CvMat k1 = cvMat(3,3,CV_64FC1,a);
CvMat k2 = cvMat(3,3,CV_64FC1,b);
cvFilter2D(img ,dst1, &k1,cvPoint(-1,-1));
cvFilter2D(img ,dst2, &k2,cvPoint(-1,-1));
cvPow(dst1, dst1, 2.0);
cvPow(dst2, dst2, 2.0);
cvAdd(dst1, dst2, dst, NULL);
cvPow(dst, dst, 0.5);
cvConvertImage(dst,dst_f,CV_CVTIMG_FLIP);
cvThreshold(dst_f,dst_f,127,255,CV_THRESH_BINARY);
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
cvShowImage("mainWin",img);
cvNamedWindow("Sobel", CV_WINDOW_AUTOSIZE);
cvShowImage("Sobel",dst_f);
cvWaitKey(0);
cvReleaseImage(&img);
cvReleaseImage(&dst_f);
return 0;
}
這是運行
OpenCV ERROR: Formats of input arguments do not match() in function cvFilter2D, cvfilter.cpp(2617) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application...
當終端返回請幫我理解這個問題。
看起來不錯,我 - 我可以建議的唯一的事情就是儘量使用32位浮動,而不是64位,也就是改變你的雙打花車,IPL_DEPTH_64F到IPL_DEPTH_32F和CV_64FC1到CV_32FC1等 – 2011-02-10 15:59:25