ScoreComputer.h
Go to the documentation of this file.
1 #ifndef SCORECOMPUTER_HEADER
2 #define SCORECOMPUTER_HEADER
3 #include <GfxTL/NullClass.h>
4 #ifndef _USE_MATH_DEFINES
5 #define _USE_MATH_DEFINES
6 #endif
7 #include <cmath>
8 
9 #include "PointCloud.h"
10 
11 inline float
12 weigh(const float d, const float eps)
13 {
14  return std::exp(-d * d / (2.f / 9.f * eps * eps)); // gaussian weighting eps / 3 == sigma
15  // return 1.f - (d / eps) * (d / eps); // anti-quadratic weighting
16  // return 1.f - d / eps; // linear weighting
17  //return d * d; // SSE
18 }
19 
20 template <class BaseT>
21 class LocalScoreComputer : public BaseT
22 {
23 public:
24  template <class ShapeT>
25  static void
26  Score(const ShapeT& shape,
27  const PointCloud& pc,
28  float epsilon,
29  float normalThresh,
32  std::pair<size_t, float>* score,
34  {
35  Vec3f n;
36  size_t size = end - begin;
37  for (size_t iter = 0; iter < size; ++iter)
38  {
39  float d = shape.DistanceAndNormal(pc[begin[iter]].pos, &n);
40  float nd = n.dot(pc[begin[iter]].normal);
41  if (d < epsilon && abs(nd) > normalThresh)
42  {
43  ++score->first;
44  score->second += weigh(d, epsilon);
45  }
46  }
47  }
48 };
49 
50 #endif
weigh
float weigh(const float d, const float eps)
Definition: ScoreComputer.h:12
Vec3f
Definition: basic.h:17
LocalScoreComputer
Definition: ScoreComputer.h:21
magic_enum::detail::n
constexpr auto n() noexcept
Definition: magic_enum.hpp:418
MiscLib::Vector
Definition: Vector.h:19
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:281
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:717
LocalScoreComputer::Score
static void Score(const ShapeT &shape, const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end, std::pair< size_t, float > *score, MiscLib::Vector< size_t > *indices=NULL)
Definition: ScoreComputer.h:26
PointCloud
Definition: PointCloud.h:85
NullClass.h
PointCloud.h
pc
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics Blackwell June If you use this software you should cite the aforementioned paper in any resulting publication Please send comments or bug reports to Ruwen Roland BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Example usage This section shows how to use the library to detect the shapes in a point cloud PointCloud pc
Definition: ReadMe.txt:68