Go to the documentation of this file.
5 #ifndef _USE_MATH_DEFINES
6 #define _USE_MATH_DEFINES
23 : m_cylinder(cylinder)
39 return m_cylinder.
Init(pointA, pointB, normalA, normalB);
56 m_cylinder.
Normal(p, &normal);
61 const Vec3f& p,
const Vec3f& n, std::pair< float, float >* dn)
const
65 dn->second = n.
dot(normal);
79 float epsilon,
float normalThresh,
float rms,
const PointCloud&
pc,
82 return BasePrimitiveShape::ConfidenceTests< Cylinder >(numTests, epsilon,
106 float epsilon,
float normalThresh,
109 std::pair< size_t, float >* score)
const
162 visitor->
Visit(*
this);
177 for (
unsigned int i = 0; i < 5; ++i, u += uStep)
180 for (
unsigned int j = 0; j < 5; ++j,
v += vStep)
182 &samples[i * 5 + j + 25]);
184 size_t c = samples.
size() / 2;
187 if (sphere.
Init(samples))
191 for (
size_t i = 0; i <
c; ++i)
192 if (sphere.
Distance(samples[i]) > distThresh)
200 suggestions->back()->Release();
207 for (
size_t i = 0; i <
c; ++i)
208 if (plane.
Distance(samples[i]) > distThresh)
216 suggestions->back()->Release();
259 return m_cylinder.
Radius() <= (1.f + tolerance) * shape.m_cylinder.
Radius()
260 && (1.f + tolerance) * m_cylinder.
Radius() >= shape.m_cylinder.
Radius();
279 std::pair< float, float >* param)
const
283 param->second *= m_cylinder.
Radius();
293 ParametersImpl(begin, end, bmpParams);
303 ParametersImpl(begin, end, bmpParams);
309 size_t* uextent,
size_t* vextent)
311 *uextent = size_t(std::ceil(
312 (bbox->
Max()[0] - bbox->
Min()[0]) / epsilon));
313 *vextent = size_t(std::ceil((bbox->
Max()[1] - bbox->
Min()[1]) / epsilon));
314 if ((*vextent) * (*uextent) > 1e6)
317 if (bbox->
Min()[1] > epsilon && bbox->
Max()[1] < 2 *
M_PI * m_cylinder.
Radius() - epsilon)
322 for (
size_t i = 0; i < params->size(); ++i)
324 angularParams[i] = (*params)[i].second;
326 std::sort(angularParams.
begin(), angularParams.
end());
330 for (
size_t i = 1; i < angularParams.
size(); ++i)
332 float gap = angularParams[i] - angularParams[i - 1];
336 lower = angularParams[i - 1];
337 upper = angularParams[i];
340 if (maxGap > epsilon)
343 float newCut = (lower + upper) / 2.f;
345 bbox->
Min()[1] = std::numeric_limits< float >::infinity();
346 bbox->
Max()[1] = -std::numeric_limits< float >::infinity();
347 for (
size_t i = 0; i < params->size(); ++i)
349 (*params)[i].second -= newCut;
350 if ((*params)[i].second < 0)
352 (*params)[i].second = 2 *
M_PI * m_cylinder.
Radius() + (*params)[i].second;
354 if ((*params)[i].second < bbox->Min()[1])
356 bbox->
Min()[1] = (*params)[i].second;
358 if ((*params)[i].second > bbox->
Max()[1])
360 bbox->
Max()[1] = (*params)[i].second;
363 *vextent = size_t(std::ceil((bbox->
Max()[1] - bbox->
Min()[1]) / epsilon));
370 size_t uextent,
size_t vextent, std::pair< int, int >* inBmp)
const
373 inBmp->first = std::floor((param.first - bbox.
Min()[0]) / epsilon);
374 inBmp->second = std::floor((param.second - bbox.
Min()[1]) / epsilon);
381 if (bbox.
Max()[1] - bbox.
Min()[1]
382 >= 2 *
M_PI * m_cylinder.
Radius() - 2 * epsilon)
398 for (
int i = 0; i < uextent; i++)
408 size_t vextent,
float epsilon,
int label)
410 if (extBbox.
Min()[1] * m_cylinder.
Radius() <= epsilon
411 && extBbox.
Max()[1] * m_cylinder.
Radius()
416 size_t row = 0, j = 0;
417 for (; j < vextent; ++j)
420 for (
size_t i = 0; i < uextent; ++i)
422 if (componentsImg[row + i] == label)
440 row = (vextent - 1) * uextent, j = 0;
441 for (; j < vextent; ++j)
444 for (
size_t i = 0; i < uextent; ++i)
446 if (componentsImg[row + i] == label)
460 m_minPhi = minj * epsilon / m_cylinder.
Radius() + extBbox.
Min()[1];
461 m_maxPhi = maxj * epsilon / m_cylinder.
Radius() + extBbox.
Min()[1];
465 m_minPhi = extBbox.
Min()[1];
466 m_maxPhi = extBbox.
Max()[1];
489 q.RotationRad((bbox.
Min()[1] + epsilon * (
v + .5f)) / m_cylinder.
Radius(),
virtual void Visit(const PlanePrimitiveShape &plane)=0
void push_back(const T &v)
static size_t SerializedSize()
void RotateAngularDirection(float radians)
void Serialize(bool binary, std::ostream *o) const
float Distance(const Vec3f &p) const
float SignedDistance(const Vec3f &p) const
PrimitiveShape * Clone() const
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
const Vec3f & AxisPosition() const
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 Parameters(const Vec3f &p, std::pair< float, float > *param) const
PrimtiveShape is a shape primitive in conjunction with a parametrization.
void Normal(const Vec3f &p, Vec3f *n) const
void SetExtent(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, const MiscLib::Vector< int > &componentsImg, size_t uextent, size_t vextent, float epsilon, int label)
float Distance(const Vec3f &p) const
bool Init(const Vec3f &pointA, const Vec3f &pointB, const Vec3f &normalA, const Vec3f &normalB)
const typedef Point * const_iterator
void Transform(float scale, const Vec3f &translate)
const Vec3f & AxisDirection() const
LevMarFunc< float > * SignedDistanceFunc() const
void PreWrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, size_t uextent, size_t vextent, MiscLib::Vector< char > *bmp) const
bool Similar(float tolerance, const CylinderPrimitiveShape &shape) const
bool InSpace(float u, float v, Vec3f *p, Vec3f *n) const
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...
bool Fit(const PointCloud &pc, float epsilon, float normalThresh, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
float Distance(const Vec3f &pos) const
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
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
void Project(const Vec3f &p, Vec3f *pp) const
void Project(const Vec3f &p, Vec3f *pp) const
size_t SerializedSize() const
class DLL_LINKAGE SpherePrimitiveShape
GfxTL::AABox< GfxTL::Vector2Df > m_extBbox
const Vec3f AngularDirection() const
void Transform(float scale, const Vec3f &translate)
bool Init(const MiscLib::Vector< Vec3f > &samples)
void Description(std::string *s) const
float NormalDeviation(const Vec3f &p, const Vec3f &n) const
double v(double t, double v0, double a0, double j)
void DistanceAndNormalDeviation(const Vec3f &p, const Vec3f &n, std::pair< float, float > *dn) const
float dot(const Vec3f &v) const
void Visit(PrimitiveShapeVisitor *visitor) const
MiscLib::performance_t totalTime_cylinderConnected
unsigned int ConfidenceTests(unsigned int numTests, float epsilon, float normalThresh, float rms, const PointCloud &pc, const MiscLib::Vector< size_t > &indices) const
size_t Identifier() const
float SignedDistance(const Vec3f &p) 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 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 ...
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
float DistanceAndNormal(const Vec3f &p, Vec3f *normal) const
void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const
float Distance(const Vec3f &p) const
double s(double t, double s0, double v0, double a0, double j)
class DLL_LINKAGE PlanePrimitiveShape
bool Init(const MiscLib::Vector< Vec3f > &samples)
void Normal(const Vec3f &p, Vec3f *normal) const
void Parameters(const Vec3f &p, std::pair< float, float > *param) const
void BitmapExtent(float epsilon, GfxTL::AABox< GfxTL::Vector2Df > *bbox, MiscLib::Vector< std::pair< float, float > > *params, size_t *uextent, size_t *vextent)