Git Product home page Git Product logo

pcl-normal-estimation-2d's Introduction

Normal-Estimation-2d

PCL add-on to compute normal estimation to 2D pointCloud. You can find a Normal2dEstimation class that take 3D points but ignore the z part.

You can see the example result just bellow : normal_illustration

Why

The PCL library doesn't support pure 2D points. You have to use 3D points with a z compotent equals to 0. This trick work with many algorithm like centroid, ICP, ransac etc.. But it doesn't work with normal estimation due to your constant component (all normal are equal to (0,0,1). My implementation solve this problem by ignoring the z component.

Here you can see the problem with pcl 3d normal estimation: problem_normal

pcl-normal-estimation-2d's People

Contributors

enderdead avatar kotaweav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pcl-normal-estimation-2d's Issues

issue in making

Hi,
Thanks for the nice idea,

When making the file I see that pcl_isfinite is not defined in the namespace, so when changing !pcl_isfinite (in_cloud->points[i].x) to !pcl::pcl_isfinite (in_cloud->points[i].x), this shows up:

make
Consolidate compiler generated dependencies of target pcl_norm_2d
[ 20%] Building CXX object CMakeFiles/pcl_norm_2d.dir/src/PCA2D.cpp.o
/PCL-Normal-Estimation-2d-master/src/PCA2D.cpp: In member function ‘void PCA2D::project(const ConstPtrCloud&, PtrCloud&)’:
/PCL-Normal-Estimation-2d-master/src/PCA2D.cpp:99:23: error: ‘pcl_isfinite’ is not a member of ‘pcl’; did you mean ‘isFinite’?
   99 |             if (!pcl::pcl_isfinite(in_cloud->points[i].x) ||
      |                       ^~~~~~~~~~~~
      |                       isFinite
/PCL-Normal-Estimation-2d-master/src/PCA2D.cpp:100:23: error: ‘pcl_isfinite’ is not a member of ‘pcl’; did you mean ‘isFinite’?
  100 |                 !pcl::pcl_isfinite(in_cloud->points[i].y) ||
      |                       ^~~~~~~~~~~~
      |                       isFinite
/PCL-Normal-Estimation-2d-master/src/PCA2D.cpp:101:23: error: ‘pcl_isfinite’ is not a member of ‘pcl’; did you mean ‘isFinite’?
  101 |                 !pcl::pcl_isfinite(in_cloud->points[i].z))
      |                       ^~~~~~~~~~~~
      |                       isFinite
make[2]: *** [CMakeFiles/pcl_norm_2d.dir/build.make:76: CMakeFiles/pcl_norm_2d.dir/src/PCA2D.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/pcl_norm_2d.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

and when I change pcl::pcl_isfinite() to !pcl::isFinite(in_cloud->points[i].x) I still see the following error:

make
Consolidate compiler generated dependencies of target pcl_norm_2d
[ 20%] Building CXX object CMakeFiles/pcl_norm_2d.dir/src/PCA2D.cpp.o
In file included from /usr/include/pcl-1.12/pcl/common/impl/centroid.hpp:45,
                 from /usr/include/pcl-1.12/pcl/common/centroid.h:1099,
                 from /PCL-Normal-Estimation-2d-master/src/../include/PCA2D.h:13,
                 from /PCL-Normal-Estimation-2d-master/src/PCA2D.cpp:5:
/usr/include/pcl-1.12/pcl/common/point_tests.h: In instantiation of ‘bool pcl::isFinite(const PointT&) [with PointT = float]’:
/PCL-Normal-Estimation-2d-master/src/PCA2D.cpp:99:31:   required from here
/usr/include/pcl-1.12/pcl/common/point_tests.h:57:31: error: request for member ‘x’ in ‘pt’, which is of non-class type ‘const float’
   57 |     return (std::isfinite (pt.x) && std::isfinite (pt.y) && std::isfinite (pt.z));
      |                            ~~~^
/usr/include/pcl-1.12/pcl/common/point_tests.h:57:55: error: request for member ‘y’ in ‘pt’, which is of non-class type ‘const float’
   57 |     return (std::isfinite (pt.x) && std::isfinite (pt.y) && std::isfinite (pt.z));
      |                                                    ~~~^
/usr/include/pcl-1.12/pcl/common/point_tests.h:57:79: error: request for member ‘z’ in ‘pt’, which is of non-class type ‘const float’
   57 |     return (std::isfinite (pt.x) && std::isfinite (pt.y) && std::isfinite (pt.z));
      |                                                                            ~~~^
make[2]: *** [CMakeFiles/pcl_norm_2d.dir/build.make:76: CMakeFiles/pcl_norm_2d.dir/src/PCA2D.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/pcl_norm_2d.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

What is the issue here? any hints?

Empty inputs

In PCA source code, if indices isn't set, the computation will fail because automatic indices generation is missing. it is necessary that PCA2D and Normal 2D estimation inherit from PCLBase.

make have bug

error: cannot convert ‘const IndicesPtr’ {aka ‘const boost::shared_ptr<std::vector<int, std::allocator > >’} to ‘const IndicesConstPtr&’ {aka ‘const std::shared_ptr<const std::vector<int, std::allocator > >&’}
60 | this->m_kd_tree->setInputCloud(m_in_cloud, m_indices);
| ^~~~~~~~~
| |
| const IndicesPtr {aka const boost::shared_ptr<std::vector<int, std::allocator > >}
In file included from /home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/../include/Normal2dEstimation.h:14,
from /home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/Normal2dEstimation.cpp:5:
/usr/local/include/pcl-1.12/pcl/search/search.h:121:47: note: initializing argument 2 of ‘void pcl::search::Search::setInputCloud(const PointCloudConstPtr&, const IndicesConstPtr&) [with PointT = pcl::PointXYZ; pcl::search::Search::PointCloudConstPtr = std::shared_ptr<const pcl::PointCloudpcl::PointXYZ >; pcl::search::Search::IndicesConstPtr = std::shared_ptr<const std::vector<int, std::allocator > >]’
121 | const IndicesConstPtr &indices = IndicesConstPtr ());
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/Normal2dEstimation.cpp: In member function ‘void Normal2dEstimation::compute(const Ptr&) const’:
/home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/Normal2dEstimation.cpp:125:48: error: cannot convert ‘const IndicesPtr’ {aka ‘const boost::shared_ptr<std::vector<int, std::allocator > >’} to ‘const IndicesConstPtr&’ {aka ‘const std::shared_ptr<const std::vector<int, std::allocator > >&’}
125 | this->m_kd_tree->setInputCloud(m_in_cloud, m_indices);
| ^~~~~~~~~
| |
| const IndicesPtr {aka const boost::shared_ptr<std::vector<int, std::allocator > >}
In file included from /home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/../include/Normal2dEstimation.h:14,
from /home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/Normal2dEstimation.cpp:5:
/usr/local/include/pcl-1.12/pcl/search/search.h:121:47: note: initializing argument 2 of ‘void pcl::search::Search::setInputCloud(const PointCloudConstPtr&, const IndicesConstPtr&) [with PointT = pcl::PointXYZ; pcl::search::Search::PointCloudConstPtr = std::shared_ptr<const pcl::PointCloudpcl::PointXYZ >; pcl::search::Search::IndicesConstPtr = std::shared_ptr<const std::vector<int, std::allocator > >]’
121 | const IndicesConstPtr &indices = IndicesConstPtr ());
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/Normal2dEstimation.cpp: In member function ‘bool Normal2dEstimation::computePointNormal2d(boost::shared_ptr<std::vector<int, std::allocator > >&, Eigen::Vector3f&) const’:
/home/chenxiaocong/cvte_work/slam/code/PCL-Normal-Estimation-2d/src/Normal2dEstimation.cpp:268:27: error: no matching function for call to ‘pcl::PCApcl::PointXYZ::setIndices(boost::shared_ptr<std::vector<int, std::allocator > >&)’
268 | pca.setIndices(indices);

Question about the normal calculation method

Hi, I have been using this repo for a while now with the fork I have created. This was very useful to me and I have used this in my ms thesis. I have understood how you computed the normals by finding the eigenvectors of the alpha matrix but, I would like to refer to this method by its 'scientific name' if there is any. I am planning to cite this repo and the method that you are using. I would like to know if there is any 'scientific term' for calculating normals this way.

Thanks in advance,
Ulaş

Breaks in release mode

Just thought I'd note for anyone else who comes across this, with PCL 1.12, C++14, changing all the boost references etc, it works but only in Debug mode (I think - CMake default). Changing to release mode (-DCMAKE_BUILD_TYPE=Release) causes the algorithm to fail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.