C++ 编译C+时遇到错误+;小波库

C++ 编译C+时遇到错误+;小波库,c++,opencv,wavelet,C++,Opencv,Wavelet,我在使用g++进行编译时,遇到如下错误: ➜ 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 /us

我在使用g++进行编译时,遇到如下错误:

➜  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

因为我是一个C++新手,我不知道如何解决这个问题,你介意帮我吗?谢谢

问题在于OpenCV3.X.X中对IplImage的支持要少得多(如果有的话),而您想要使用的小波代码需要此功能

小波示例页面上的以下代码:

 // Creating Image in OPENCV
IplImage *cvImg; // image used for output
CvSize imgSize; // size of output image
imgSize.width = cols_n;
imgSize.height = rows_n; 
不再受支持,也将无法工作,我想这将贯穿整个框架


降级到OpenCV2.X.X并重试,或者将小波库更改为支持cv::Mat的内容。后者是更好的选择,因为C API长期以来一直不受欢迎,而且不受真正的支持。

opencv3删除了IplImage*到cv::Mat的转换。该小波代码似乎使用了过时的c-api(您可能不应该使用它)。试着找到一个替代的、维护更好的小波库
 // Creating Image in OPENCV
IplImage *cvImg; // image used for output
CvSize imgSize; // size of output image
imgSize.width = cols_n;
imgSize.height = rows_n;