Go to the documentation of this file.
34 m_sphere(
s), m_parametrization(m_sphere)
41 m_parametrization.
Shape(m_sphere);
55 size_t upperuextent, uppervextent, loweruextent, lowervextent;
60 i->read((
char*)&size,
sizeof(size));
64 i->read((
char*)&bboxUpper,
sizeof(bboxUpper));
66 i->read((
char*)&upperuextent,
sizeof(upperuextent));
67 i->read((
char*)&uppervextent,
sizeof(uppervextent));
68 for (
size_t j = 0; j < size; ++j)
72 i->read((
char*)&numPolys,
sizeof(numPolys));
73 for (
size_t k = 0; k < numPolys; ++k)
77 i->read((
char*)&numPoints,
sizeof(numPoints));
79 for (
size_t l = 0; l < numPoints; ++l)
81 i->read((
char*)&pp,
sizeof(pp));
88 i->read((
char*)&size,
sizeof(size));
92 i->read((
char*)&bboxLower,
sizeof(bboxLower));
94 i->read((
char*)&loweruextent,
sizeof(loweruextent));
95 i->read((
char*)&lowervextent,
sizeof(lowervextent));
96 for (
size_t j = 0; j < size; ++j)
100 i->read((
char*)&numPolys,
sizeof(numPolys));
101 for (
size_t k = 0; k < numPolys; ++k)
105 i->read((
char*)&numPoints,
sizeof(numPoints));
107 for (
size_t l = 0; l < numPoints; ++l)
109 i->read((
char*)&pp,
sizeof(pp));
123 (*i) >> bboxUpper.
Min()[0] >> bboxUpper.
Max()[0] >> bboxUpper.
Min()[1] >>
126 (*i) >> upperuextent >> uppervextent;
127 for (
size_t j = 0; j < size; ++j)
132 for (
size_t k = 0; k < numPolys; ++k)
138 for (
size_t l = 0; l < numPoints; ++l)
140 (*i) >> pp[0] >> pp[1];
150 (*i) >> bboxLower.
Min()[0] >> bboxLower.
Max()[0] >> bboxLower.
Min()[1] >>
153 (*i) >> loweruextent >> lowervextent;
154 for (
size_t j = 0; j < size; ++j)
159 for (
size_t k = 0; k < numPolys; ++k)
165 for (
size_t l = 0; l < numPoints; ++l)
167 (*i) >> pp[0] >> pp[1];
198 m_sphere.
Normal(p, &normal);
199 return n.dot(normal);
205 std::pair<float, float>* dn)
const
209 dn->second =
n.dot(normal);
232 return BasePrimitiveShape::ConfidenceTests<Sphere>(
233 numTests, epsilon, normalThresh, rms,
pc,
indices);
254 m_parametrization.
Shape(m_sphere);
266 std::pair<size_t, float>* score)
const
303 m_sphere.
Init(binary, i);
304 m_parametrization.
Shape(m_sphere);
329 visitor->
Visit(*
this);
345 size_t c = samples.
size() / 2;
349 for (
unsigned int i = 0; i < 5; ++i, u += uStep)
352 for (
unsigned int j = 0; j < 5; ++j,
v += vStep)
353 m_parametrization.
InSpace(u,
v, &samples[i * 5 + j], &samples[i * 5 + j +
c]);
360 for (
size_t i = 0; i <
c; ++i)
361 if (plane.
Distance(samples[i]) > distThresh)
369 suggestions->back()->Release();
458 return m_sphere.
Radius() <= (1.f + tolerance) * shape.m_sphere.
Radius() &&
459 (1.f + tolerance) * m_sphere.
Radius() >= shape.m_sphere.
Radius();
474 ParametersImpl(begin, end, bmpParams);
483 ParametersImpl(begin, end, bmpParams);
489 return m_parametrization.
InSpace(u,
v, p,
n);
499 *uextent = std::ceil((bbox->
Max()[0] - bbox->
Min()[0]) / epsilon);
500 *vextent = std::ceil((bbox->
Max()[1] - bbox->
Min()[1]) / epsilon);
509 std::pair<int, int>* inBmp)
const
511 inBmp->first = std::floor((param.first - bbox.
Min()[0]) / epsilon);
512 inBmp->second = std::floor((param.second - bbox.
Min()[1]) / epsilon);
521 m_parametrization.
WrapBitmap(bbox, epsilon, uwrap, vwrap);
532 m_parametrization.
WrapComponents(bbox, epsilon, uextent, vextent, componentImg, labels);
545 return m_parametrization.
InSpace(
546 (u + .5f) * epsilon + bbox.
Min()[0], (
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 ...
constexpr auto n() noexcept
unsigned int ConfidenceTests(unsigned int numTests, float epsilon, float normalThresh, float rms, const PointCloud &pc, const MiscLib::Vector< size_t > &indices) 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 BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float >> *params, size_t *uextent, size_t *vextent)
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 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
void Serialize(std::ostream *o, bool binary) 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
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
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