PCL中Sample_consensus模块支持的几何模型

As of PCL 1.0, the following models are supported: 

(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. 

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 
(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 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 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. 

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 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 sac_model;
 ...
 sac_model.setNormalDistanceWeight (0.1);
 ...
举例:(使用参数化模型投影点云到三维平面)

用到ModelCoefficients结构和ProjectInliers滤波器

说明:填充ModelCoefficients的值,例子中使用了一个ax+by+cz+d=0的平面模型,其中a=b=d=0,c=1;

创建了ProjectInliers对象,并使用刚定义好的 ModelCoefficients作为投影对象的模型参数。


[objc]  view plain  copy
 print ?
  1. #include  
  2. #include  
  3. #include  
  4. #include  
  5. #include  
  6. using namespace std;  
  7. int main()  
  8. {  
  9.     pcl::PointCloud::Ptr cloud(new pcl::PointCloud);  
  10.     pcl::PointCloud::Ptr cloud_projected(new pcl::PointCloud);  
  11.     cloud->width=5;  
  12.     cloud->height=1;  
  13.     cloud->points.resize(cloud->width*cloud->height);  
  14.     for(size_t i=0;ipoints.size();i++)  
  15.     {  
  16.         cloud->points[i].x=1024*rand()/(RAND_MAX+1.0f);  
  17.         cloud->points[i].y=1024*rand()/(RAND_MAX+1.0f);  
  18.         cloud->points[i].z=1024*rand()/(RAND_MAX+1.0f);  
  19.     }  
  20.     std::cerr<<"Cloud before projection:"<
  21.     for(size_t i=0;ipoints.size();i++)  
  22.         std::cerr<<' '<points[i].x<<' '<points[i].y<<' '<points[i].z<
  23.   
  24.     //定义模型系数对象,并填充对应的数据  
  25.     pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());  
  26.     coefficients->values.resize(4);  
  27.     coefficients->values[0]=coefficients->values[1]=coefficients->values[3]=0;  
  28.     coefficients->values[2]=1.0;  
  29.     pcl::ProjectInliers proj;//创建投影滤波对象  
  30.     proj.setModelType(pcl::SACMODEL_PLANE);//设置对象对应的投影模型  
  31.     proj.setInputCloud(cloud);      //设置输入点云  
  32.     proj.setModelCoefficients(coefficients);//设置模型对应的系数  
  33.     proj.filter(*cloud_projected);  
  34.   
  35.     std::cerr<<"Cloud after projection:"<
  36.     for(size_t i=0;ipoints.size();i++)  
  37.         std::cerr<<' '<points[i].x<<' '<points[i].y<<' '<points[i].z<
  38.     system("pause");  
  39.     return 0;  
  40. }  

总结:投影钱的z轴都不为0,是随机产生的值,投影之后,打印结果表明,x,y没有改变,z都变成0。

该投影滤波类输入为点云和投影模型,输出为投影到模型上之后的点云。

你可能感兴趣的:(PCL)