运算符/编译opencv代码时不匹配

时间:2015-03-07 23:10:09

标签: c++ opencv

我正在尝试从作者网站安装Copy-Move Forgery Detectors and Ground Truth Generator。但是当我使用make命令编译它时,一行特定的verify.cxx给了我一个我无法解决的错误。这是代码的一部分。

序言:

 #include <algorithm>
 #include <cmath>
 #include <cstring>
 #include <cstdlib>
 #include <ctime>
 #include <iostream> 
 #include <iomanip>
 #include <queue>
 #include <limits.h>
 #include <stdexcept> 
 #include <cv.h>
 #include <highgui.h>
 #include "execution.h"
 #include "verification.h"
 #include "fastsats.h"
 ...

以下是发生错误的部分:

double avg_dist = 0.0;
for (int i = 0; i < m.rows; i++)
{
    avg_dist += cv::norm(m.at<cv::Vec2f>(i,0));
}

avg_dist /=  m.rows;

// scale factor
cv::Vec2f scale_factor( sqrt(2.0),sqrt(2.0) );
//where error happens
scale_factor = scale_factor/avg_dist;

最后编译器告诉我的事情:

 [  9%] Building CXX object       

 cmfd/CMakeFiles/cmfd.dir/verification.cxx.o
 /home/anselmo/cmfd_framework/cmfd/verification.cxx: In static member    
 function ‘static void Verification::normalizeCluster(cv::Mat&, 
 cv::Mat&)’:
 /home/anselmo/cmfd_framework/cmfd/verification.cxx:317:30: error: no   
 match for ‘operator/’ in ‘scale_factor / avg_dist’
 /home/anselmo/cmfd_framework/cmfd/verification.cxx:317:30: note: 
 candidates are:
 /usr/include/opencv2/core/mat.hpp:1252:20: note: cv::MatExpr 
 cv::operator/(const cv::MatExpr&, const cv::MatExpr&)
 /usr/include/opencv2/core/mat.hpp:1252:20: note:   no known    
 conversion for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to 
 ‘const cv::MatExpr&’
 /usr/include/opencv2/core/mat.hpp:1251:20: note: cv::MatExpr 
 cv::operator/(double, const cv::MatExpr&)
 /usr/include/opencv2/core/mat.hpp:1251:20: note:   no known 
 conversion for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to    
 ‘double’
 /usr/include/opencv2/core/mat.hpp:1250:20: note: cv::MatExpr 
 cv::operator/(const cv::MatExpr&, double)
 /usr/include/opencv2/core/mat.hpp:1250:20: note:   no known 
 conversion for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to 
‘const cv::MatExpr&’
/usr/include/opencv2/core/mat.hpp:1249:20: note: cv::MatExpr 
cv::operator/(const cv::Mat&, const cv::MatExpr&)
/usr/include/opencv2/core/mat.hpp:1249:20: note:   no known conversion    
for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to ‘const    
cv::Mat&’
/usr/include/opencv2/core/mat.hpp:1248:20: note: cv::MatExpr    
cv::operator/(const cv::MatExpr&, const cv::Mat&)
/usr/include/opencv2/core/mat.hpp:1248:20: note:   no known conversion   
for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to ‘const   
cv::MatExpr&’
/usr/include/opencv2/core/mat.hpp:1247:20: note: cv::MatExpr 
cv::operator/(double, const cv::Mat&)
/usr/include/opencv2/core/mat.hpp:1247:20: note:   no known conversion  
for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to ‘double’
/usr/include/opencv2/core/mat.hpp:1246:20: note: cv::MatExpr 
cv::operator/(const cv::Mat&, double)
/usr/include/opencv2/core/mat.hpp:1246:20: note:   no known conversion 
for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to ‘const 
cv::Mat&’
/usr/include/opencv2/core/mat.hpp:1245:20: note: cv::MatExpr   
cv::operator/(const cv::Mat&, const cv::Mat&)
/usr/include/opencv2/core/mat.hpp:1245:20: note:   no known conversion   
for argument 1 from ‘cv::Vec2f {aka cv::Vec<float, 2>}’ to ‘const 
cv::Mat&’
/usr/include/opencv2/core/operations.hpp:1959:14: note: template<class 
_Tp> cv::Scalar_<_Tp> cv::operator/(const cv::Scalar_<_Tp>&, const   
cv::Scalar_<_Tp>&)
/usr/include/opencv2/core/operations.hpp:1952:14: note: template<class  
_Tp> cv::Scalar_<_Tp> cv::operator/(_Tp, const cv::Scalar_<_Tp>&)
/usr/include/opencv2/core/operations.hpp:1938:17: note: template<class 
_Tp> cv::Scalar_<double> cv::operator/(const cv::Scalar_<double>&, 
double)
/usr/include/opencv2/core/operations.hpp:1931:16: note: template<class 
_Tp> cv::Scalar_<float> cv::operator/(const cv::Scalar_<float>&,  
float)
/usr/include/opencv2/core/operations.hpp:1922:14: note: template<class 
_Tp> cv::Scalar_<_Tp> cv::operator/(const cv::Scalar_<_Tp>&, _Tp)
/usr/include/opencv2/core/operations.hpp:1373:14: note: template<class 
_Tp> cv::Complex<_Tp> cv::operator/(_Tp, const cv::Complex<_Tp>&)
/usr/include/opencv2/core/operations.hpp:1366:14: note: template<class   
_Tp> cv::Complex<_Tp> cv::operator/(const cv::Complex<_Tp>&, _Tp)
/usr/include/opencv2/core/operations.hpp:1352:14: note: template<class   
_Tp> cv::Complex<_Tp> cv::operator/(const cv::Complex<_Tp>&, const     
cv::Complex<_Tp>&)
make[2]: *** [cmfd/CMakeFiles/cmfd.dir/verification.cxx.o] Error 1
make[1]: *** [cmfd/CMakeFiles/cmfd.dir/all] Error 2
make: *** [all] Error 2

似乎原始源代码没有使用正确的opencv函数,但我将'/'替换为'cv :: operator /()'但它仍然无效。我是opencv的新手,我想知道解决这个问题。

我的opencv版本是2.3.1-7

0 个答案:

没有答案