Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error in Hu-moments calculation

    cvtColor(forcalc,forcalc,CV_BGR2GRAY);
    threshold(forcalc,forcalc,1, 255,cv::THRESH_BINARY_INV);
    double hu[7];
    int eros = 10;
    Mat ele = getStructuringElement( MORPH_ELLIPSE, Size( 2*eros+ 1, 2*eros+1 ), Point( eros, eros) );
    erode(forcalc,forcalc,ele );

     Moments moments(forcalc, false); 
     HuMoments(&moments,  hu[7]);

In the above code i get the following errors

opcorect2.cpp: In function ‘int main(int, char**)’:
opcorect2.cpp:238:31: error: no matching function for call to ‘cv::Moments::Moments(cv::Mat&, bool)’
opcorect2.cpp:238:31: note: candidates are:
In file included from opcorect2.cpp:1:0:
/usr/local/include/opencv2/imgproc/imgproc.hpp:1103:5: note: cv::Moments::Moments(const CvMoments&)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1103:5: note:   candidate expects 1 argument, 2 provided
/usr/local/include/opencv2/imgproc/imgproc.hpp:1100:5: note: cv::Moments::Moments(double, double, double, double, double, double, double, double, double, double)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1100:5: note:   candidate expects 10 arguments, 2 provided
/usr/local/include/opencv2/imgproc/imgproc.hpp:1098:5: note: cv::Moments::Moments()
/usr/local/include/opencv2/imgproc/imgproc.hpp:1098:5: note:   candidate expects 0 arguments, 2 provided
/usr/local/include/opencv2/imgproc/imgproc.hpp:1094:24: note: cv::Moments::Moments(const cv::Moments&)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1094:24: note:   candidate expects 1 argument, 2 provided
opcorect2.cpp:239:27: error: no matching function for call to ‘HuMoments(cv::Moments*, double&)’
opcorect2.cpp:239:27: note: candidates are:
In file included from opcorect2.cpp:1:0:
/usr/local/include/opencv2/imgproc/imgproc.hpp:1119:17: note: void cv::HuMoments(const cv::Moments&, double*)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1119:17: note:   no known conversion for argument 1 from ‘cv::Moments*’ to ‘const cv::Moments&’
/usr/local/include/opencv2/imgproc/imgproc.hpp:1120:19: note: void cv::HuMoments(const cv::Moments&, cv::OutputArray)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1120:19: note:   no known conversion for argument 1 from ‘cv::Moments*’ to ‘const cv::Moments&’

The image(forcalc) is image description

click to hide/show revision 2
retagged

updated 2014-09-05 01:49:19 -0600

berak gravatar image

Error in Hu-moments calculation

    cvtColor(forcalc,forcalc,CV_BGR2GRAY);
    threshold(forcalc,forcalc,1, 255,cv::THRESH_BINARY_INV);
    double hu[7];
    int eros = 10;
    Mat ele = getStructuringElement( MORPH_ELLIPSE, Size( 2*eros+ 1, 2*eros+1 ), Point( eros, eros) );
    erode(forcalc,forcalc,ele );

     Moments moments(forcalc, false); 
     HuMoments(&moments,  hu[7]);

In the above code i get the following errors

opcorect2.cpp: In function ‘int main(int, char**)’:
opcorect2.cpp:238:31: error: no matching function for call to ‘cv::Moments::Moments(cv::Mat&, bool)’
opcorect2.cpp:238:31: note: candidates are:
In file included from opcorect2.cpp:1:0:
/usr/local/include/opencv2/imgproc/imgproc.hpp:1103:5: note: cv::Moments::Moments(const CvMoments&)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1103:5: note:   candidate expects 1 argument, 2 provided
/usr/local/include/opencv2/imgproc/imgproc.hpp:1100:5: note: cv::Moments::Moments(double, double, double, double, double, double, double, double, double, double)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1100:5: note:   candidate expects 10 arguments, 2 provided
/usr/local/include/opencv2/imgproc/imgproc.hpp:1098:5: note: cv::Moments::Moments()
/usr/local/include/opencv2/imgproc/imgproc.hpp:1098:5: note:   candidate expects 0 arguments, 2 provided
/usr/local/include/opencv2/imgproc/imgproc.hpp:1094:24: note: cv::Moments::Moments(const cv::Moments&)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1094:24: note:   candidate expects 1 argument, 2 provided
opcorect2.cpp:239:27: error: no matching function for call to ‘HuMoments(cv::Moments*, double&)’
opcorect2.cpp:239:27: note: candidates are:
In file included from opcorect2.cpp:1:0:
/usr/local/include/opencv2/imgproc/imgproc.hpp:1119:17: note: void cv::HuMoments(const cv::Moments&, double*)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1119:17: note:   no known conversion for argument 1 from ‘cv::Moments*’ to ‘const cv::Moments&’
/usr/local/include/opencv2/imgproc/imgproc.hpp:1120:19: note: void cv::HuMoments(const cv::Moments&, cv::OutputArray)
/usr/local/include/opencv2/imgproc/imgproc.hpp:1120:19: note:   no known conversion for argument 1 from ‘cv::Moments*’ to ‘const cv::Moments&’

The image(forcalc) is image description