void GetHu(string image_path)
{
IplImage *src_image = cvLoadImage(image_path.c_str(),0);
CvMoments moments;
CvHuMoments hu_moments;
cvMoments(src_image, &moments,0);
cvGetHuMoments(&moments, &hu_moments);
for(int i = 1; i < 8; ++i)
{
cout<<((double*)&hu_moments)[i]<<"\t";
}
}
另外,opencv中的cvMatchShapes()方法可以直接实现两个轮廓的相似性计算,结果越小越相似。这个函数也是基于Hu不变量的相似性匹配。