Easy3D 2.6.1
Loading...
Searching...
No Matches
point_cloud_ransac.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_ALGO_POINT_CLOUD_RANSAC_H
28#define EASY3D_ALGO_POINT_CLOUD_RANSAC_H
29
30#include <set>
31#include <easy3d/core/types.h>
32
33
34namespace easy3d {
35
36 class PointCloud;
37
41
53 public:
55 enum PrimType { // Do NOT modify the order!!! Values have to be exactly the same as in RANSAC
56 PLANE = 0,
57 SPHERE = 1,
59 CONE = 3,
60 TORUS = 4,
61 UNKNOWN = -1
62 };
63
64 public:
75
90 int detect(
91 PointCloud *cloud,
92 unsigned int min_support = 1000,
93 float dist_threshold = 0.005f,
94 float bitmap_resolution = 0.02f,
95 float normal_threshold = 0.8f,
96 float overlook_probability = 0.001f
97 );
98
99
117 int detect(
118 PointCloud *cloud,
119 const std::vector<int> &vertices,
120 unsigned int min_support = 1000,
121 float dist_threshold = 0.005f,
122 float bitmap_resolution = 0.02f,
123 float normal_threshold = 0.8f,
124 float overlook_probability = 0.001f
125 );
126
137
140 const std::vector<PlanePrim>& get_planes() const { return plane_primitives_; }
141
152
155 const std::vector<CylinderPrim>& get_cylinders() const { return cylinder_primitives_; }
156
157 private:
158 std::set<PrimType> types_;
159
160 std::vector<PlanePrim> plane_primitives_;
161 std::vector<CylinderPrim> cylinder_primitives_;
162 };
163
164}
165
166
167#endif // EASY3D_ALGO_POINT_CLOUD_RANSAC_H
A data structure for point clouds.
Definition point_cloud.h:45
Extract primitives from point clouds using RANSAC.Usage example:
Definition point_cloud_ransac.h:52
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.
Definition point_cloud_ransac.cpp:242
const std::vector< CylinderPrim > & get_cylinders() const
Definition point_cloud_ransac.h:155
void add_primitive_type(PrimType t)
Set up the primitive types to be extracted.
Definition point_cloud_ransac.cpp:232
void remove_primitive_type(PrimType t)
Exclude a primitive types to be extracted.
Definition point_cloud_ransac.cpp:237
const std::vector< PlanePrim > & get_planes() const
Get the detected planes.
Definition point_cloud_ransac.h:140
PrimType
The primitive types that can be extracted.
Definition point_cloud_ransac.h:55
@ TORUS
Torus primitive.
Definition point_cloud_ransac.h:60
@ PLANE
Plane primitive.
Definition point_cloud_ransac.h:56
@ UNKNOWN
Unknown primitive.
Definition point_cloud_ransac.h:61
@ CYLINDER
Cylinder primitive.
Definition point_cloud_ransac.h:58
@ CONE
Cone primitive.
Definition point_cloud_ransac.h:59
@ SPHERE
Sphere primitive.
Definition point_cloud_ransac.h:57
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
GenericPlane< float > Plane3
A 3D plane of float type.
Definition types.h:103
Information about a cylinder primitive.
Definition point_cloud_ransac.h:145
vec3 position
the position of the cylinder (represented by the center of the bottom circle)
Definition point_cloud_ransac.h:149
int primitive_index
the index of this cylinder (w.r.t. the entire list of detected primitives)
Definition point_cloud_ransac.h:146
float radius
the radius of the cylinder
Definition point_cloud_ransac.h:148
std::vector< int > vertices
the vertex indices (w.r.t. the point cloud) of this cylinder
Definition point_cloud_ransac.h:147
vec3 direction
the direction of the cylinder
Definition point_cloud_ransac.h:150
Information about a plane primitive.
Definition point_cloud_ransac.h:130
vec3 position
the position of the plane (represented by a point on the plane)
Definition point_cloud_ransac.h:134
int primitive_index
the index of this plane (w.r.t. the entire list of detected primitives)
Definition point_cloud_ransac.h:131
vec3 normal
the normal of the plane
Definition point_cloud_ransac.h:135
std::vector< int > vertices
the vertex indices (w.r.t. the point cloud) of this plane
Definition point_cloud_ransac.h:132
Plane3 plane
the plane representation
Definition point_cloud_ransac.h:133