Search code examples
c++opencvwavelet

Meet error when compiling a C++ wavelet library


I am using this C++ Wavelet Libraries, when compiling by g++, I meet some error like this:

➜  examples  g++ imagedemo1.cpp
imagedemo1.cpp: In function ‘int main()’:
imagedemo1.cpp:75:16: error: no matching function for call to ‘cv::Mat::Mat(IplImage*&)’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:935:14: note: candidate: cv::Mat::Mat(const cv::cuda::GpuMat&)
     explicit Mat(const cuda::GpuMat& m);
              ^
/usr/local/include/opencv2/core/mat.hpp:935:14: note:   no known conversion for argument 1 from ‘IplImage* {aka _IplImage*}’ to ‘const cv::cuda::GpuMat&’
/usr/local/include/opencv2/core/mat.hpp:932:37: note: candidate: template<class _Tp> cv::Mat::Mat(const cv::MatCommaInitializer_<_Tp>&)
     template<typename _Tp> explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:932:37: note:   template argument deduction/substitution failed:
imagedemo1.cpp:75:16: note:   mismatched types ‘const cv::MatCommaInitializer_<_Tp>’ and ‘IplImage* {aka _IplImage*}’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:928:37: note: candidate: template<class _Tp> cv::Mat::Mat(const cv::Point3_<_Tp>&, bool)
     template<typename _Tp> explicit Mat(const Point3_<_Tp>& pt, bool copyData=true);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:928:37: note:   template argument deduction/substitution failed:
imagedemo1.cpp:75:16: note:   mismatched types ‘const cv::Point3_<_Tp>’ and ‘IplImage* {aka _IplImage*}’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:924:37: note: candidate: template<class _Tp> cv::Mat::Mat(const cv::Point_<_Tp>&, bool)
     template<typename _Tp> explicit Mat(const Point_<_Tp>& pt, bool copyData=true);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:924:37: note:   template argument deduction/substitution failed:
imagedemo1.cpp:75:16: note:   mismatched types ‘const cv::Point_<_Tp>’ and ‘IplImage* {aka _IplImage*}’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:920:51: note: candidate: template<class _Tp, int m, int n> cv::Mat::Mat(const cv::Matx<_Tp, m, n>&, bool)
     template<typename _Tp, int m, int n> explicit Mat(const Matx<_Tp, m, n>& mtx, bool copyDat
                                                   ^
/usr/local/include/opencv2/core/mat.hpp:920:51: note:   template argument deduction/substitution failed:
imagedemo1.cpp:75:16: note:   mismatched types ‘const cv::Matx<_Tp, m, n>’ and ‘IplImage* {aka _IplImage*}’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:916:44: note: candidate: template<class _Tp, int n> cv::Mat::Mat(const cv::Vec<_Tp, m>&, bool)
     template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
                                            ^
/usr/local/include/opencv2/core/mat.hpp:916:44: note:   template argument deduction/substitution failed:
imagedemo1.cpp:75:16: note:   mismatched types ‘const cv::Vec<_Tp, m>’ and ‘IplImage* {aka _IplImage*}’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:912:37: note: candidate: template<class _Tp> cv::Mat::Mat(const std::vector<_Tp>&, bool)
     template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
                                     ^
/usr/local/include/opencv2/core/mat.hpp:912:37: note:   template argument deduction/substitution failed:
imagedemo1.cpp:75:16: note:   mismatched types ‘const std::vector<_Tp>’ and ‘IplImage* {aka _IplImage*}’
  Mat matimg(img);
                ^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.hpp:894:5: note: candidate: cv::Mat::Mat(const cv::Mat&, const cv::Range*)
     Mat(const Mat& m, const Range* ranges);
     ^
/usr/local/include/opencv2/core/mat.hpp:894:5: note:   candidate expects 2 arguments, 1 provided
/usr/local/include/opencv2/core/mat.hpp:884:5: note: candidate: cv::Mat::Mat(const cv::Mat&, const Rect&)
     Mat(const Mat& m, const Rect& roi);
     ^
/usr/local/include/opencv2/core/mat.hpp:884:5: note:   candidate expects 2 arguments, 1 provided
/usr/local/include/opencv2/core/mat.hpp:874:5: note: candidate: cv::Mat::Mat(const cv::Mat&, const cv::Range&, const cv::Range&)
     Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all());
     ^
/usr/local/include/opencv2/core/mat.hpp:874:5: note:   candidate expects 3 arguments, 1 provided
/usr/local/include/opencv2/core/mat.hpp:862:5: note: candidate: cv::Mat::Mat(int, const int*, int, void*, const size_t*)
     Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0);
     ^
/usr/local/include/opencv2/core/mat.hpp:862:5: note:   candidate expects 5 arguments, 1 provided
In file included from /usr/local/include/opencv2/core/mat.hpp:3429:0,
                 from /usr/local/include/opencv2/core.hpp:59,
                 from /usr/local/include/opencv2/core/types_c.h:101,
                 from /usr/local/include/opencv2/core/core_c.h:48,
                 from cv.h:63,
                 from imagedemo1.cpp:17:
/usr/local/include/opencv2/core/mat.inl.hpp:438:1: note: candidate: cv::Mat::Mat(cv::Size, int, void*, size_t)
 Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:438:1: note:   candidate expects 4 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:405:1: note: candidate: cv::Mat::Mat(int, int, int, void*, size_t)
 Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:405:1: note:   candidate expects 5 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:386:1: note: candidate: cv::Mat::Mat(const cv::Mat&)
 Mat::Mat(const Mat& m)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:386:1: note:   no known conversion for argument 1 from ‘IplImage* {aka _IplImage*}’ to ‘const cv::Mat&’
/usr/local/include/opencv2/core/mat.inl.hpp:377:1: note: candidate: cv::Mat::Mat(int, const int*, int, const Scalar&)
 Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:377:1: note:   candidate expects 4 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:369:1: note: candidate: cv::Mat::Mat(int, const int*, int)
 Mat::Mat(int _dims, const int* _sz, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:369:1: note:   candidate expects 3 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:360:1: note: candidate: cv::Mat::Mat(cv::Size, int, const Scalar&)
 Mat::Mat(Size _sz, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:360:1: note:   candidate expects 3 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:343:1: note: candidate: cv::Mat::Mat(int, int, int, const Scalar&)
 Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:343:1: note:   candidate expects 4 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:352:1: note: candidate: cv::Mat::Mat(cv::Size, int)
 Mat::Mat(Size _sz, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:352:1: note:   candidate expects 2 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:335:1: note: candidate: cv::Mat::Mat(int, int, int)
 Mat::Mat(int _rows, int _cols, int _type)
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:335:1: note:   candidate expects 3 arguments, 1 provided
/usr/local/include/opencv2/core/mat.inl.hpp:329:1: note: candidate: cv::Mat::Mat()
 Mat::Mat()
 ^
/usr/local/include/opencv2/core/mat.inl.hpp:329:1: note:   candidate expects 0 arguments, 1 provided

I have installed opencv-3.1.0 downloaded from official website on my Ubuntu 15.10, followed by this instruction, and I include all necessary *.h and *.so files in current folder.

➜  examples  pwd
/home/neo/Desktop/wavelib/examples
➜  examples  ls
cv.h            imagedemo2.cpp       README         swtdemo.cpp    wavelet2s.h
cxcore.h        lena512.bmp          signal.txt     wavedemo1.cpp
highgui.h       libwavelet2d.so.1.0  snow.jpg       wavedemo2.cpp
imagedemo1.cpp  libwavelet2s.a       swt2Ddemo.cpp  wavelet2d.h

Since I am a newbie in C++, I don't know how to fix this problem, would you mind helping me? Thanks!


Solution

  • The problem is that IplImage is much less supported (if at all) in OpenCV3.X.X and the wavelet code that you are wanting to use needs this functionality.

    This code on the wavelets example page:

     // Creating Image in OPENCV
    IplImage *cvImg; // image used for output
    CvSize imgSize; // size of output image
    imgSize.width = cols_n;
    imgSize.height = rows_n; 
    

    Is no longer supported and won't work, I imagine this is throughout the framework.

    Either downgrade to OpenCV2.X.X and try again or change your wavelets lib to something that supports cv::Mat. The latter is the better option as the C API is long deprecated and not really supported.