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不变量的相似性匹配。
本文介绍了一个使用OpenCV库来计算图像Hu不变矩的示例函数voidGetHu,并解释了如何通过cvMatchShapes()方法来比较两个轮廓的相似性。此方法基于Hu不变矩进行形状匹配,结果越小表明形状越相似。
1341

被折叠的 条评论
为什么被折叠?



