PCL中Sample_consensus分割支持的几何模型
Posted cv_gordon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PCL中Sample_consensus分割支持的几何模型相关的知识,希望对你有一定的参考价值。
随机采样一致分割法,从点云中分割出线、面等几何元素
#include <pcl/sample_consensus/method_types.h> #include <pcl/sample_consensus/model_types.h> #include <pcl/segmentation/sac_segmentation.h> // Create the segmentation object pcl::SACSegmentation<pcl::PointXYZ> seg; // Optional seg.setOptimizeCoefficients (true); // Mandatory seg.setModelType (pcl::SACMODEL_PLANE); //model: plane seg.setMethodType (pcl::SAC_RANSAC);
(1) SACMODEL_PLANE(三维平面)
- used to determine plane models. The four coefficients of the plane are itsHessian Normal form: [normal_x normal_y normal_z d]
- a : the X coordinate of the plane‘s normal (normalized)
- b : the Y coordinate of the plane‘s normal (normalized)
- c : the Z coordinate of the plane‘s normal (normalized)
- d : the fourth Hessian component of the plane‘s equation
- used to determine line models. The six coefficients of the line are given by a point on the line and the direction of the line as: [point_on_line.x point_on_line.y point_on_line.z line_direction.x line_direction.y line_direction.z]
- point_on_line.x : the X coordinate of a point on the line
- point_on_line.y : the Y coordinate of a point on the line
- point_on_line.z : the Z coordinate of a point on the line
- line_direction.x : the X coordinate of a line‘s direction
- line_direction.y : the Y coordinate of a line‘s direction
- line_direction.z : the Z coordinate of a line‘s direction
- used to determine 2D circles in a plane. The circle‘s three coefficients are given by its center and radius as: [center.x center.y radius]
- center.x : the X coordinate of the circle‘s center
- center.y : the Y coordinate of the circle‘s center
- radius : the circle‘s radius
- not implemented yet
(5) SACMODEL_SPHERE(球)
- used to determine sphere models. The four coefficients of the sphere are given by its 3D center and radius as: [center.x center.y center.z radius]
- center.x : the X coordinate of the sphere‘s center
- center.y : the Y coordinate of the sphere‘s center
- center.z : the Z coordinate of the sphere‘s center
- radius : the sphere‘s radius
- used to determine cylinder models. The seven coefficients of the cylinder are given by a point on its axis, the axis direction, and a radius, as: [point_on_axis.x point_on_axis.y point_on_axis.z axis_direction.x axis_direction.y axis_direction.z radius]
-
- point_on_axis.x : the X coordinate of a point located on the cylinder axis
- point_on_axis.y : the Y coordinate of a point located on the cylinder axis
- point_on_axis.z : the Z coordinate of a point located on the cylinder axis
- axis_direction.x : the X coordinate of the cylinder‘s axis direction
- axis_direction.y : the Y coordinate of the cylinder‘s axis direction
- axis_direction.z : the Z coordinate of the cylinder‘s axis direction
- radius : the cylinder‘s radius
- not implemented yet
- not implemented yet
- a model for determining a line parallel with a given axis, within a maximum specified angular deviation. The line coefficients are similar toSACMODEL_LINE.
- SampleConsensusModelParallelLine defines a model for 3D line segmentation using additional angular constraints.
The model coefficients are defined as:
-
- point_on_line.x : the X coordinate of a point on the line
- point_on_line.y : the Y coordinate of a point on the line
- point_on_line.z : the Z coordinate of a point on the line
- line_direction.x : the X coordinate of a line‘s direction
- line_direction.y : the Y coordinate of a line‘s direction
- line_direction.z : the Z coordinate of a line‘s direction
- a model for determining a plane perpendicular to an user-specified axis, within a maximum specified angular deviation. The plane coefficients are similar to SACMODEL_PLANE.
- SampleConsensusModelPerpendicularPlane defines a model for 3D plane segmentation using additional angular constraints.The plane must be perpendicular to an user-specified axis (setAxis), up to an user-specified angle threshold (setEpsAngle).
The model coefficients are defined as:
-
- a : the X coordinate of the plane‘s normal (normalized)
- b : the Y coordinate of the plane‘s normal (normalized)
- c : the Z coordinate of the plane‘s normal (normalized)
- d : the fourth Hessian component of the plane‘s equation
Code example for a plane model, perpendicular (within a 15 degrees tolerance) with the Z axis:
SampleConsensusModelPerpendicularPlane<pcl::PointXYZ> model (cloud); model.setAxis (Eigen::Vector3f (0.0, 0.0, 1.0)); model.setEpsAngle (pcl::deg2rad (15));
- Note:
- Please remember that you need to specify an angle > 0 in order to activate the axis-angle constraint!
-
(11) SACMODEL_PARALLEL_LINES
- not implemented yet
- a model for determining plane models using an additional constraint: the surface normals at each inlier point has to be parallel to the surface normal of the output plane, within a maximum specified angular deviation. The plane coefficients are similar to SACMODEL_PLANE.
- SampleConsensusModelNormalPlane defines a model for 3D plane segmentation using additional surface normal constraints.
- Basically this means that checking for inliers will not only involve a "distance to model" criterion, but also an additional "maximum angular deviation" between the plane‘s normal and the inlier points normals.
The model coefficients are defined as:
-
- a : the X coordinate of the plane‘s normal (normalized)
- b : the Y coordinate of the plane‘s normal (normalized)
- c : the Z coordinate of the plane‘s normal (normalized)
- d : the fourth Hessian component of the plane‘s equation
To set the influence of the surface normals in the inlier estimation process, set the normal weight (0.0-1.0), e.g.:
SampleConsensusModelNormalPlane<pcl::PointXYZ, pcl::Normal> sac_model; ... sac_model.setNormalDistanceWeight (0.1); ...
- a model for determining a plane parallel to an user-specified axis, within a maximim specified angular deviation. SACMODEL_PLANE.
- SampleConsensusModelParallelPlane defines a model for 3D plane segmentation using additional angular constraints.The plane must be parallel to a user-specified axis (setAxis) within an user-specified angle threshold (setEpsAngle).
Code example for a plane model, parallel (within a 15 degrees tolerance) with the Z axis:
SampleConsensusModelParallelPlane<pcl::PointXYZ> model (cloud); model.setAxis (Eigen::Vector3f (0.0, 0.0, 1.0)); model.setEpsAngle (pcl::deg2rad (15));
(14) SACMODEL_NORMAL_PARALLEL_PLANE
- defines a model for 3D plane segmentation using additional surface normal constraints. The plane must lieparallel to a user-specified axis. SACMODEL_NORMAL_PARALLEL_PLANE therefore is equivallent to SACMODEL_NORMAL_PLANE + SACMODEL_PARALLEL_PLANE. The plane coefficients are similar toSACMODEL_PLANE.
- SampleConsensusModelNormalParallelPlane defines a model for 3D plane segmentation using additional surface normal constraints.
- Basically this means that checking for inliers will not only involve a "distance to model" criterion, but also an additional "maximum angular deviation" between the plane‘s normal and the inlier points normals. In addition, the plane normal must lie parallel to an user-specified axis.
The model coefficients are defined as:
-
- a : the X coordinate of the plane‘s normal (normalized)
- b : the Y coordinate of the plane‘s normal (normalized)
- c : the Z coordinate of the plane‘s normal (normalized)
- d : the fourth Hessian component of the plane‘s equation
To set the influence of the surface normals in the inlier estimation process, set the normal weight (0.0-1.0), e.g.:
SampleConsensusModelNormalPlane<pcl::PointXYZ, pcl::Normal> sac_model; ... sac_model.setNormalDistanceWeight (0.1); ...
文章引用自 https://blog.csdn.net/sdau20104555/article/details/40649101
以上是关于PCL中Sample_consensus分割支持的几何模型的主要内容,如果未能解决你的问题,请参考以下文章