Go to the documentation of this file.
33 , m_parametrization(m_sphere)
38 , m_sphere(sps.m_sphere)
39 , m_parametrization(sps.m_parametrization)
41 m_parametrization.
Shape(m_sphere);
53 size_t upperuextent, uppervextent, loweruextent, lowervextent;
58 i->read((
char*)&size,
sizeof(size));
62 i->read((
char*)&bboxUpper,
sizeof(bboxUpper));
64 i->read((
char*)&upperuextent,
sizeof(upperuextent));
65 i->read((
char*)&uppervextent,
sizeof(uppervextent));
66 for (
size_t j = 0; j < size; ++j)
70 i->read((
char*)&numPolys,
sizeof(numPolys));
71 for (
size_t k = 0; k < numPolys; ++k)
75 i->read((
char*)&numPoints,
sizeof(numPoints));
77 for (
size_t l = 0; l < numPoints; ++l)
79 i->read((
char*)&pp,
sizeof(pp));
86 i->read((
char*)&size,
sizeof(size));
90 i->read((
char*)&bboxLower,
sizeof(bboxLower));
92 i->read((
char*)&loweruextent,
sizeof(loweruextent));
93 i->read((
char*)&lowervextent,
sizeof(lowervextent));
94 for (
size_t j = 0; j < size; ++j)
98 i->read((
char*)&numPolys,
sizeof(numPolys));
99 for (
size_t k = 0; k < numPolys; ++k)
103 i->read((
char*)&numPoints,
sizeof(numPoints));
105 for (
size_t l = 0; l < numPoints; ++l)
107 i->read((
char*)&pp,
sizeof(pp));
121 (*i) >> bboxUpper.
Min()[0] >> bboxUpper.
Max()[0]
122 >> bboxUpper.
Min()[1] >> bboxUpper.
Max()[1];
124 (*i) >> upperuextent >> uppervextent;
125 for (
size_t j = 0; j < size; ++j)
130 for (
size_t k = 0; k < numPolys; ++k)
136 for (
size_t l = 0; l < numPoints; ++l)
138 (*i) >> pp[0] >> pp[1];
148 (*i) >> bboxLower.
Min()[0] >> bboxLower.
Max()[0]
149 >> bboxLower.
Min()[1] >> bboxLower.
Max()[1];
151 (*i) >> loweruextent >> lowervextent;
152 for (
size_t j = 0; j < size; ++j)
157 for (
size_t k = 0; k < numPolys; ++k)
163 for (
size_t l = 0; l < numPoints; ++l)
165 (*i) >> pp[0] >> pp[1];
190 const Vec3f& n)
const
193 m_sphere.
Normal(p, &normal);
194 return n.
dot(normal);
198 const Vec3f& p,
const Vec3f& n, std::pair< float, float >* dn)
const
202 dn->second = n.
dot(normal);
216 float epsilon,
float normalThresh,
float rms,
const PointCloud&
pc,
219 return BasePrimitiveShape::ConfidenceTests< Sphere >(numTests, epsilon,
237 m_parametrization.
Shape(m_sphere);
246 std::pair< size_t, float >* score)
const
280 m_sphere.
Init(binary, i);
281 m_parametrization.
Shape(m_sphere);
303 visitor->
Visit(*
this);
316 size_t c = samples.
size() / 2;
320 for (
unsigned int i = 0; i < 5; ++i, u += uStep)
323 for (
unsigned int j = 0; j < 5; ++j,
v += vStep)
325 &samples[i * 5 + j], &samples[i * 5 + j +
c]);
332 for (
size_t i = 0; i <
c; ++i)
333 if (plane.
Distance(samples[i]) > distThresh)
341 suggestions->back()->Release();
415 size_t begin,
size_t end,
float epsilon)
424 return m_sphere.
Radius() <= (1.f + tolerance) * shape.m_sphere.
Radius()
425 && (1.f + tolerance) * m_sphere.
Radius() >= shape.m_sphere.
Radius();
429 std::pair< float, float >* param)
const
441 ParametersImpl(begin, end, bmpParams);
451 ParametersImpl(begin, end, bmpParams);
456 return m_parametrization.
InSpace(u,
v, p, n);
462 size_t* uextent,
size_t* vextent)
464 *uextent = std::ceil((bbox->
Max()[0] - bbox->
Min()[0]) / epsilon);
465 *vextent = std::ceil((bbox->
Max()[1] - bbox->
Min()[1]) / epsilon);
470 size_t uextent,
size_t vextent,
471 std::pair< int, int >* inBmp)
const
473 inBmp->first = std::floor((param.first - bbox.
Min()[0]) / epsilon);
474 inBmp->second = std::floor((param.second - bbox.
Min()[1]) / epsilon);
479 float epsilon,
bool* uwrap,
bool* vwrap)
const
481 m_parametrization.
WrapBitmap(bbox, epsilon, uwrap, vwrap);
485 float epsilon,
size_t uextent,
size_t vextent,
490 componentImg, labels);
497 return m_parametrization.
InSpace((u + .5f) * epsilon + bbox.
Min()[0],
498 (
v + .5f) * epsilon + bbox.
Min()[1], p, n);
bool InSpace(float u, float v, Vec3f *p) const
virtual void Visit(const PlanePrimitiveShape &plane)=0
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
void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const
float Distance(const Vec3f &p) const
float Distance(const Vec3f &p) const
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
bool InSpace(float u, float v, Vec3f *p, Vec3f *n) const
void Normal(const Vec3f &p, Vec3f *n) const
void Project(const Vec3f &p, Vec3f *pp) const
void resize(size_type s, const value_type &v)
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
static size_t SerializedSize()
void OptimizeParametrization(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end, float epsilon)
PrimtiveShape is a shape primitive in conjunction with a parametrization.
void Serialize(std::ostream *o, bool binary=true) const
This is the one and only serialization function It stores all the parameters of the shape as well as ...
unsigned int ConfidenceTests(unsigned int numTests, float epsilon, float normalThresh, float rms, const PointCloud &pc, const MiscLib::Vector< size_t > &indices) const
const typedef Point * const_iterator
bool Similar(float tolerance, const SpherePrimitiveShape &shape) const
void Transform(float scale, const Vec3f &translate)
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...
float Distance(const Vec3f &pos) const
void Serialize(std::ostream *o, bool binary) const
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
void Serialize(bool binary, std::ostream *o) const
LevMarFunc< float > * SignedDistanceFunc() const
IndexedIterator< IndexIteratorT, IteratorT > IndexIterate(IndexIteratorT idxIt, IteratorT it)
static size_t SerializedSize()
void Deserialize(std::istream *i, bool binary)
GfxTL::AABox< GfxTL::Vector2Df > m_extBbox
void Normal(const Vec3f &p, Vec3f *normal) const
void WrapComponents(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< int > *componentImg, MiscLib::Vector< std::pair< int, size_t > > *labels) const
bool Init(const MiscLib::Vector< Vec3f > &samples)
void InBitmap(const std::pair< float, float > ¶m, float epsilon, const GfxTL::AABox< GfxTL::Vector2Df > &bbox, size_t uextent, size_t vextent, std::pair< int, int > *inBmp) const
float SignedDistance(const Vec3f &p) const
void Description(std::string *s) const
MiscLib::performance_t totalTime_sphereConnected
void Visit(PrimitiveShapeVisitor *visitor) const
void WrapComponents(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< int > *componentImg, MiscLib::Vector< std::pair< int, size_t > > *labels) const
double v(double t, double v0, double a0, double j)
void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const
float DistanceAndNormal(const Vec3f &p, Vec3f *normal) const
void BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float > > *params, size_t *uextent, size_t *vextent)
float dot(const Vec3f &v) const
float NormalDeviation(const Vec3f &p, const Vec3f &n) const
void Shape(const Sphere &sphere)
size_t SerializedSize() const
void Optimize(IteratorT begin, IteratorT end, float epsilon)
PrimitiveShape * Clone() const
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
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
void Project(const Vec3f &p, Vec3f *pp) const
bool Init(bool binary, std::istream *i)
void DistanceAndNormalDeviation(const Vec3f &p, const Vec3f &n, std::pair< float, float > *dn) const
void Deserialize(std::istream *i, bool binary)
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
size_t Identifier() const
bool Fit(const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
double s(double t, double s0, double v0, double a0, double j)
class DLL_LINKAGE PlanePrimitiveShape
void Transform(float scale, const Vec3f &translate)
float SignedDistance(const Vec3f &p) const