CylinderPrimitiveShape.h
Go to the documentation of this file.
1 #ifndef CYLINDERPRIMITIVESHAPE_HEADER
2 #define CYLINDERPRIMITIVESHAPE_HEADER
3 #include "BitmapPrimitiveShape.h"
4 #include "Cylinder.h"
5 #include "LevMarFunc.h"
6 
7 #ifndef DLL_LINKAGE
8 #define DLL_LINKAGE
9 #endif
10 
12  : public BitmapPrimitiveShape
13 {
14 public:
16  size_t Identifier() const;
17  unsigned int RequiredSamples() const
18  {
20  }
21  CylinderPrimitiveShape(const Cylinder& cylinder);
22  PrimitiveShape* Clone() const;
23  bool Init(const Vec3f& pointA, const Vec3f& pointB,
24  const Vec3f& normalA, const Vec3f& normalB);
25  bool Init(bool binary, std::istream* i)
26  {
27  return BitmapPrimitiveShape::Init(binary, i);
28  }
29  float Distance(const Vec3f& p) const;
30  float SignedDistance(const Vec3f& p) const;
31  float NormalDeviation(const Vec3f& p, const Vec3f& n) const;
32  void DistanceAndNormalDeviation(const Vec3f& p,
33  const Vec3f& n, std::pair< float, float >* dn) const;
34  void Project(const Vec3f& p, Vec3f* pp) const;
35  void Normal(const Vec3f& p, Vec3f* n) const;
36  unsigned int ConfidenceTests(unsigned int numTests, float epsilon,
37  float normalThresh, float rms, const PointCloud& pc,
38  const MiscLib::Vector< size_t >& indices) const;
39  void Description(std::string* s) const;
40  bool Fit(const PointCloud& pc, float epsilon, float normalThresh,
43  PrimitiveShape* LSFit(const PointCloud& pc, float epsilon,
44  float normalThresh,
47  std::pair< size_t, float >* score) const;
49  void Serialize(std::ostream* o, bool binary = true) const;
50  size_t SerializedSize() const;
51  virtual void Serialize(float* array) const
52  {
53  m_cylinder.Serialize(array);
54  }
55  virtual size_t SerializedFloatSize() const
56  {
57  return m_cylinder.SerializedFloatSize();
58  }
59  void Transform(float scale, const Vec3f& translate);
61  const GfxTL::Vector3Df& trans);
62  void Visit(PrimitiveShapeVisitor* visitor) const;
65  MiscLib::Vector< size_t >::const_iterator end, float distThresh,
67  bool Similar(float tolerance,
68  const CylinderPrimitiveShape& shape) const;
69  const Cylinder& Internal() const
70  {
71  return m_cylinder;
72  }
73  float Height() const;
74  float MinHeight() const;
75  float MaxHeight() const;
76 
77  void Parameters(const Vec3f& p,
78  std::pair< float, float >* param) const;
83  MiscLib::Vector< std::pair< float, float > >* bmpParams) const;
88  MiscLib::Vector< std::pair< float, float > >* bmpParams) const;
89  bool InSpace(float u, float v, Vec3f* p, Vec3f* n) const;
90  void BitmapExtent(float epsilon,
92  MiscLib::Vector< std::pair< float, float > >* params,
93  size_t* uextent, size_t* vextent);
94  void InBitmap(const std::pair< float, float >& param, float epsilon,
95  const GfxTL::AABox< GfxTL::Vector2Df >& bbox, size_t uextent,
96  size_t vextent, std::pair< int, int >* inBmp) const;
98  float epsilon, bool* uwrap, bool* vwrap) const;
100  float epsilon, size_t uextent, size_t vextent,
101  MiscLib::Vector< char >* bmp) const;
102  void SetExtent(const GfxTL::AABox< GfxTL::Vector2Df >& bbox,
103  const MiscLib::Vector< int >& componentsImg, size_t uextent,
104  size_t vextent, float epsilon, int label);
105  bool InSpace(size_t u, size_t v, float epsilon,
106  const GfxTL::AABox< GfxTL::Vector2Df >& bbox, size_t uextent,
107  size_t vextent, Vec3f* p, Vec3f* n) const;
108 
109 private:
110  template< class IteratorT >
111  void ParametersImpl(IteratorT begin, IteratorT end,
112  MiscLib::Vector< std::pair< float, float > >* bmpParams) const;
113 
114 private:
115  Cylinder m_cylinder;
116  bool m_clip;
117  float m_minPhi;
118  float m_maxPhi;
119 };
120 
121 template< class IteratorT >
122 void CylinderPrimitiveShape::ParametersImpl(IteratorT begin, IteratorT end,
123  MiscLib::Vector< std::pair< float, float > >* bmpParams) const
124 {
125  bmpParams->resize(end - begin);
126  size_t j = 0;
127  for (IteratorT i = begin; i != end; ++i, ++j)
128  {
129  m_cylinder.Parameters(*i, &(*bmpParams)[j]);
130  (*bmpParams)[j].second = (*bmpParams)[j].second * m_cylinder.Radius();
131  }
132 }
133 
135  : public LevMarFunc< float >
136 {
137 public:
139  : m_cylinder(cy)
140  {}
141 
142  float operator()(const float* x) const
143  {
144  return m_cylinder.SignedDistance(*((const Vec3f*)x));
145  }
146 
147  void operator()(const float* x, float* gradient) const
148  {
149  m_cylinder.Normal(*((const Vec3f*)x), (Vec3f*)gradient);
150  }
151 
152 private:
153  Cylinder m_cylinder;
154 };
155 
156 #endif
GfxTL::IndexedIterator
Definition: IndexedIterator.h:8
Cylinder::Radius
float Radius() const
Definition: Cylinder.cpp:309
LevMarFunc< float >
GfxTL::VectorXD
Definition: MatrixXX.h:21
PrimitiveShape::Identifier
virtual size_t Identifier() const =0
Cylinder.h
CylinderLevMarFunc
Definition: CylinderPrimitiveShape.h:134
PrimitiveShape::Project
virtual void Project(const Vec3f &p, Vec3f *pp) const =0
PrimitiveShape::Fit
virtual bool Fit(const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)=0
Vec3f
Definition: basic.h:16
BitmapPrimitiveShape::PreWrapBitmap
virtual void PreWrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< char > *bmp) const
Definition: BitmapPrimitiveShape.cpp:12
Cylinder::RequiredSamples
@ RequiredSamples
Definition: Cylinder.h:28
PrimitiveShape::SignedDistance
virtual float SignedDistance(const Vec3f &p) const =0
BitmapPrimitiveShape
Definition: BitmapPrimitiveShape.h:30
CylinderPrimitiveShape::RequiredSamples
unsigned int RequiredSamples() const
Definition: CylinderPrimitiveShape.h:17
Cylinder::Parameters
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
Definition: Cylinder.cpp:289
BitmapPrimitiveShape::InSpace
virtual bool InSpace(float u, float v, Vec3f *p, Vec3f *n) const =0
PrimitiveShape
PrimtiveShape is a shape primitive in conjunction with a parametrization.
Definition: PrimitiveShape.h:32
PrimitiveShape::Normal
virtual void Normal(const Vec3f &p, Vec3f *n) const =0
PrimitiveShape::NormalDeviation
virtual float NormalDeviation(const Vec3f &p, const Vec3f &n) const =0
PrimitiveShape::LSFit
virtual PrimitiveShape * LSFit(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) const =0
GfxTL::MatrixXX
Definition: MatrixXX.h:25
PrimitiveShape::Distance
virtual float Distance(const Vec3f &p) const =0
MiscLib::Vector< size_t >
PrimitiveShape::SerializedSize
virtual size_t SerializedSize() const =0
LevMarFunc.h
MiscLib::Vector< Point >::const_iterator
const typedef Point * const_iterator
Definition: Vector.h:26
CylinderPrimitiveShape
class DLL_LINKAGE CylinderPrimitiveShape
Definition: PrimitiveShapeVisitor.h:10
PrimitiveShape::Description
virtual void Description(std::string *s) const =0
CylinderPrimitiveShape::Init
bool Init(bool binary, std::istream *i)
Definition: CylinderPrimitiveShape.h:25
PrimitiveShape::SuggestSimplifications
virtual void SuggestSimplifications(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end, float distThresh, MiscLib::Vector< MiscLib::RefCountPtr< PrimitiveShape > > *suggestions) const
Definition: PrimitiveShape.h:93
PrimitiveShape::DistanceAndNormalDeviation
virtual void DistanceAndNormalDeviation(const Vec3f &p, const Vec3f &n, std::pair< float, float > *dn) const =0
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:737
CylinderPrimitiveShape
Definition: CylinderPrimitiveShape.h:11
PrimitiveShapeVisitor
Definition: PrimitiveShapeVisitor.h:14
CylinderLevMarFunc::operator()
float operator()(const float *x) const
Definition: CylinderPrimitiveShape.h:142
BitmapPrimitiveShape::Init
bool Init(bool binary, std::istream *i)
Definition: BitmapPrimitiveShape.cpp:28
BitmapPrimitiveShape.h
BasePrimitiveShape::ConfidenceTests
unsigned int ConfidenceTests(unsigned int numTests, float epsilon, float normalThresh, float rms, const PointCloud &pc, const MiscLib::Vector< size_t > &indices) const
Definition: BasePrimitiveShape.h:17
MiscLib::RefCountPtr< PrimitiveShape >
CylinderPrimitiveShape::SerializedFloatSize
virtual size_t SerializedFloatSize() const
Definition: CylinderPrimitiveShape.h:55
PointCloud
Definition: PointCloud.h:69
CylinderPrimitiveShape::Serialize
virtual void Serialize(float *array) const
Definition: CylinderPrimitiveShape.h:51
CylinderPrimitiveShape::Internal
const Cylinder & Internal() const
Definition: CylinderPrimitiveShape.h:69
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
BitmapPrimitiveShape::Parameters
virtual void Parameters(const Vec3f &p, std::pair< float, float > *param) const =0
BitmapPrimitiveShape::BitmapExtent
virtual void BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float > > *params, size_t *uextent, size_t *vextent)=0
DLL_LINKAGE
#define DLL_LINKAGE
Definition: basic.h:11
BitmapPrimitiveShape::InBitmap
virtual void InBitmap(const std::pair< float, float > &param, float epsilon, const GfxTL::AABox< GfxTL::Vector2Df > &bbox, size_t uextent, size_t vextent, std::pair< int, int > *inBmp) const =0
CylinderLevMarFunc::CylinderLevMarFunc
CylinderLevMarFunc(const Cylinder &cy)
Definition: CylinderPrimitiveShape.h:138
PrimitiveShape::Transform
virtual void Transform(float scale, const Vec3f &translate)=0
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
Cylinder
Definition: Cylinder.h:20
PrimitiveShape::Serialize
virtual void Serialize(std::ostream *o, bool binary=true) const =0
This is the one and only serialization function It stores all the parameters of the shape as well as ...
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
IndexIterator
Definition: IndexIterator.h:9
CylinderLevMarFunc::operator()
void operator()(const float *x, float *gradient) const
Definition: CylinderPrimitiveShape.h:147
GfxTL::AABox
Definition: AABox.h:18
PrimitiveShape::SignedDistanceFunc
virtual LevMarFunc< float > * SignedDistanceFunc() const =0
BitmapPrimitiveShape::WrapBitmap
virtual void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const =0
PrimitiveShape::Clone
virtual PrimitiveShape * Clone() const =0
PrimitiveShape::Visit
virtual void Visit(PrimitiveShapeVisitor *visitor) const =0