编译 C++ 小波库时遇到错误
Meet error when compiling a C++ wavelet library
我正在使用this C++ Wavelet Libraries,当用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
我已经在我的 Ubuntu 15.10 上安装了从官方网站下载的 opencv-3.1.0,接着是 this instruction,我在当前文件夹中包含了所有必要的 *.h 和 *.so 文件.
➜ 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
由于我是 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 并重试,要么将您的 wavelets 库更改为支持 cv::Mat 的库。后者是更好的选择,因为 C API 早已被弃用并且不受真正支持。
我正在使用this C++ Wavelet Libraries,当用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
我已经在我的 Ubuntu 15.10 上安装了从官方网站下载的 opencv-3.1.0,接着是 this instruction,我在当前文件夹中包含了所有必要的 *.h 和 *.so 文件.
➜ 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
由于我是 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 并重试,要么将您的 wavelets 库更改为支持 cv::Mat 的库。后者是更好的选择,因为 C API 早已被弃用并且不受真正支持。