Go to the documentation of this file.
35 const std::vector<TPoint3D>& allData;
37 Fit3DPlane(
const std::vector<TPoint3D>& _allData) : allData(_allData) {}
38 size_t getSampleCount(
void)
const {
return allData.size(); }
39 bool fitModel(
const std::vector<size_t>& useIndices,
TPlane3D&
model)
const
41 ASSERT_(useIndices.size() == 3);
73 const size_t N_plane = 300;
74 const size_t N_noise = 100;
76 const double PLANE_EQ[4] = {1, -1, 1, -2};
78 std::vector<TPoint3D>
data;
79 for (
size_t i = 0; i < N_plane; i++)
84 -(PLANE_EQ[3] + PLANE_EQ[0] * xx + PLANE_EQ[1] * yy) / PLANE_EQ[2];
88 for (
size_t i = 0; i < N_noise; i++)
100 std::vector<size_t> best_inliers;
101 const double DIST_THRESHOLD = 0.2;
104 const size_t TIMES = 100;
107 for (
size_t iters = 0; iters < TIMES; iters++)
112 fit, 3, DIST_THRESHOLD, 10, 100, best_model, best_inliers);
114 cout <<
"Computation time (genetic): " << tictac.
Tac() * 1000.0 / TIMES
117 for (
size_t iters = 0; iters < TIMES; iters++)
122 fit, 3, DIST_THRESHOLD, best_model, best_inliers);
124 cout <<
"Computation time (ransac): " << tictac.
Tac() * 1000.0 / TIMES
136 mrpt::make_aligned_shared<opengl::COpenGLScene>();
139 mrpt::make_aligned_shared<opengl::CGridPlaneXY>(
140 -20, 20, -20, 20, 0, 1));
144 mrpt::make_aligned_shared<opengl::CPointCloud>();
145 points->setColor(0, 0, 1);
147 points->enableColorFromZ();
150 std::vector<float>
x,
y,
z;
151 x.reserve(
data.size());
152 y.reserve(
data.size());
153 z.reserve(
data.size());
154 for (
size_t i = 0; i <
data.size(); i++)
166 mrpt::make_aligned_shared<opengl::CTexturedPlane>(-4, 4, -4, 4);
170 glPlane->setPose(glPlanePose);
172 scene->insert(glPlane);
174 win.get3DSceneAndLock() = scene;
175 win.unlockAccess3DScene();
191 catch (std::exception& e)
193 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
198 printf(
"Untyped exception!!");
A high-performance stopwatch, with typical resolution of nanoseconds.
std::shared_ptr< CTexturedPlane > Ptr
GLsizei const GLfloat * points
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Model search implementations: RANSAC and genetic algorithm.
#define ASSERT_(f)
Defines an assertion mechanism.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::shared_ptr< CPointCloud > Ptr
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
double Tac() noexcept
Stops the stopwatch.
GLsizei GLsizei GLenum GLenum const GLvoid * data
double drawUniform(const double Min, const double Max)
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm,...
mrpt::gui::CDisplayWindow3D::Ptr win
void getAsPose3D(mrpt::math::TPose3D &outPose)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
bool geneticSingleModel(const TModelFit &p_state, size_t p_kernelSize, const typename TModelFit::Real &p_fitnessThreshold, size_t p_populationSize, size_t p_maxIteration, typename TModelFit::Model &p_bestModel, std::vector< size_t > &p_inliers)
Run a generic programming version of ransac searching for a single model.
Classes for creating GUI windows for 2D and 3D visualization.
3D Plane, represented by its equation
CSetOfObjects::Ptr CornerXYZ(float scale=1.0)
Returns three arrows representing a X,Y,Z 3D corner.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
This base provides a set of functions for maths stuff.
std::shared_ptr< COpenGLScene > Ptr
A namespace of pseudo-random numbers generators of diferent distributions.
bool ransacSingleModel(const TModelFit &p_state, size_t p_kernelSize, const typename TModelFit::Real &p_fitnessThreshold, typename TModelFit::Model &p_bestModel, std::vector< size_t > &p_inliers)
Run the ransac algorithm searching for a single model.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |