typedef boost::geometry::model::d2::point_xy<double> boostPoint;
如何在不转换为boostPoint的情况下使用opencv cv::Point使用boost::geometry::distance?
double EuclideanDistance(const cv::Point2d &pt1, const cv::Point2d &pt2)
{
boostPoint boostPt1(pt1.x, pt1.y);
boostPoint boostPt2(pt2.x, pt2.y);
double distance= boost::geometry::distance(boostPt1, boostPt2);
return distance;
}
更新:
我尝试了此代码,但它抱怨
x
error: ‘x’ has not been declared
BOOST_GEOMETRY_REGISTER_POINT_2D(cv::Point2d, double, boost::geometry::cs::cartesian, x, y)
最佳答案
确保包含doc指示的必要 header :#include <boost/geometry/geometries/register/point.hpp>
关于c++ - 如何在opencv cv::Point中使用boost::geometry::distance?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34161322/