#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;
int main()
{
IplImage* img1 = cvLoadImage("1.jpg",0);
IplImage* img2 = cvLoadImage("2.jpg",0);
CvMoments moments;
CvHuMoments hu_moments;
cvMoments(img1, &moments, 0);
cvGetHuMoments(&moments, &hu_moments);
cout<<hu_moments.hu1 <<endl
<<hu_moments.hu2 <<endl
<<hu_moments.hu3 <<endl
<<hu_moments.hu4 <<endl
<<hu_moments.hu5 <<endl
<<hu_moments.hu6 <<endl
<<hu_moments.hu7 <<endl;
cvMoments(img2, &moments, 0);
cvGetHuMoments(&moments, &hu_moments);
cout<<hu_moments.hu1 <<endl
<<hu_moments.hu2 <<endl
<<hu_moments.hu3 <<endl
<<hu_moments.hu4 <<endl
<<hu_moments.hu5 <<endl
<<hu_moments.hu6 <<endl
<<hu_moments.hu7 <<endl;
cvReleaseImage(&img1);
cvReleaseImage(&img2);
return 0;
}
#include <highgui.h>
#include <iostream>
using namespace std;
int main()
{
IplImage* img1 = cvLoadImage("1.jpg",0);
IplImage* img2 = cvLoadImage("2.jpg",0);
CvMoments moments;
CvHuMoments hu_moments;
cvMoments(img1, &moments, 0);
cvGetHuMoments(&moments, &hu_moments);
cout<<hu_moments.hu1 <<endl
<<hu_moments.hu2 <<endl
<<hu_moments.hu3 <<endl
<<hu_moments.hu4 <<endl
<<hu_moments.hu5 <<endl
<<hu_moments.hu6 <<endl
<<hu_moments.hu7 <<endl;
cvMoments(img2, &moments, 0);
cvGetHuMoments(&moments, &hu_moments);
cout<<hu_moments.hu1 <<endl
<<hu_moments.hu2 <<endl
<<hu_moments.hu3 <<endl
<<hu_moments.hu4 <<endl
<<hu_moments.hu5 <<endl
<<hu_moments.hu6 <<endl
<<hu_moments.hu7 <<endl;
cvReleaseImage(&img1);
cvReleaseImage(&img2);
return 0;
}