Skip to content
Snippets Groups Projects
Commit e508e128 authored by Corvin-N's avatar Corvin-N
Browse files

Change calculation of cluster center to calculate centroid

parent 78587f30
No related branches found
No related tags found
2 merge requests!68Add human tracking,!28Draft: Dev -> Main
#include "HumanTracker.h"
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include "ArmarXCore/core/exceptions/local/ExpressionException.h"
#include "armarx/navigation/human/types.h"
......@@ -331,13 +335,21 @@ namespace armarx::navigation::human
Eigen::Vector2f
HumanTracker::getClusterCenter(Cluster cluster)
{
Eigen::Vector2f center;
typedef boost::geometry::model::d2::point_xy<double> boost_point;
typedef boost::geometry::model::polygon<boost_point> boost_polygon;
std::vector<boost_point> points;
for (auto& point : cluster.convexHull)
{
center += point;
points.push_back(boost_point(point.x(), point.y()));
}
center /= cluster.points.size();
return center;
boost_polygon poly;
boost::geometry::assign_points(poly, points);
boost_point p;
boost::geometry::centroid(poly, p);
return Eigen::Vector2f{p.x(), p.y()};
}
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment