/* Hausdorff Distance using OpenCV function */
#include "shape/shape_distance.hpp"
void main()
{
cv::Ptr <cv::HausdorffDistanceExtractor> hausdorff_ptr = cv::createHausdorffDistanceExtractor();
vector<Point> pt1s;
vector<Point> pt2s;
pt1s.push_back(Point(0, 0));
pt1s.push_back(Point(0, 4));
pt2s.push_back(Point(4, 6));
pt2s.push_back(Point(4, 2));
float distance = hausdorff_ptr->computeDistance(pt1s, pt2s);
cout << distance << endl;
}
注:OpenCV 3.0 版本以上才有此函数。
Only available in OpenCV 3.0 or higher version.