Go to the documentation of this file.
3 #include <SimoxUtility/math/pose/invert.h>
4 #include <SimoxUtility/math/pose/pose.h>
36 const pcl::PointCloud<PointT>& cloud, Eigen::Vector3f normal, Eigen::Vector3f center)
38 initAlignedPointCloud(cloud, normal, center);
45 for (
size_t i = 0; i <
numSteps; ++i)
59 const pcl::PointCloud<FitKnownRectangleRotationMaxPoints::PointT>& cloud,
60 Eigen::Vector3f normal, Eigen::Vector3f center)
67 void FitKnownRectangleRotationMaxPoints::initAlignedPointCloud(
68 const pcl::PointCloud<FitKnownRectangleRotationMaxPoints::PointT>& cloud,
69 Eigen::Vector3f normal, Eigen::Vector3f center)
71 using namespace Eigen;
76 transform = simox::math::pose(Quaternionf::FromTwoVectors(normal, Vector3f::UnitZ()))
83 auto FitKnownRectangleRotationMaxPoints::getAlignedPointCloud() const ->
pcl::
PointCloud<
PointT>::ConstPtr
89 void FitKnownRectangleRotationMaxPoints::setRotated(
float angle)
const
91 const Eigen::Matrix3f rot = Eigen::AngleAxisf(-
angle, Eigen::Vector3f::UnitZ()).toRotationMatrix();
92 pcl::transformPointCloud(*
aligned, *
rotated, simox::math::pose(rot));
96 bool FitKnownRectangleRotationMaxPoints::isInlier(
const PointT& p)
const
112 return size_t(count);
120 pcl::PointIndicesPtr
indices(
new pcl::PointIndices);
121 for (
size_t i = 0; i <
rotated->size(); ++i)
123 if (isInlier(
rotated->points[i]))
125 indices->indices.push_back(
int(i));
135 Eigen::AngleAxisf localRotation(
angle, Eigen::Vector3f::UnitZ());
136 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.
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.
void setNumSteps(const size_t &value)
Set the number of solution steps, i.e. the resolution of the solution space.
MatrixXX< 3, 3, float > Matrix3f
MatrixXX< 4, 4, float > Matrix4f
float stepToAngle(Int step) const
Get the local rotation angle of a solution step.
FitKnownRectangleRotationMaxPoints()
float bestAngle
The best angle.
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...
double angle(const Point &a, const Point &b, const Point &c)
double distance(const Point &a, const Point &b)
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.