Easy3D 2.6.1
Loading...
Searching...
No Matches
PrimitivesRansac Class Reference

Extract primitives from point clouds using RANSAC.Usage example: More...

#include <easy3d/algo/point_cloud_ransac.h>

Classes

struct  CylinderPrim
 Information about a cylinder primitive. More...
 
struct  PlanePrim
 Information about a plane primitive. More...
 

Public Types

enum  PrimType {
  PLANE = 0 , SPHERE = 1 , CYLINDER = 2 , CONE = 3 ,
  TORUS = 4 , UNKNOWN = -1
}
 The primitive types that can be extracted. More...
 

Public Member Functions

void add_primitive_type (PrimType t)
 Set up the primitive types to be extracted.
 
void remove_primitive_type (PrimType t)
 Exclude a primitive types to be extracted.
 
int detect (PointCloud *cloud, unsigned int min_support=1000, float dist_threshold=0.005f, float bitmap_resolution=0.02f, float normal_threshold=0.8f, float overlook_probability=0.001f)
 Extract primitives from a point cloud.
 
int detect (PointCloud *cloud, const std::vector< int > &vertices, unsigned int min_support=1000, float dist_threshold=0.005f, float bitmap_resolution=0.02f, float normal_threshold=0.8f, float overlook_probability=0.001f)
 Extract primitives from a subset of a point cloud.
 
const std::vector< PlanePrim > & get_planes () const
 Get the detected planes.
 
const std::vector< CylinderPrim > & get_cylinders () const
 

Detailed Description

Extract primitives from point clouds using RANSAC.

Usage example:

Todo: (1) redesign the APIs (2) allow all five types of primitives (and support parameters)

ransac.add_primitive_type(PrimitivesRansac::PLANE);
int num = ransac.detect(cloud);
Extract primitives from point clouds using RANSAC.Usage example:
Definition point_cloud_ransac.h:52
@ PLANE
Plane primitive.
Definition point_cloud_ransac.h:56
Examples
Tutorial_703_Cloud_PlaneExtraction/main.cpp.

Member Enumeration Documentation

◆ PrimType

enum PrimType

The primitive types that can be extracted.

Enumerator
PLANE 

Plane primitive.

SPHERE 

Sphere primitive.

CYLINDER 

Cylinder primitive.

CONE 

Cone primitive.

TORUS 

Torus primitive.

UNKNOWN 

Unknown primitive.

Member Function Documentation

◆ add_primitive_type()

void add_primitive_type ( PrimType t)

Set up the primitive types to be extracted.

This is done by adding the interested primitive types one by one.

Examples
Tutorial_703_Cloud_PlaneExtraction/main.cpp.

◆ detect() [1/2]

int detect ( PointCloud * cloud,
const std::vector< int > & vertices,
unsigned int min_support = 1000,
float dist_threshold = 0.005f,
float bitmap_resolution = 0.02f,
float normal_threshold = 0.8f,
float overlook_probability = 0.001f )

Extract primitives from a subset of a point cloud.

The extracted primitives are stored as per-vertex properties:

  • "v:primitive_type" (one of PLANE, SPHERE, CYLINDER, CONE, TORUS, and UNKNOWN)
  • "v:primitive_index" (-1, 0, 1, 2...). -1 meaning a vertex does not belong to any primitive (thus its primitive_type must be UNKNOWN). In addition to the primitive information stored as properties, the parameters of the detected primitives can also be queried using this functions.
    See also
    get_planes, get_cylinders.
    Parameters
    cloudThe input point cloud.
    verticesThe indices of the subset of the input point cloud.
    min_supportThe minimal number of points required for a primitive.
    dist_thresholdThe distance threshold, defined relative to the bounding box's max dimension.
    bitmap_resolutionThe bitmap resolution, defined relative to the bounding box width.
    normal_thresholdThe cosine of the maximal normal deviation.
    overlook_probabilityThe probability with which a primitive is overlooked.
    Returns
    The number of extracted primitives.

◆ detect() [2/2]

int detect ( PointCloud * cloud,
unsigned int min_support = 1000,
float dist_threshold = 0.005f,
float bitmap_resolution = 0.02f,
float normal_threshold = 0.8f,
float overlook_probability = 0.001f )

Extract primitives from a point cloud.

The extracted primitives are stored as properties:

  • "v:primitive_type" (one of PLANE, SPHERE, CYLINDER, CONE, TORUS, and UNKNOWN)
  • "v:primitive_index" (-1, 0, 1, 2...). -1 meaning a vertex does not belong to any primitive (thus its primitive_type must be UNKNOWN).
    Parameters
    cloudThe input point cloud.
    min_supportThe minimal number of points required for a primitive.
    dist_thresholdThe distance threshold, defined relative to the bounding box's max dimension.
    bitmap_resolutionThe bitmap resolution, defined relative to the bounding box width.
    normal_thresholdThe cosine of the maximal normal deviation.
    overlook_probabilityThe probability with which a primitive is overlooked.
    Returns
    The number of extracted primitives.
Examples
Tutorial_703_Cloud_PlaneExtraction/main.cpp.

◆ get_cylinders()

const std::vector< CylinderPrim > & get_cylinders ( ) const
inline

Get the detected cylinders.

◆ remove_primitive_type()

void remove_primitive_type ( PrimType t)

Exclude a primitive types to be extracted.

This is done by removing the primitive type from the existing list.


The documentation for this class was generated from the following files: