gpt4 book ai didi

c++ - 如何将 boost::geometry::distance 与 opencv cv::Point 一起使用?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:15:32 25 4
gpt4 key购买 nike

typedef boost::geometry::model::d2::point_xy<double> boostPoint;

如何在不转换为 boostPoint 的情况下将 boost::geometry::distance 与 opencv cv::Point 一起使用?

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)

最佳答案

确保包含必要的 header ,如 doc 所示:

#include <boost/geometry/geometries/register/point.hpp>

关于c++ - 如何将 boost::geometry::distance 与 opencv cv::Point 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34161322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com