当前位置: 首页>>代码示例>>C++>>正文


C++ NormalEstimation::computeEigen方法代码示例

本文整理汇总了C++中NormalEstimation::computeEigen方法的典型用法代码示例。如果您正苦于以下问题:C++ NormalEstimation::computeEigen方法的具体用法?C++ NormalEstimation::computeEigen怎么用?C++ NormalEstimation::computeEigen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NormalEstimation的用法示例。


在下文中一共展示了NormalEstimation::computeEigen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST

  TEST (PCL, NormalEstimationEigen)
  {
    Eigen::Vector4f plane_parameters;
    float curvature;

    NormalEstimation<PointXYZ, Eigen::MatrixXf> n;

    // computePointNormal (indices, Vector)
    computePointNormal (cloud, indices, plane_parameters, curvature);
    EXPECT_NEAR (fabs (plane_parameters[0]), 0.035592, 1e-4);
    EXPECT_NEAR (fabs (plane_parameters[1]), 0.369596, 1e-4);
    EXPECT_NEAR (fabs (plane_parameters[2]), 0.928511, 1e-4);
    EXPECT_NEAR (fabs (plane_parameters[3]), 0.0622552, 1e-4);
    EXPECT_NEAR (curvature, 0.0693136, 1e-4);

    float nx, ny, nz;
    // computePointNormal (indices)
    n.computePointNormal (cloud, indices, nx, ny, nz, curvature);
    EXPECT_NEAR (fabs (nx), 0.035592, 1e-4);
    EXPECT_NEAR (fabs (ny), 0.369596, 1e-4);
    EXPECT_NEAR (fabs (nz), 0.928511, 1e-4);
    EXPECT_NEAR (curvature, 0.0693136, 1e-4);

    // computePointNormal (Vector)
    computePointNormal (cloud, plane_parameters, curvature);
    EXPECT_NEAR (plane_parameters[0],  0.035592,  1e-4);
    EXPECT_NEAR (plane_parameters[1],  0.369596,  1e-4);
    EXPECT_NEAR (plane_parameters[2],  0.928511,  1e-4);
    EXPECT_NEAR (plane_parameters[3], -0.0622552, 1e-4);
    EXPECT_NEAR (curvature,            0.0693136, 1e-4);

    // flipNormalTowardsViewpoint (Vector)
    flipNormalTowardsViewpoint (cloud.points[0], 0, 0, 0, plane_parameters);
    EXPECT_NEAR (plane_parameters[0], -0.035592,  1e-4);
    EXPECT_NEAR (plane_parameters[1], -0.369596,  1e-4);
    EXPECT_NEAR (plane_parameters[2], -0.928511,  1e-4);
    EXPECT_NEAR (plane_parameters[3],  0.0799743, 1e-4);

    // flipNormalTowardsViewpoint
    flipNormalTowardsViewpoint (cloud.points[0], 0, 0, 0, nx, ny, nz);
    EXPECT_NEAR (nx, -0.035592, 1e-4);
    EXPECT_NEAR (ny, -0.369596, 1e-4);
    EXPECT_NEAR (nz, -0.928511, 1e-4);

    // Object
    PointCloud<Eigen::MatrixXf>::Ptr normals (new PointCloud<Eigen::MatrixXf> ());

    // set parameters
    PointCloud<PointXYZ>::Ptr cloudptr = cloud.makeShared ();
    n.setInputCloud (cloudptr);
    EXPECT_EQ (n.getInputCloud (), cloudptr);
    boost::shared_ptr<vector<int> > indicesptr (new vector<int> (indices));
    n.setIndices (indicesptr);
    EXPECT_EQ (n.getIndices (), indicesptr);
    n.setSearchMethod (tree);
    EXPECT_EQ (n.getSearchMethod (), tree);
    n.setKSearch (static_cast<int> (indices.size ()));

    // estimate
    n.computeEigen (*normals);
    EXPECT_EQ (normals->points.rows (), indices.size ());

    for (int i = 0; i < normals->points.rows (); ++i)
    {
      EXPECT_NEAR (normals->points.row (i)[0], -0.035592, 1e-4);
      EXPECT_NEAR (normals->points.row (i)[1], -0.369596, 1e-4);
      EXPECT_NEAR (normals->points.row (i)[2], -0.928511, 1e-4);
      EXPECT_NEAR (normals->points.row (i)[3], 0.0693136, 1e-4);
    }

    PointCloud<PointXYZ>::Ptr surfaceptr = cloudptr;
    n.setSearchSurface (surfaceptr);
    EXPECT_EQ (n.getSearchSurface (), surfaceptr);

    // Additional test for searchForNeigbhors
    surfaceptr.reset (new PointCloud<PointXYZ>);
    *surfaceptr = *cloudptr;
    surfaceptr->points.resize (640 * 480);
    surfaceptr->width = 640;
    surfaceptr->height = 480;
    EXPECT_EQ (surfaceptr->points.size (), surfaceptr->width * surfaceptr->height);
    n.setSearchSurface (surfaceptr);
    tree.reset ();
    n.setSearchMethod (tree);

    // estimate
    n.computeEigen (*normals);
    EXPECT_EQ (normals->points.rows (), indices.size ());
  }
开发者ID:hitsjt,项目名称:StanfordPCL,代码行数:89,代码来源:test_normal_estimation.cpp


注:本文中的NormalEstimation::computeEigen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。