Main MRPT website > C++ reference for MRPT 1.9.9
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /* ===========================================================================
11  EXAMPLE: bundle_adj_full_demo
12  PURPOSE: Demonstrate "mrpt::vision::bundle_adj_full" with a set of
13  simulated or real data. If the program is called without command
14  line arguments, simulated measurements will be used.
15  To use real data, invoke:
16  bundle_adj_full_demo <feats.txt> <cam_model.cfg>
17 
18  Where <feats.txt> is a "TSequenceFeatureObservations" saved as
19  a text file, and <cam_model.cfg> is a .ini-like file with a
20  section named "CAMERA" loadable by mrpt::img::TCamera.
21 
22  DATE: 20-Aug-2010
23  ===========================================================================
24  */
25 
27 #include <mrpt/vision/pinhole.h>
30 #include <mrpt/poses/CPose3DQuat.h>
31 #include <mrpt/random.h>
32 #include <mrpt/math/geometry.h>
33 #include <mrpt/system/filesystem.h>
39 #include <iostream>
40 
41 using namespace mrpt;
42 using namespace mrpt::gui;
43 using namespace mrpt::math;
44 using namespace mrpt::system;
45 using namespace mrpt::opengl;
46 using namespace mrpt::poses;
47 using namespace mrpt::img;
48 using namespace mrpt::vision;
49 using namespace std;
50 
52 
53 double WORLD_SCALE = 1; // Will change when loading SBA examples
54 
55 // A feedback functor, which is called on each iteration by the optimizer to let
56 // us know on the progress:
58  const size_t cur_iter, const double cur_total_sq_error,
59  const size_t max_iters,
60  const TSequenceFeatureObservations& input_observations,
61  const TFramePosesVec& current_frame_estimate,
62  const TLandmarkLocationsVec& current_landmark_estimate)
63 {
64  const double avr_err =
65  std::sqrt(cur_total_sq_error / input_observations.size());
66  history_avr_err.push_back(std::log(1e-100 + avr_err));
67  if ((cur_iter % 10) == 0)
68  {
69  cout << "[PROGRESS] Iter: " << cur_iter
70  << " avrg err in px: " << avr_err << endl;
71  cout.flush();
72  }
73 }
74 
75 // ------------------------------------------------------
76 // bundle_adj_full_demo
77 // ------------------------------------------------------
79  const TCamera& camera_params, const TSequenceFeatureObservations& allObs,
80  TFramePosesVec& frame_poses, TLandmarkLocationsVec& landmark_points)
81 {
82  cout << "Optimizing " << allObs.size() << " feature observations.\n";
83 
84  TParametersDouble extra_params;
85  // extra_params["verbose"] = 1;
86  extra_params["max_iterations"] = 2000; // 250;
87  // extra_params["num_fix_frames"] = 1;
88  // extra_params["num_fix_points"] = 0;
89  extra_params["robust_kernel"] = 0;
90  extra_params["kernel_param"] = 5.0;
91  extra_params["profiler"] = 1;
92 
94  allObs, camera_params, frame_poses, landmark_points, extra_params,
96 }
97 // ---------------------------------------------------------
98 
100  const TFramePosesVec& poses, const double len, const double lineWidth);
101 
102 // ------------------------------------------------------
103 // MAIN
104 // ------------------------------------------------------
105 int main(int argc, char** argv)
106 {
107  try
108  {
109  // Simulation or real-data? (read at the top of this file):
110  if ((argc != 1 && argc != 3 && argc != 4) ||
111  (argc == 2 && !strcpy(argv[1], "--help")))
112  {
113  cout << "Usage:\n"
114  << argv[0] << " --help -> Shows this help\n"
115  << argv[0] << " -> Simulation\n"
116  << argv[0]
117  << " <feats.txt> <cam_model.cfg> -> Data in MRPT format\n"
118  << argv[0]
119  << " <cams.txt> <points.cfg> <calib.txt> -> SBA format\n";
120  return 1;
121  }
122 
123  // BA data:
124  TCamera camera_params;
126  TFramePosesVec frame_poses;
127  TLandmarkLocationsVec landmark_points;
128 
129  // Only for simulation mode:
130  TFramePosesVec frame_poses_real,
131  frame_poses_noisy; // Ground truth & starting point
132  TLandmarkLocationsVec landmark_points_real,
133  landmark_points_noisy; // Ground truth & starting point
134 
135  if (argc == 1)
136  {
137  random::CRandomGenerator rg(1234);
138 
139  // Simulation
140  // --------------------------
141  // The projective camera model:
142  camera_params.ncols = 800;
143  camera_params.nrows = 600;
144  camera_params.fx(400);
145  camera_params.fy(400);
146  camera_params.cx(400);
147  camera_params.cy(300);
148 
149  // Generate synthetic dataset:
150  // -------------------------------------
151  const size_t nPts = 100; // # of 3D landmarks
152  const double L1 =
153  60; // Draw random poses in the rectangle L1xL2xL3
154  const double L2 = 10;
155  const double L3 = 10;
156  const double max_camera_dist = L1 * 4;
157 
158  const double cameraPathLen = L1 * 1.2;
159  // const double cameraPathEllipRadius1 = L1*2;
160  // const double cameraPathEllipRadius2 = L2*2;
161  // Noise params:
162  const double STD_PX_ERROR = 0.10; // pixels
163 
164  const double STD_PX_ERROR_OUTLIER = 5; // pixels
165  const double PROBABILITY_OUTLIERS = 0; // 0.01;
166 
167  const double STD_PT3D = 0.10; // meters
168  const double STD_CAM_XYZ = 0.05; // meters
169  const double STD_CAM_ANG = DEG2RAD(5); // degs
170 
171  landmark_points_real.resize(nPts);
172  for (size_t i = 0; i < nPts; i++)
173  {
174  landmark_points_real[i].x = rg.drawUniform(-L1, L1);
175  landmark_points_real[i].y = rg.drawUniform(-L2, L2);
176  landmark_points_real[i].z = rg.drawUniform(-L3, L3);
177  }
178 
179  // const double angStep = M_PI*2.0/40;
180  const double camPosesSteps = 2 * cameraPathLen / 20;
181  frame_poses_real.clear();
182 
183  for (double x = -cameraPathLen; x < cameraPathLen;
184  x += camPosesSteps)
185  {
186  TPose3D p;
187  p.x = x; // cameraPathEllipRadius1 * cos(ang);
188  p.y = 4 * L2; // cameraPathEllipRadius2 * sin(ang);
189  p.z = 0;
190  p.yaw = DEG2RAD(-90) -
191  DEG2RAD(30) * x / cameraPathLen; // wrapToPi(ang+M_PI);
192  p.pitch = 0;
193  p.roll = 0;
194  // Angles above is for +X pointing to the (0,0,0), but we want
195  // instead +Z pointing there, as typical in camera models:
196  frame_poses_real.push_back(
197  CPose3D(p) +
198  CPose3D(0, 0, 0, DEG2RAD(-90), 0, DEG2RAD(-90)));
199  }
200 
201  // Simulate the feature observations:
202  size_t numOutliers = 0;
203  allObs.clear();
204  map<TCameraPoseID, size_t> numViewedFrom;
205  for (size_t i = 0; i < frame_poses_real.size();
206  i++) // for each pose
207  {
208  // predict all landmarks:
209  for (size_t j = 0; j < landmark_points_real.size(); j++)
210  {
211  TPixelCoordf px =
213  false>(
214  camera_params, frame_poses_real[i],
215  landmark_points_real[j]);
216 
217  const bool is_outlier =
218  (rg.drawUniform(0.0, 1.0) < PROBABILITY_OUTLIERS);
219  px.x += rg.drawGaussian1D(
220  0, is_outlier ? STD_PX_ERROR_OUTLIER : STD_PX_ERROR);
221  px.y += rg.drawGaussian1D(
222  0, is_outlier ? STD_PX_ERROR_OUTLIER : STD_PX_ERROR);
223 
224  // Out of image?
225  if (px.x < 0 || px.y < 0 || px.x > camera_params.ncols ||
226  px.y > camera_params.nrows)
227  continue;
228 
229  // Too far?
230  const double dist = math::distance(
231  TPoint3D(frame_poses_real[i].asTPose()),
232  landmark_points_real[j]);
233  if (dist > max_camera_dist) continue;
234 
235  // Ok, accept it:
236  if (is_outlier) numOutliers++;
237  allObs.push_back(TFeatureObservation(j, i, px));
238  numViewedFrom[i]++;
239  }
240  }
241  cout << "Simulated: " << allObs.size()
242  << " observations (of which: " << numOutliers
243  << " are outliers).\n";
244 
245  ASSERT_EQUAL_(numViewedFrom.size(), frame_poses_real.size());
246  // Make sure all poses and all LMs appear at least once!
247  {
248  TSequenceFeatureObservations allObs2 = allObs;
249  std::map<TCameraPoseID, TCameraPoseID> old2new_camIDs;
250  std::map<TLandmarkID, TLandmarkID> old2new_lmIDs;
251  allObs2.compressIDs(&old2new_camIDs, &old2new_lmIDs);
252 
253  ASSERT_EQUAL_(old2new_camIDs.size(), frame_poses_real.size());
255  old2new_lmIDs.size(), landmark_points_real.size());
256  }
257 
258  // Add noise to the data:
259  frame_poses_noisy = frame_poses_real;
260  landmark_points_noisy = landmark_points_real;
261  for (size_t i = 0; i < landmark_points_noisy.size(); i++)
262  landmark_points_noisy[i] += TPoint3D(
263  rg.drawGaussian1D(0, STD_PT3D),
264  rg.drawGaussian1D(0, STD_PT3D),
265  rg.drawGaussian1D(0, STD_PT3D));
266 
267  for (size_t i = 1; i < frame_poses_noisy.size();
268  i++) // DON'T add error to frame[0], the global reference!
269  {
270  CPose3D bef = frame_poses_noisy[i];
271  frame_poses_noisy[i].setFromValues(
272  frame_poses_noisy[i].x() +
273  rg.drawGaussian1D(0, STD_CAM_XYZ),
274  frame_poses_noisy[i].y() +
275  rg.drawGaussian1D(0, STD_CAM_XYZ),
276  frame_poses_noisy[i].z() +
277  rg.drawGaussian1D(0, STD_CAM_XYZ),
278  frame_poses_noisy[i].yaw() +
279  rg.drawGaussian1D(0, STD_CAM_ANG),
280  frame_poses_noisy[i].pitch() +
281  rg.drawGaussian1D(0, STD_CAM_ANG),
282  frame_poses_noisy[i].roll() +
283  rg.drawGaussian1D(0, STD_CAM_ANG));
284  }
285 
286  // Optimize it:
287  frame_poses = frame_poses_noisy;
288  landmark_points = landmark_points_noisy;
289 
290 #if 0
291  vector<std::array<double,2> > resids;
292  const double initial_total_sq_err = mrpt::vision::reprojectionResiduals(allObs,camera_params,frame_poses, landmark_points,resids, false);
293  cout << "Initial avr error in px: " << std::sqrt(initial_total_sq_err/allObs.size()) << endl;
294 #endif
295 
296  // Run Bundle Adjustmen
298  camera_params, allObs, frame_poses, landmark_points);
299 
300  // Evaluate vs. ground truth:
301  double landmarks_total_sq_err = 0;
302  for (size_t i = 0; i < landmark_points.size(); i++)
303  landmarks_total_sq_err += square(
304  landmark_points_real[i].distanceTo(landmark_points[i]));
305 
306  double cam_point_total_sq_err = 0;
307  for (size_t i = 0; i < frame_poses.size(); i++)
308  cam_point_total_sq_err +=
309  square(frame_poses[i].distanceTo(frame_poses_real[i]));
310 
311  cout << "RMSE of recovered landmark positions: "
312  << std::sqrt(landmarks_total_sq_err / landmark_points.size())
313  << endl;
314  cout << "RMSE of recovered camera positions: "
315  << std::sqrt(cam_point_total_sq_err / frame_poses.size())
316  << endl;
317  }
318  else
319  {
320  // Real data
321  // --------------------------
322  if (argc == 3)
323  {
324  const string feats_fil = string(argv[1]);
325  const string cam_fil = string(argv[2]);
326 
327  cout << "Loading observations from: " << feats_fil << "...";
328  cout.flush();
329  allObs.loadFromTextFile(feats_fil);
330  cout << "Done.\n";
331 
332  allObs.decimateCameraFrames(20);
333  allObs.compressIDs();
334 
336  cout << "Loading camera params from: " << cam_fil;
337  mrpt::config::CConfigFile cfgCam(cam_fil);
338  camera_params.loadFromConfigFile("CAMERA", cfgCam);
339  cout << "Done.\n";
340 
341  cout << "Initial gross estimate...";
343  allObs, camera_params, frame_poses, landmark_points);
344  cout << "OK\n";
345  }
346  else
347  {
348  // Load data from 3 files in the same format as used by
349  // "eucsbademo" in the SBA library:
350  const string cam_frames_fil = string(argv[1]);
351  const string obs_fil = string(argv[2]);
352  const string calib_fil = string(argv[3]);
353 
354  {
355  cout << "Loading initial camera frames from: "
356  << cam_frames_fil << "...";
357  cout.flush();
358 
359  mrpt::io::CTextFileLinesParser fil(cam_frames_fil);
360  frame_poses.clear();
361 
362  std::istringstream ss;
363  while (fil.getNextLine(ss))
364  {
365  double q[4], t[3];
366  ss >> q[0] >> q[1] >> q[2] >> q[3] >> t[0] >> t[1] >>
367  t[2];
369  t[0], t[1], t[2], mrpt::math::CQuaternionDouble(
370  q[0], q[1], q[2], q[3]));
371  // cout << "cam: " << p << endl;
372  frame_poses.push_back(CPose3D(p));
373  }
374 
375  cout << "Done. " << frame_poses.size()
376  << " cam frames loaded\n";
377 
378  frame_poses_noisy = frame_poses; // To draw in 3D the
379  // initial values as well.
380  }
381 
382  {
383  cout << "Loading observations & feature 3D points from: "
384  << obs_fil << "...";
385  cout.flush();
386 
387  mrpt::io::CTextFileLinesParser fil(obs_fil);
388  landmark_points.clear();
389  allObs.clear();
390 
391  std::istringstream ss;
392  while (fil.getNextLine(ss))
393  {
394  // # X Y Z nframes frame0 x0 y0 frame1 x1 y1 ...
395  double t[3];
396  size_t N = 0;
397  ss >> t[0] >> t[1] >> t[2] >> N;
398 
399  const TLandmarkID feat_id = landmark_points.size();
400  const TPoint3D pt(t[0], t[1], t[2]);
401  landmark_points.push_back(pt);
402 
403  // Read obs:
404  for (size_t i = 0; i < N; i++)
405  {
406  TCameraPoseID frame_id;
407  TPixelCoordf px;
408  ss >> frame_id >> px.x >> px.y;
409  allObs.push_back(
410  TFeatureObservation(feat_id, frame_id, px));
411  // cout << "feat: " << feat_id << " cam: " <<
412  // frame_id << " px: " << px.x << "," << px.y <<
413  // endl;
414  }
415  }
416 
417  cout << "Done. " << landmark_points.size() << " points, "
418  << allObs.size() << " observations read.\n";
419 
420  landmark_points_real = landmark_points; // To draw in 3D
421  // the initial
422  // values as well.
423  }
424 
425  CMatrixDouble33 cam_pars;
426  cam_pars.loadFromTextFile(calib_fil);
427 
428  // cout << "Calib:\n" << cam_pars << endl;
429 
430  camera_params.fx(cam_pars(0, 0));
431  camera_params.fy(cam_pars(1, 1));
432  camera_params.cx(cam_pars(0, 2));
433  camera_params.cy(cam_pars(1, 2));
434 
435  cout << "camera calib:\n" << camera_params.dumpAsText() << endl;
436 
437  // Change world scale:
438  WORLD_SCALE = 2000;
439  }
440 
441  // Do it:
443  camera_params, allObs, frame_poses, landmark_points);
444  }
445 
446  // Display results in 3D:
447  // -------------------------------
448  gui::CDisplayWindow3D win("Bundle adjustment demo", 800, 600);
449 
450  COpenGLScene::Ptr& scene = win.get3DSceneAndLock();
451 
452  { // Ground plane:
453  CGridPlaneXY::Ptr obj = mrpt::make_aligned_shared<CGridPlaneXY>(
454  -200, 200, -200, 200, 0, 5);
455  obj->setColor(0.7, 0.7, 0.7);
456  scene->insert(obj);
457  }
458 
459  if (!landmark_points_real.empty())
460  { // Feature points: ground truth
461  CPointCloud::Ptr obj = mrpt::make_aligned_shared<CPointCloud>();
462  obj->setPointSize(2);
463  obj->setColor(0, 0, 0);
464  obj->loadFromPointsList(landmark_points_real);
465  obj->setScale(WORLD_SCALE);
466  scene->insert(obj);
467  }
468  if (!landmark_points_noisy.empty())
469  { // Feature points: noisy
470  CPointCloud::Ptr obj = mrpt::make_aligned_shared<CPointCloud>();
471  obj->setPointSize(4);
472  obj->setColor(0.7, 0.2, 0.2, 0);
473  obj->loadFromPointsList(landmark_points_noisy);
474  obj->setScale(WORLD_SCALE);
475  scene->insert(obj);
476  }
477 
478  { // Feature points: estimated
479  CPointCloud::Ptr obj = mrpt::make_aligned_shared<CPointCloud>();
480  obj->setPointSize(3);
481  obj->setColor(0, 0, 1, 1.0);
482  obj->loadFromPointsList(landmark_points);
483  obj->setScale(WORLD_SCALE);
484  scene->insert(obj);
485  }
486 
487  // Camera Frames: estimated
488  scene->insert(framePosesVecVisualize(frame_poses_noisy, 1.0, 1));
489  scene->insert(framePosesVecVisualize(frame_poses_real, 2.0, 1));
490  scene->insert(framePosesVecVisualize(frame_poses, 2.0, 3));
491 
492  win.setCameraZoom(100);
493 
494  win.unlockAccess3DScene();
495  win.repaint();
496 
497  // Also, show history of error:
498  gui::CDisplayWindowPlots winPlot(
499  "Avr log-error with iterations", 500, 200);
500  // winPlot.setPos(0,620);
501  winPlot.plot(history_avr_err, "b.3");
502  winPlot.axis_fit();
503 
504  cout << "Close the 3D window or press a key to exit.\n";
505  win.waitForKey();
506 
507  return 0;
508  }
509  catch (std::exception& e)
510  {
511  std::cout << "MRPT exception caught: " << e.what() << std::endl;
512  return -1;
513  }
514  catch (...)
515  {
516  printf("Untyped exception!!");
517  return -1;
518  }
519 }
520 
522  const TFramePosesVec& poses, const double len, const double lineWidth)
523 {
525  mrpt::make_aligned_shared<mrpt::opengl::CSetOfObjects>();
526 
527  for (size_t i = 0; i < poses.size(); i++)
528  {
529  CSetOfObjects::Ptr corner =
531  CPose3D p = poses[i];
532  p.x(WORLD_SCALE * p.x());
533  p.y(WORLD_SCALE * p.y());
534  p.z(WORLD_SCALE * p.z());
535  corner->setPose(p);
536  corner->setName(format("%u", (unsigned int)i));
537  corner->enableShowName();
538  obj->insert(corner);
539  }
540  return obj;
541 }
mrpt::img::TPixelCoordf
A pair (x,y) of pixel coordinates (subpixel resolution).
Definition: TPixelCoord.h:20
mrpt::opengl::CGridPlaneXY::Ptr
std::shared_ptr< CGridPlaneXY > Ptr
Definition: CGridPlaneXY.h:34
filesystem.h
mrpt::vision::TFramePosesVec
mrpt::aligned_std_vector< mrpt::poses::CPose3D > TFramePosesVec
A list of camera frames (6D poses), which assumes indexes are unique, consecutive IDs.
Definition: vision/include/mrpt/vision/types.h:38
bundle_adjustment.h
mrpt::vision::bundle_adj_full
double bundle_adj_full(const mrpt::vision::TSequenceFeatureObservations &observations, const mrpt::img::TCamera &camera_params, mrpt::vision::TFramePosesVec &frame_poses, mrpt::vision::TLandmarkLocationsVec &landmark_points, const mrpt::system::TParametersDouble &extra_params=mrpt::system::TParametersDouble(), const mrpt::vision::TBundleAdjustmentFeedbackFunctor user_feedback=mrpt::vision::TBundleAdjustmentFeedbackFunctor())
Sparse Levenberg-Marquart solution to bundle adjustment - optimizes all the camera frames & the landm...
Definition: ba_full.cpp:51
q
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
mrpt::vision::TSequenceFeatureObservations::loadFromTextFile
void loadFromTextFile(const std::string &filName)
Load from a text file, in the format described in saveToTextFile.
Definition: types.cpp:51
geometry.h
t
GLdouble GLdouble t
Definition: glext.h:3689
ASSERT_EQUAL_
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:153
mrpt::img::TCamera::fx
double fx() const
Get the value of the focal length x-value (in pixels).
Definition: TCamera.h:165
CTextFileLinesParser.h
mrpt::math::dynamic_vector
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:44
mrpt::vision
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:20
mrpt::random::CRandomGenerator
A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator.
Definition: RandomGenerators.h:47
mrpt::poses::CPose3D::setFromValues
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
Definition: CPose3D.cpp:239
mrpt::vision::TLandmarkLocationsVec
std::vector< mrpt::math::TPoint3D > TLandmarkLocationsVec
A list of landmarks (3D points), which assumes indexes are unique, consecutive IDs.
Definition: vision/include/mrpt/vision/types.h:44
CConfigFile.h
mrpt::img::TCamera::ncols
uint32_t ncols
Camera resolution.
Definition: TCamera.h:41
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
mrpt::vision::TLandmarkID
uint64_t TLandmarkID
Unique IDs for landmarks.
Definition: vision/include/mrpt/vision/types.h:29
mrpt::vision::TSequenceFeatureObservations
A complete sequence of observations of features from different camera frames (poses).
Definition: vision/include/mrpt/vision/types.h:189
mrpt::vision::pinhole::projectPoint_no_distortion
mrpt::img::TPixelCoordf projectPoint_no_distortion(const mrpt::img::TCamera &cam_params, const mrpt::poses::CPose3D &F, const mrpt::math::TPoint3D &P)
Project a single 3D point with global coordinates P into a camera at pose F, without distortion param...
Definition: pinhole.h:64
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::math::distance
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
Definition: geometry.cpp:1891
mrpt::poses::CPose3DQuat
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
Definition: CPose3DQuat.h:48
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
stock_objects.h
CPointCloud.h
mrpt::opengl::stock_objects::CornerXYZSimple
CSetOfObjects::Ptr CornerXYZSimple(float scale=1.0, float lineWidth=1.0)
Returns three arrows representing a X,Y,Z 3D corner (just thick lines instead of complex arrows for f...
Definition: StockObjects.cpp:419
p
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::square
T square(const T x)
Inline function for the square of a number.
Definition: core/include/mrpt/core/bits_math.h:18
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::system::fileExists
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
Definition: filesystem.cpp:127
mrpt::img::TCamera::cy
double cy() const
Get the value of the principal point y-coordinate (in pixels).
Definition: TCamera.h:163
mrpt::opengl::CPointCloud::Ptr
std::shared_ptr< CPointCloud > Ptr
Definition: CPointCloud.h:50
CDisplayWindow3D.h
mrpt::vision::reprojectionResiduals
double reprojectionResiduals(const mrpt::vision::TSequenceFeatureObservations &observations, const mrpt::img::TCamera &camera_params, const mrpt::vision::TFramePosesVec &frame_poses, const mrpt::vision::TLandmarkLocationsVec &landmark_points, std::vector< std::array< double, 2 >> &out_residuals, const bool frame_poses_are_inverse, const bool use_robust_kernel=true, const double kernel_param=3.0, std::vector< double > *out_kernel_1st_deriv=nullptr)
Compute reprojection error vector (used from within Bundle Adjustment methods, but can be used in gen...
Definition: ba_common.cpp:205
random.h
my_BundleAdjustmentFeedbackFunctor
void my_BundleAdjustmentFeedbackFunctor(const size_t cur_iter, const double cur_total_sq_error, const size_t max_iters, const TSequenceFeatureObservations &input_observations, const TFramePosesVec &current_frame_estimate, const TLandmarkLocationsVec &current_landmark_estimate)
Definition: vision_stereo_rectify/test.cpp:57
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::img::TCamera::fy
double fy() const
Get the value of the focal length y-value (in pixels).
Definition: TCamera.h:167
mrpt::vision::TSequenceFeatureObservations::compressIDs
void compressIDs(std::map< TCameraPoseID, TCameraPoseID > *old2new_camIDs=nullptr, std::map< TLandmarkID, TLandmarkID > *old2new_lmIDs=nullptr)
Rearrange frame and feature IDs such as they start at 0 and there are no gaps.
Definition: types.cpp:207
mrpt::vision::TCameraPoseID
uint64_t TCameraPoseID
Unique IDs for camera frames (poses)
Definition: vision/include/mrpt/vision/types.h:31
mrpt::vision::ba_initial_estimate
void ba_initial_estimate(const mrpt::vision::TSequenceFeatureObservations &observations, const mrpt::img::TCamera &camera_params, mrpt::vision::TFramePosesVec &frame_poses, mrpt::vision::TLandmarkLocationsVec &landmark_points)
Fills the frames & landmark points maps with an initial gross estimate from the sequence observations...
Definition: ba_common.cpp:74
mrpt::img
Definition: CCanvas.h:17
mrpt::img::TCamera::cx
double cx() const
Get the value of the principal point x-coordinate (in pixels).
Definition: TCamera.h:161
win
mrpt::gui::CDisplayWindow3D::Ptr win
Definition: vision_stereo_rectify/test.cpp:31
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
mrpt::system::TParameters< double >
mrpt::img::TCamera::nrows
uint32_t nrows
Definition: TCamera.h:41
WORLD_SCALE
double WORLD_SCALE
Definition: vision_stereo_rectify/test.cpp:53
mrpt::poses::CPoseOrPoint::x
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
pinhole.h
CPose3DQuat.h
mrpt::math::TPose3D
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: lightweight_geom_data.h:603
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
mrpt::system::os::strcpy
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
Definition: os.cpp:297
len
GLenum GLsizei len
Definition: glext.h:4712
mrpt::opengl::CSetOfObjects::Ptr
std::shared_ptr< CSetOfObjects > Ptr
Definition: CSetOfObjects.h:30
mrpt::gui
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:16
mrpt::math::CMatrixFixedNumeric< double, 3, 3 >
mrpt::gui::CDisplayWindowPlots
Create a GUI window and display plots with MATLAB-like interfaces and commands.
Definition: CDisplayWindowPlots.h:31
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::vision::TFeatureObservation
One feature observation entry, used within sequences with TSequenceFeatureObservations.
Definition: vision/include/mrpt/vision/types.h:137
mrpt::math::CQuaternion
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ,...
Definition: CQuaternion.h:46
mrpt::config::CConfigFile
This class allows loading and storing values and vectors of different types from "....
Definition: config/CConfigFile.h:33
mrpt::io::CTextFileLinesParser
A class for parsing text files, returning each non-empty and non-comment line, along its line number.
Definition: CTextFileLinesParser.h:26
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
mrpt::img::TPixelCoordf::y
float y
Definition: TPixelCoord.h:25
bundle_adj_full_demo
void bundle_adj_full_demo(const TCamera &camera_params, const TSequenceFeatureObservations &allObs, TFramePosesVec &frame_poses, TLandmarkLocationsVec &landmark_points)
Definition: vision_stereo_rectify/test.cpp:78
history_avr_err
CVectorDouble history_avr_err
Definition: vision_stereo_rectify/test.cpp:51
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::opengl::COpenGLScene::Ptr
std::shared_ptr< COpenGLScene > Ptr
Definition: COpenGLScene.h:61
mrpt::img::TPixelCoordf::x
float x
Definition: TPixelCoord.h:25
framePosesVecVisualize
mrpt::opengl::CSetOfObjects::Ptr framePosesVecVisualize(const TFramePosesVec &poses, const double len, const double lineWidth)
Definition: vision_stereo_rectify/test.cpp:521
CDisplayWindowPlots.h
mrpt::vision::TSequenceFeatureObservations::decimateCameraFrames
void decimateCameraFrames(const size_t decimate_ratio)
Remove all but one out of decimate_ratio camera frame IDs from the list (eg: from N camera pose IDs a...
Definition: types.cpp:172
CGridPlaneXY.h
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
mrpt::gui::CDisplayWindow3D
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Definition: CDisplayWindow3D.h:117
x
GLenum GLint x
Definition: glext.h:3538
mrpt::system
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:25
mrpt::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: core/include/mrpt/core/bits_math.h:42



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