2011-11-12 34 views
0

我試圖執行索貝爾的圖像變換但是它給出了這樣的錯誤:opencv的2.1索貝爾探測器傳遞錯誤

error: invalid initialization of reference of type 'cv::Mat&' from expression of type 'IplImage*'| cv.hpp|254|error: in passing argument 2 of 'void cv::Sobel(const cv::Mat&, cv::Mat&, int, int, int, int, double, double, int)'| ||=== Build finished: 2 errors, 0 warnings ===|

它是我的誤解是什麼手冊說明的情況下?
我使用OpenCV的2.1版文檔

IplImage* img=cvLoadImage("fight1.png"); 

      CvMat *mat = cvCreateMat(img->height,img->width,CV_32FC3); 
      //Get width and height 
      int w=img->width; 
      int h=img->height; 
      //create Images 
      IplImage* img2=cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1); 
      IplImage* img3=cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1); 
      //convert to Mat 
      cvConvert(img,mat); 

      //prepare stream reader 
      ofstream ob; 
      ob.open("object.txt"); 

      //Perform Sobel 
      cvCvtColor(img,img2,CV_RGB2GRAY); 
      Sobel(img2,img3,32 ,1,3,1.0,1.0,BORDER_DEFAULT); 
      //cvLaplace(img, img2); 

回答

0

你混合C和C++的語法。選擇其中一個,並使用正確的文檔。

在這裏,您聲明瞭C風格(IplImage)中的矩陣,並調用了cv :: Sobel(),而不是cvSobel()。

+0

謝謝,解決了它! – user1016950