Go to the documentation of this file.
3 #include <SimoxUtility/math/pose/invert.h>
4 #include <SimoxUtility/math/pose/pose.h>
39 Eigen::Vector3f normal,
42 initAlignedPointCloud(cloud, normal,
center);
49 for (
size_t i = 0; i <
numSteps; ++i)
63 const pcl::PointCloud<FitKnownRectangleRotationMaxPoints::PointT>& cloud,
64 Eigen::Vector3f normal,
72 FitKnownRectangleRotationMaxPoints::initAlignedPointCloud(
73 const pcl::PointCloud<FitKnownRectangleRotationMaxPoints::PointT>& cloud,
74 Eigen::Vector3f normal,
77 using namespace Eigen;
83 simox::math::pose(Quaternionf::FromTwoVectors(normal, Vector3f::UnitZ())) *
transform;
90 FitKnownRectangleRotationMaxPoints::getAlignedPointCloud() const
97 FitKnownRectangleRotationMaxPoints::setRotated(
float angle)
const
100 Eigen::AngleAxisf(-
angle, Eigen::Vector3f::UnitZ()).toRotationMatrix();
101 pcl::transformPointCloud(*
aligned, *
rotated, simox::math::pose(rot));
105 FitKnownRectangleRotationMaxPoints::isInlier(
const PointT& p)
const
116 long count = std::count_if(
118 return size_t(count);
127 pcl::PointIndicesPtr
indices(
new pcl::PointIndices);
128 for (
size_t i = 0; i <
rotated->size(); ++i)
130 if (isInlier(
rotated->points[i]))
132 indices->indices.push_back(
int(i));
142 Eigen::AngleAxisf localRotation(
angle, Eigen::Vector3f::UnitZ());
143 return simox::math::inverted_pose(
alignedTransform) * simox::math::pose(localRotation);
void setRectangleSize(const Eigen::Vector2f &value)
Set the rectangle size.
Eigen::Matrix4f alignedTransform
Transformation applied to get aligned.
Eigen::Vector2f getRectangleSize() const
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr aligned
Transformed so center is at 0 and z = normal.
Eigen::Matrix4f fit()
Count the number of inliers per rotation step, and return the global pose corresponding to the rotati...
size_t numSteps
The number of steps (i.e. resolution of solution space).
Eigen::Vector2f rectangleSize
The rectangle size.
MatrixXX< 4, 4, float > Matrix4f
Eigen::Matrix4f angleToPose(float angle)
Get the global pose corresponding to a local rotation angle.
std::vector< size_t > getInlierCounts() const
Get the inlier counts per step.
size_t countInliersOfAngle(float angle) const
Count the inliers for a given local rotation angle.
std::shared_ptr< Value > value()
std::vector< T > abs(const std::vector< T > &v)
std::vector< size_t > inlierCounts
The inlier counts per step.
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
size_t getNumSteps() const
void setInputCloud(const pcl::PointCloud< PointT > &cloud, Eigen::Vector3f normal, Eigen::Vector3f center)
Set the input cloud and the rectangle's position and normal.
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT >>
Convenience function (with less typing) to transform a container of type InputT into the same contain...
void setNumSteps(const size_t &value)
Set the number of solution steps, i.e. the resolution of the solution space.
float stepToAngle(Int step) const
Get the local rotation angle of a solution step.
FitKnownRectangleRotationMaxPoints()
float bestAngle
The best angle.
state::Type center(state::Type previous)
double angle(const Point &a, const Point &b, const Point &c)
double distance(const Point &a, const Point &b)
MatrixXX< 3, 3, float > Matrix3f
float getBestAngle() const
Get the best local rotation angle.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr rotated
Buffer for point clouds rotated for inlier counting.
pcl::PointIndicesPtr findInliersOfAngle(float angle) const
Get the inliers for a given local rotation angle.