码迷,mamicode.com
首页 > 其他好文 > 详细

PCL中Sample_consensus分割支持的几何模型

时间:2018-05-02 02:35:19      阅读:489      评论:0      收藏:0      [点我收藏+]

标签:...   直线   div   models   activate   similar   min   com   tps   

随机采样一致分割法,从点云中分割出线、面等几何元素

#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

 

(2) SACMODEL_LINE(三维直线)
  • 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
     
(3) SACMODEL_CIRCLE2D(二维圆)
  • 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

 

(4) SACMODEL_CIRCLE3D
  • 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 

 

(6) SACMODEL_CYLINDER(柱)
  •  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 

 

(7) SACMODEL_CONE 
  • not implemented yet 

 

(8) SACMODEL_TORUS
  •  not implemented yet 

 

(9) SACMODEL_PARALLEL_LINE(平行线)
  •  a model for determining a line parallel with a given axis, within a maximum specified angular deviation. The line coefficients are similar toSACMODEL_LINE

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 

 

(10) SACMODEL_PERPENDICULAR_PLANE
  • 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 

 

(12) SACMODEL_NORMAL_PLANE 

  • 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);
 ...

 

(13) SACMODEL_PARALLEL_PLANE

  • a model for determining a plane parallel to an user-specified axis, within a maximim specified angular deviation. SACMODEL_PLANE. 

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分割支持的几何模型

标签:...   直线   div   models   activate   similar   min   com   tps   

原文地址:https://www.cnblogs.com/gdut-gordon/p/8977942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!