3 #include <SimoxUtility/math/periodic/periodic_diff.h>
4 #include <SimoxUtility/math/periodic/periodic_mean.h>
8 const pcl::PointIndices&
indices)
10 std::vector<float> xs, ys, zs;
11 xs.reserve(cloud.size());
12 ys.reserve(cloud.size());
13 zs.reserve(cloud.size());
15 auto processPoint = [&](
const auto & p)
24 for (
const auto& p : cloud)
33 processPoint(cloud.at(
size_t(i)));
37 std::sort(xs.begin(), xs.end());
38 std::sort(ys.begin(), ys.end());
39 std::sort(zs.begin(), zs.end());
41 size_t index = cloud.size() / 2;
47 const pcl::PointCloud<pcl::PointXYZRGBA>& cloud, Eigen::Vector3f center)
49 return fitPlaneSVD(cloud, pcl::PointIndices(), center);
54 const pcl::PointCloud<pcl::PointXYZRGBA>& cloud,
const pcl::PointIndices&
indices,
55 Eigen::Vector3f center)
70 A = Eigen::MatrixXf(3, cloud.size());
71 for (
size_t i = 0; i < cloud.size(); ++i)
73 A.col(
int(i)) = Eigen::Vector3f(cloud[i].
data) - center;
79 A = Eigen::MatrixXf(3,
indices.indices.size());
82 A.col(i++) = Eigen::Vector3f(cloud.at(
size_t(
index)).data) - center;
87 Eigen::JacobiSVD<Eigen::MatrixXf> svd(
A, Eigen::ComputeFullU);
90 Eigen::Vector3f normal = svd.matrixU().col(2);
97 const pcl::PointCloud<pcl::PointXYZRGBA>& cloud,
Eigen::Hyperplane3f plane,
float maxDistance)
99 pcl::PointIndicesPtr inliers(
new pcl::PointIndices);
100 for (
size_t i = 0; i < cloud.size(); ++i)
102 if (plane.absDistance(Eigen::Vector3f(cloud[i].data)) <= maxDistance)
104 inliers->indices.push_back(
int(i));
112 const Eigen::Vector3f& hsvWeights)
114 return hsvDistance(Eigen::Vector3f(lhs.h, lhs.s, lhs.v), Eigen::Vector3f(rhs.h, rhs.s, rhs.v), hsvWeights);
119 const Eigen::Vector3f& hsvWeights)
121 Eigen::Array3f dists(simox::math::periodic_diff(lhs.x(), rhs.x(), 0.f, 360.f) / 180.f,
124 Eigen::Array3f weighted = hsvWeights.normalized().array() * dists.abs();
125 return weighted.sum();
132 std::vector<float> hues;
137 const auto& p = hsvCloud.at(
size_t(i));
142 float h = simox::math::periodic_mean(hues, 0.f, 360.f);
150 return plane.normal().dot(normal) >= 0