libstereo-odometry (C++ Library for robust Stereo odometry)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
libstereo-odometry.h
Go to the documentation of this file.
1 /* +-------------------------------------------------------------------------+
2  | Robust Stereo Odometry library |
3  | (libstereo-odometry) |
4  | |
5  | Copyright (C) 2012 Jose-Luis Blanco-Claraco, Francisco-Angel Moreno |
6  | and Javier Gonzalez-Jimenez |
7  | |
8  | This program is free software: you can redistribute it and/or modify |
9  | it under the terms of the GNU General Public License as published by |
10  | the Free Software Foundation, either version 3 of the License, or |
11  | (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20  +-------------------------------------------------------------------------+ */
21 
22 #pragma once
23 
28 // opencv
29 #include <opencv2/opencv.hpp>
30 #include <opencv2/core/version.hpp>
31 #if CV_MAJOR_VERSION < 3 // OpenCV < 3.0.0
32  #include <opencv2/highgui/highgui.hpp>
33  #include <opencv2/imgproc/imgproc.hpp>
34  #include <opencv2/features2d/features2d.hpp>
35 #else // OpenCV >= 3.0.0
36  #include <opencv2/highgui.hpp>
37  #include <opencv2/imgproc.hpp>
38  #include <opencv2/features2d.hpp>
39 #endif
40 
41 // mrpt
42 #include <mrpt/utils/CImage.h>
43 #include <mrpt/utils/CConfigFile.h>
44 #include <mrpt/utils/CTimeLogger.h>
45 
50 
51 #include <mrpt/poses/CPose3D.h>
53 
54 #include <mrpt/math/CMatrixB.h>
56 
57 #include <mrpt/system/filesystem.h>
58 #include <mrpt/system/os.h>
59 #include <mrpt/system/threads.h>
60 
64 
65 #include <mrpt/version.h>
66 #if MRPT_VERSION>=0x130
67 # include <mrpt/obs/CObservationStereoImages.h>
68 #else
69 # include <mrpt/slam/CObservationStereoImages.h>
70 #endif
71 
72 #include <fstream>
73 #define SQUARE(_X) _X*_X
74 #define INVALID_IDX -1
75 #define DUMP_BOOL_VAR(_B) _B ? cout << "Yes" : cout << "No"; cout << endl;
76 #define SHOW_WARNING(MSG) cout << "[Visual Odometry] " << MSG << endl;
77 #define DUMP_VO_ERROR_CODE( _CODE ) \
78  cout << "[sVO] ERROR: "; \
79  switch( _CODE ) { case voecBadCondNumber : cout << "(LS) Bad Condition Number" << endl; break; \
80  case voecIncrFuncCostStg1 : cout << "(LS) (Initial) Function cost increased too many times" << endl; break; \
81  case voecIncrFuncCostStg2 : cout << "(LS) (Final) Function cost increased too many times" << endl; break; \
82  case voecFirstIteration : cout << "First iteration, no change in pose can be computed" << endl; break; \
83  case voecBadTracking : cout << "Number of tracked features is low " << endl; break; \
84  case voecNone : default : cout << "None" << endl; break; }
85 #define DUMP_VECTOR(_V) \
86  for(size_t k = 0; k < _V.size()-1; ++k) \
87  cout << _V[k] << ","; \
88  cout << _V[_V.size()-1] << endl;
89 
91 namespace rso
92 {
93  using namespace std;
94  using namespace mrpt::vision;
95  using namespace mrpt::utils;
96  using namespace mrpt::math;
97  using namespace mrpt::poses;
98  using namespace mrpt::system;
99 
100 #if MRPT_VERSION>=0x130
102  using mrpt::obs::CObservationStereoImagesPtr;
103 #else
104  using mrpt::slam::CObservationStereoImages;
105  using mrpt::slam::CObservationStereoImagesPtr;
106 #endif
107 
108  typedef std::vector<cv::KeyPoint> TKeyPointList;
109  typedef std::vector<cv::DMatch> TDMatchList;
110 
111  struct KpRadiusSorter : public std::binary_function<size_t,size_t,bool>
112  {
113  const std::vector<double> & m_radius_data;
114  KpRadiusSorter( const std::vector<double> & radius_data ) : m_radius_data( radius_data ) { }
115  bool operator() (size_t k1, size_t k2 ) const {
116  return ( m_radius_data[k1] > m_radius_data[k2] );
117  }
118  };
119  // from lowest to highest row
120  struct KpRowSorter : public std::binary_function<size_t,size_t,bool>
121  {
123  KpRowSorter( const TKeyPointList & data ) : m_data( data ) { }
124  bool operator() (size_t k1, size_t k2 ) const {
125  return (m_data[k1].pt.y < m_data[k2].pt.y);
126  }
127  }; // end -- KpRowSorter
128 
129  typedef struct t_change_in_pose_output {
131  std::vector<double> out_residual;
132  unsigned int num_gn_iterations;
134 
135  t_change_in_pose_output() : change_in_pose( mrpt::poses::CPose3D() ), out_residual( std::vector<double>() ), num_gn_iterations( 0 ), num_gn_final_iterations( 0 ) {}
136 
138 
139  typedef std::vector<std::pair<size_t,size_t> > vector_index_pairs_t;
140  typedef std::vector<std::pair<mrpt::utils::TPixelCoord,mrpt::utils::TPixelCoord> > vector_pixel_pairs_t;
141 
143 
148  {
149  public:
150  struct TStereoOdometryRequest; // Forward decl. (declaration below)
151  struct TStereoOdometryResult; // Forward decl. (declaration below)
152 
153  //---------------------------------------------------------------
157  void processNewImagePair(
158  TStereoOdometryRequest & request_data,
159  TStereoOdometryResult & result );
160 
162  bool getChangeInPose(
163  const vector_index_pairs_t & tracked_pairs,
164  const vector<cv::DMatch> & pre_matches,
165  const vector<cv::DMatch> & cur_matches,
166  const vector<cv::KeyPoint> & pre_left_feats,
167  const vector<cv::KeyPoint> & pre_right_feats,
168  const vector<cv::KeyPoint> & cur_left_feats,
169  const vector<cv::KeyPoint> & cur_right_feats,
170  const mrpt::utils::TStereoCamera & stereo_camera,
171  TStereoOdometryResult & result, // output
172  const vector<double> & ini_estimation = vector<double>(6,0) ); // initial estimation of the pose (if any)
173 
174  // this custom method computes the coords of a set of features after a change in pose
175  void getProjectedCoords(
176  const vector<cv::DMatch> & pre_matches, // all the matches in the previous keyframe
177  const vector<cv::KeyPoint> & pre_left_feats,
178  const vector<cv::KeyPoint> & pre_right_feats, // all the features in the previuous keyframe
179  const vector< pair<int,float> > & other_matches_tracked, // tracking info for OTHER matches [size=A]
180  const mrpt::utils::TStereoCamera & stereo_camera, // stereo camera intrinsic and extrinsic parameters
181  const CPose3D & change_pose, // the estimated change in pose between keyframes
182  vector< pair<TPixelCoordf,TPixelCoordf> > & pro_pre_feats ); // [out] coords of the features in the left image [size=B (only for those whose 'other_matches_tracked' entry is false]
183 
184  bool saveStateToFile( const string & filename ); // returns false on error
185  bool loadStateFromFile( const string & filename ); // returns false on error
186 
187  void inline dumpToConsole()
188  {
189  cout << "---------------------------------------------------------" << endl;
190  cout << " Visual Odometry parameters" << endl;
191  cout << "---------------------------------------------------------" << endl;
192  params_general.dumpToConsole();
193  params_rectify.dumpToConsole();
194  params_detect.dumpToConsole();
195  params_lr_match.dumpToConsole();
196  params_least_squares.dumpToConsole();
197  params_gui.dumpToConsole();
198  }
199  // End of main API methods
201  //---------------------------------------------------------------
206  {
208  CObservationStereoImagesPtr stereo_imgs;
209 
212 
215  vector<TKeyPointList> *precomputed_left_feats, *precomputed_right_feats;
216  vector<cv::Mat> *precomputed_left_desc, *precomputed_right_desc;
217  vector<TDMatchList> *precomputed_matches;
218  vector< vector<size_t> > *precomputed_matches_ID;
219 
221  bool repeat;
222 
223  TStereoOdometryRequest() : stereo_imgs(),
224  stereo_cam(),
225  use_precomputed_data(false),
226  precomputed_left_feats(NULL),
227  precomputed_right_feats(NULL),
228  precomputed_left_desc(NULL),
229  precomputed_right_desc(NULL),
230  precomputed_matches(NULL),
231  precomputed_matches_ID(NULL),
232  repeat(false) {}
233  };
234 
236  {
237  // least square results
239  vector<size_t> outliers;
240  vector<double> out_residual;
241  int num_it, num_it_final;
242 
243  bool valid;
246  tracked_feats_from_last_frame;
247 
248  vector< pair<size_t,size_t> > detected_feats;
249  vector<size_t> stereo_matches;
250 
252  outPose(CPose3D()),
253  outliers(vector<size_t>()),
254  out_residual(vector<double>()),
255  num_it(0),
256  num_it_final(0),
257  valid(false),
258  error_code(voecNone),
259  tracked_feats_from_last_KF(0),
260  tracked_feats_from_last_frame(0),
261  detected_feats(),
262  stereo_matches()
263  { }
264  };
265 
267  {
268  TGeneralParams();
271  bool vo_debug;
272  bool vo_pause_it;
273  string vo_out_dir;
274 
276  {
277  cout << " [GENERAL] Track the IDs of the matches?: "; vo_use_matches_ids ? cout << "Yes" : cout << "No"; cout << endl;
278  cout << " [GENERAL] Save information files?: "; vo_save_files ? cout << "Yes" : cout << "No"; cout << endl;
279  cout << " [GENERAL] Debug?: "; vo_debug ? cout << "Yes" : cout << "No"; cout << endl;
280  cout << " [GENERAL] Pause after each iteration?: "; vo_pause_it ? cout << "Yes" : cout << "No"; cout << endl;
281  cout << " [GENERAL] Output directory: " << vo_out_dir << endl;
282  }
283  };
284 
286  {
287  MRPT_TODO("Set default values for these parameters and check unused ones")
288  MRPT_TODO("Implement fundamental matrix rejection for IF matches")
289 
291  enum TIFMMethod {ifmDescBF = 0, ifmDescWin, ifmSAD, ifmOpticalFlow };
293 
294  int ifm_win_w, ifm_win_h;
295 
296  // SAD
297  uint32_t sad_max_distance;
298  double sad_max_ratio;
299 
300  // ORB
302 
303  // General
305 
307  {
308 
309  }
310  };
311 
314  {
316 
317  // Parameters for optimize_*()
318  // -------------------------------------
320  double kernel_param;
321 
322  size_t max_iters;
326  size_t max_incr_cost;
331  // -------------------------------------
332 
334  {
335  cout << " [LS] Use Robust Kernel?: "; use_robust_kernel ? cout << "Yes" : cout << "No"; cout << endl;
336  if( use_robust_kernel ) cout << " [LS] Robust kernel param: " << kernel_param << endl;
337 
338  cout << " [LS] Use previous estimated pose as initial pose?: "; use_previous_pose_as_initial ? cout << "Yes" : cout << "No"; cout << endl;
339 
340  cout << " [LS] Initial maximum number of iterations: " << initial_max_iters << endl;
341  cout << " [LS] Final maximum number of iterations: " << max_iters << endl;
342  cout << " [LS] Minimum modulus of the step output vector to continue iterating: " << min_mod_out_vector << endl;
343  cout << " [LS] Maximum allowed number of times the cost can grow: " << max_incr_cost << endl;
344 
345  cout << " [LS] STD noise for the feature coordinates: " << std_noise_pixels << endl;
346  cout << " [LS] Residual threshold for detecting outliers: " << residual_threshold << endl;
347 
348  cout << " [LS] Minimum number of tracked features to yield a tracking error: " << bad_tracking_th << endl;
349  }
350  };
351 
354  {
355  TRectifyParams();
356  int nOctaves;
357 
359  {
360  cout << " [RECTIFY] Number of octaves: " << nOctaves << endl;
361  }
362  };
363 
365  struct TGUIParams
366  {
367  TGUIParams();
368  bool show_gui;
372 
374  {
375  cout << " [GUI] Show GUI?: "; show_gui ? cout << "Yes" : cout << "No"; cout << endl;
376  cout << " [GUI] Draw Raw Features?: "; draw_all_raw_feats ? cout << "Yes" : cout << "No"; cout << endl;
377  cout << " [GUI] Draw Stereo Matches?: "; draw_lr_pairings ? cout << "Yes" : cout << "No"; cout << endl;
378  cout << " [GUI] Draw Tracked Matches?: "; draw_tracking ? cout << "Yes" : cout << "No"; cout << endl;
379  }
380  };
381 
384  {
385  TDetectParams();
386 
387  enum NMSMethod { nmsmStandard, nmsmAdaptive };
388  enum TDMethod { dmORB, dmFAST_ORB, dmFASTER, dmKLT };
389 
391 
392  // General
394 
395  // KLT
396  int KLT_win;
398 
399  // Non-maximal suppression
402  size_t min_distance;
403 
404  // ORB + FAST
405  size_t orb_nfeats;
406  size_t orb_nlevels;
408  int fast_min_th, fast_max_th;
410 
412  {
413  cout << " [DETECT] Detection method: ";
414  switch( detect_method )
415  {
416  case dmFASTER : cout << "FASTER" << endl; break;
417  case dmORB :
418  cout << "ORB" << endl;
419  cout << " [DETECT] Number of desired ORB features: " << orb_nfeats << endl;
420  cout << " [DETECT] Number of desired ORB levels in scale space: " << orb_nlevels << endl;
421  cout << " [DETECT] Minimum ORB (Harris) response to consider a feature: " << minimum_ORB_response << endl;
422  cout << " [DETECT] FAST threshold limits: " << fast_min_th << ":" << fast_max_th << endl;
423  break;
424  case dmFAST_ORB :
425  cout << "FAST + ORB" << endl;
426  cout << " [DETECT] Desired number of features per square pixel: " << target_feats_per_pixel << endl;
427  cout << " [DETECT] Initial FAST threshold: " << initial_FAST_threshold << endl;
428  cout << " [DETECT] FAST threshold limits: " << fast_min_th << ":" << fast_max_th << endl;
429  cout << " [DETECT] Window for the KLT response evaluation: " << KLT_win << endl;
430  cout << " [DETECT] Minimum KLT response to consider a feature: " << minimum_KLT_response << endl;
431  break;
432  case dmKLT :
433  cout << "KLT" << endl;
434  cout << " [DETECT] Minimum KLT response to consider a feature: " << minimum_KLT_response << endl;
435  break;
436  }
437  cout << " [DETECT] Perform Non Maximal Suppression (NMS)?: ";
438  DUMP_BOOL_VAR(non_maximal_suppression)
439  cout << " [DETECT] NMS Method: ";
440  switch( nmsMethod )
441  {
442  case nmsmStandard : cout << "Standard" << endl; break;
443  case nmsmAdaptive : cout << "Adaptive" << endl; break;
444  }
445  cout << " [DETECT] Allowed minimum distance between features: " << min_distance << endl;
446  }
447  };
448 
450  {
452 
453  // Stereo matching method enumeration
454  enum TSMMethod { smDescBF = 0, smDescRbR, smSAD };
456 
457  // SAD
458  uint32_t sad_max_distance;
459  double sad_max_ratio;
460 
461  // ORB
463  int orb_min_th, orb_max_th;
464 
465  // GENERAL
468  double max_y_diff;
469  double min_z, max_z;
470 
472  {
473  cout << " [MATCH] Method: ";
474  switch( match_method )
475  {
476  case smSAD :
477  cout << "SAD" << endl;
478  cout << " [MATCH] Maximum Sum of Absolute Differences (SAD): " << sad_max_distance << endl;
479  cout << " [MATCH] Maximum SAD ratio: " << sad_max_ratio << endl;
480  break;
481  case smDescBF :
482  cout << "Descriptor (Brute-force)" << endl;
483  cout << " [MATCH] Maximum ORB distance: " << orb_max_distance << endl;
484  cout << " [MATCH] ORB distance limits: " << orb_min_th << "/" << orb_max_th << endl;
485  break;
486  case smDescRbR :
487  cout << "Descriptor (Row-by-row) -- requires row-ordered keypoint vector (from top to bottom)" << endl;
488  cout << " [MATCH] Maximum ORB distance: " << orb_max_distance << endl;
489  cout << " [MATCH] ORB distance limits: " << orb_min_th << "/" << orb_max_th << endl;
490  break;
491  }
492  cout << " [MATCH] Enable robust 1 to 1 match?: ";
493  DUMP_BOOL_VAR(enable_robust_1to1_match)
494  cout << " [MATCH] Stereo pair has parallel optical axes?: ";
495  DUMP_BOOL_VAR(rectified_images)
496  if( rectified_images ) cout << " [MATCH] Maximum 'y' distance allowed between matched features: " << max_y_diff << endl;
497  cout << " [MATCH] Min/Max value for the Z coordinate of 3D feature to be considered: " << min_z << "/" << max_z << endl;
498  }
499  };
500 
509 
510  // End of data fields
512  //---------------------------------------------------------------
513 
516 
519 
521  void inline enable_time_profiler(bool enable=true) { m_profiler.enable(enable); }
522 
524  inline mrpt::utils::CTimeLogger & get_time_profiler() { return m_profiler; }
525 
527  inline void setVerbosityLevel(int level) { m_verbose_level = level; }
528 
530  inline int getFASTThreshold( ) { return m_current_fast_th; }
531  inline void setFASTThreshold( int value ) { m_current_fast_th = std::min(params_detect.fast_max_th,std::max(params_detect.fast_min_th,value)); }
532  inline void resetFASTThreshold( ) { m_current_fast_th = params_detect.initial_FAST_threshold; }
533  inline bool isFASTThMin( ) { return m_current_fast_th == params_detect.fast_min_th; }
534  inline bool isFASTThMax( ) { return m_current_fast_th == params_detect.fast_max_th; }
535 
537  inline int getORBThreshold( ) { return m_current_orb_th; }
538  inline void setORBThreshold( int value ) { m_current_orb_th = std::min(params_lr_match.orb_max_th,std::max(params_lr_match.orb_min_th,value)); }
539  inline void resetORBThreshold( ) { m_current_orb_th = params_lr_match.orb_max_distance;}
540  inline bool isORBThMin( ) { return m_current_orb_th == params_lr_match.orb_min_th; }
541  inline bool isORBThMax( ) { return m_current_orb_th == params_lr_match.orb_max_th; }
542 
543  bool keyPressedOnGUI();
544 
549  int getKeyPressedOnGUI();
550 
554  void loadParamsFromConfigFile( const mrpt::utils::CConfigFile &iniFile, const std::vector<std::string> &sections)
555  {
556  ASSERT_(sections.size() == 7) // one section for type of params:
557 
558  if( sections[0].size() > 0 ) // rectify
559  params_rectify.nOctaves = iniFile.read_int(sections[0], "nOctaves", params_rectify.nOctaves, false);
560 
561  if( sections[1].size() > 0 ) // detection
562  {
563  // general
564  params_detect.detect_method = static_cast<TDetectParams::TDMethod>( iniFile.read_int(sections[1], "detect_method", params_detect.detect_method, false) );
565  params_detect.min_distance = iniFile.read_int(sections[1], "min_distance",params_detect.min_distance,false);
566 
567  // fast
568  params_detect.target_feats_per_pixel = iniFile.read_double(sections[1], "target_feats_per_pixel", params_detect.target_feats_per_pixel, false);
569  params_detect.initial_FAST_threshold = iniFile.read_int(sections[1], "initial_FAST_threshold", params_detect.initial_FAST_threshold, false);
570  params_detect.fast_min_th = iniFile.read_int(sections[1], "fast_min_th",params_detect.fast_min_th,false);
571  params_detect.fast_max_th = iniFile.read_int(sections[1], "fast_max_th",params_detect.fast_max_th,false);
572 
573  // KLT
574  params_detect.KLT_win = iniFile.read_int(sections[1], "KLT_win", params_detect.KLT_win, false);
575  params_detect.minimum_KLT_response = iniFile.read_double(sections[1], "minimum_KLT_response", params_detect.minimum_KLT_response, false);
576 
577  // orb
578  params_detect.orb_nfeats = iniFile.read_int(sections[1], "orb_nfeats",params_detect.orb_nfeats,false);
579  params_detect.orb_nlevels = iniFile.read_int(sections[1], "orb_nlevels",params_detect.orb_nlevels,false);
580  params_detect.minimum_ORB_response = iniFile.read_double(sections[1], "minimum_ORB_response", params_detect.minimum_ORB_response, false);
581 
582  // non-max-sup
583  params_detect.non_maximal_suppression = iniFile.read_bool(sections[1], "non_maximal_suppression", params_detect.non_maximal_suppression, false);
584  params_detect.nmsMethod = static_cast<TDetectParams::NMSMethod>( iniFile.read_int(sections[1], "non_max_supp_method", params_detect.nmsMethod, false) );
585  }
586 
587  if( sections[2].size() > 0 ) // left right matching
588  {
589  // general
590  params_lr_match.match_method = static_cast<TLeftRightMatchParams::TSMMethod>(iniFile.read_int(sections[2], "match_method", params_lr_match.match_method, false) );
591  params_lr_match.max_y_diff = iniFile.read_double(sections[2], "max_y_diff", params_lr_match.max_y_diff, false);
592  params_lr_match.enable_robust_1to1_match = iniFile.read_bool(sections[2], "enable_robust_1to1_match", params_lr_match.enable_robust_1to1_match, false);
593  params_lr_match.rectified_images = iniFile.read_bool(sections[2], "rectified_images", params_lr_match.rectified_images, false);
594  params_lr_match.min_z = iniFile.read_double(sections[2], "min_z", params_lr_match.min_z, false);
595  params_lr_match.max_z = iniFile.read_double(sections[2], "max_z", params_lr_match.max_z, false);
596 
597  // sda - limits
598  params_lr_match.sad_max_ratio = iniFile.read_double(sections[2], "sad_max_ratio", params_lr_match.sad_max_ratio, false);
599  params_lr_match.sad_max_distance = iniFile.read_int(sections[2], "sad_max_distance", params_lr_match.sad_max_distance, false);
600 
601  // orb - limits
602  params_lr_match.orb_min_th = iniFile.read_int(sections[2], "orb_min_th", params_lr_match.orb_min_th, false);
603  params_lr_match.orb_max_th = iniFile.read_int(sections[2], "orb_max_th", params_lr_match.orb_max_th, false);
604  params_lr_match.orb_max_distance = iniFile.read_double(sections[2], "orb_max_distance", params_lr_match.orb_max_distance, false);
605  }
606 
607  if( sections[3].size() > 0 ) // inter-frame matching
608  {
609  // general
610  params_if_match.ifm_method = static_cast<TInterFrameMatchingParams::TIFMMethod>( iniFile.read_int(sections[3], "if_match_method", 0, false) );
611  params_if_match.filter_fund_matrix = iniFile.read_bool(sections[3], "filter_fund_matrix", params_if_match.filter_fund_matrix, false);
612 
613  // window - limits
614  params_if_match.ifm_win_h = iniFile.read_int(sections[3], "window_height", params_if_match.ifm_win_h, false);
615  params_if_match.ifm_win_w = iniFile.read_int(sections[3], "window_width", params_if_match.ifm_win_w, false);
616 
617  // sad - limits
618  params_if_match.sad_max_ratio = iniFile.read_double(sections[3], "sad_max_ratio", params_if_match.sad_max_ratio, false);
619  params_if_match.sad_max_distance = iniFile.read_int(sections[3], "sad_max_distance", params_if_match.sad_max_distance, false);
620 
621  // orb - limits
622  params_if_match.orb_max_distance = iniFile.read_double(sections[3], "orb_max_distance", params_if_match.orb_max_distance, false);;
623  }
624 
625  if( sections[4].size() > 0 ) // least squares
626  {
627  // general
628  params_least_squares.std_noise_pixels = iniFile.read_double(sections[4], "std_noise_pixels", params_least_squares.std_noise_pixels, false);
629  params_least_squares.use_previous_pose_as_initial = iniFile.read_bool(sections[4], "use_previous_pose_as_initial", params_least_squares.use_previous_pose_as_initial, false);
630 
631  params_least_squares.initial_max_iters = iniFile.read_int(sections[4], "initial_max_iters", params_least_squares.initial_max_iters, false);
632  params_least_squares.max_iters = iniFile.read_int(sections[4], "max_iters", params_least_squares.max_iters, false);
633 
634  params_least_squares.min_mod_out_vector = iniFile.read_double(sections[4], "min_mod_out_vector", params_least_squares.min_mod_out_vector, false);
635  params_least_squares.max_incr_cost = iniFile.read_int(sections[4], "max_incr_cost", params_least_squares.max_incr_cost, false);
636  params_least_squares.residual_threshold = iniFile.read_double(sections[4], "residual_threshold", params_least_squares.residual_threshold, false);
637  params_least_squares.bad_tracking_th = iniFile.read_int(sections[4], "bad_tracking_th", params_least_squares.bad_tracking_th, false);
638 
639  // robust kernel
640  params_least_squares.use_robust_kernel = iniFile.read_bool(sections[4], "use_robust_kernel", params_least_squares.use_robust_kernel, false);
641  params_least_squares.kernel_param = iniFile.read_double(sections[4], "kernel_param", params_least_squares.kernel_param, false);
642  }
643 
644  if( sections[5].size() > 0 ) // GUI
645  {
646  params_gui.show_gui = iniFile.read_bool(sections[5], "show_gui", params_gui.show_gui, false);
647  params_gui.draw_all_raw_feats = iniFile.read_bool(sections[5], "draw_all_raw_feats", params_gui.draw_all_raw_feats, false);
648  params_gui.draw_lr_pairings = iniFile.read_bool(sections[5], "draw_lr_pairings", params_gui.draw_lr_pairings, false);
649  params_gui.draw_tracking = iniFile.read_bool(sections[5], "draw_tracking", params_gui.draw_tracking, false);
650  }
651 
652  if( sections[6].size() > 0 ) // GENERAL
653  {
654  params_general.vo_use_matches_ids = iniFile.read_bool(sections[6], "vo_use_matches_ids", params_general.vo_use_matches_ids, false);
655  params_general.vo_save_files = iniFile.read_bool(sections[6], "vo_save_files", params_general.vo_save_files, false);
656  params_general.vo_debug = iniFile.read_bool(sections[6], "vo_debug", params_general.vo_debug, false);
657  params_general.vo_pause_it = iniFile.read_bool(sections[6], "vo_pause_it", params_general.vo_pause_it, false);
658  params_general.vo_out_dir = iniFile.read_string(sections[6], "vo_out_dir", params_general.vo_out_dir, false );
659  }
660 
661  resetFASTThreshold();
662  resetORBThreshold();
663  }
664 
666  void loadParamsFromConfigFileName( const std::string &fileName, const std::vector<std::string> &sections )
667  {
668  // ORDER: Rectify, detect, match, least_squares, gui
669  ASSERT_(mrpt::system::fileExists(fileName))
670  mrpt::utils::CConfigFile iniFile(fileName);
671  loadParamsFromConfigFile(iniFile,sections);
672  } // end loadParamsFromConfigFileName
673 
675  void inline setThisFrameAsKF()
676  {
677  ASSERTMSG_(m_current_imgpair,"[VO Error -- setThisFrameAsKF] Current frame does not exist")
678  ASSERTMSG_(m_current_imgpair->lr_pairing_data.size() > 0,"[VO Error -- setThisFrameAsKF] No existing lr_pairing_data")
679 
680  const size_t octave = 0;
681  const vector<size_t> & v = m_current_imgpair->lr_pairing_data[octave].matches_IDs;
682  m_last_kf_max_id = *std::max_element(v.begin(),v.end());
683  }
684  void inline resetIds() { m_reset = true; }
685  void inline setIds( const vector<size_t> & ids ) { // only for ORB (since it is just one scale)
686  if( m_current_imgpair ) {
687  m_current_imgpair->lr_pairing_data[0].matches_IDs.resize(ids.size());
688  std::copy(ids.begin(), ids.end(), m_current_imgpair->lr_pairing_data[0].matches_IDs.begin());
689  }
690  else {
691  m_prev_imgpair->lr_pairing_data[0].matches_IDs.resize(ids.size());
692  std::copy(ids.begin(), ids.end(), m_prev_imgpair->lr_pairing_data[0].matches_IDs.begin());
693  }
694  } // end-setIds
695 
696  CImage & getRefCurrentImageLeft() { return params_gui.show_gui ? m_gui_info->img_left : m_next_gui_info->img_left; }
697  CImage & getRefCurrentImageRight() { return params_gui.show_gui ? m_gui_info->img_right : m_next_gui_info->img_right; }
698  CImage getCopyCurrentImageLeft() { CImage aux; params_gui.show_gui ? aux.copyFromForceLoad(m_gui_info->img_left) : aux.copyFromForceLoad(m_next_gui_info->img_left); return aux; }
699  CImage getCopyCurrentImageRight() { CImage aux; params_gui.show_gui ? aux.copyFromForceLoad(m_gui_info->img_right) : aux.copyFromForceLoad(m_next_gui_info->img_right); return aux; }
700 
701  vector<size_t> & getRefCurrentIDs(const size_t octave) { return m_current_imgpair->lr_pairing_data[octave].matches_IDs; }
702 
704  void getValues( vector<cv::KeyPoint> & leftKP, vector<cv::KeyPoint> & rightKP,
705  cv::Mat &leftDesc, cv::Mat &rightDesc,
706  vector<cv::DMatch> & matches,
707  vector<size_t> & matches_id )
708  {
709  const size_t octave = 0; // only for ORB features
710  leftKP.resize( m_current_imgpair->left.pyr_feats_kps[octave].size() );
711  std::copy( m_current_imgpair->left.pyr_feats_kps[octave].begin(), m_current_imgpair->left.pyr_feats_kps[octave].end(), leftKP.begin() );
712 
713  rightKP.resize( m_current_imgpair->right.pyr_feats_kps[octave].size() );
714  std::copy( m_current_imgpair->right.pyr_feats_kps[octave].begin(), m_current_imgpair->right.pyr_feats_kps[octave].end(), rightKP.begin() );
715 
716  m_current_imgpair->left.pyr_feats_desc[octave].copyTo( leftDesc );
717  m_current_imgpair->right.pyr_feats_desc[octave].copyTo( rightDesc );
718 
719  matches.resize( m_current_imgpair->lr_pairing_data[octave].matches_lr_dm.size() );
720  std::copy( m_current_imgpair->lr_pairing_data[octave].matches_lr_dm.begin(), m_current_imgpair->lr_pairing_data[octave].matches_lr_dm.end(), matches.begin() );
721 
722  matches_id.resize( m_current_imgpair->lr_pairing_data[octave].matches_IDs.size() );
723  std::copy( m_current_imgpair->lr_pairing_data[octave].matches_IDs.begin(), m_current_imgpair->lr_pairing_data[octave].matches_IDs.end(), matches_id.begin() );
724  } // end getValues
725 
726  inline void setMaxMatchID( const size_t id ){ m_last_match_ID = id; }
727 
728  private:
733  size_t m_lastID;
734 
735  // matches id management (if 'params_general.vo_use_matches_ids' is set)
739  bool m_reset;
740  vector< vector<size_t> > m_kf_ids;
743 
744  // orb method: fast detector and orb matching (dynamic) thresholds
747 
750  // ------------------------------------------------------------------------------------------------------------
751 
753  unsigned int m_it_counter;
754  vector<double> m_last_computed_pose;
755 
757  {
758  struct img_data_t
759  {
761  std::vector<mrpt::vision::TSimpleFeatureList> pyr_feats;
762  std::vector<TKeyPointList> pyr_feats_kps;
763  std::vector<mrpt::vector_size_t> pyr_feats_index;
764  std::vector<cv::Mat> pyr_feats_desc;
765 
766  // orb based:
767  std::vector<cv::KeyPoint> orb_feats; // <----- to be deleted -- //!< ORB based feats, one vector for all the octaves
768  cv::Mat orb_desc; // <----- to be deleted -- //!< ORB based descriptors
769  };
770 
771  mrpt::system::TTimeStamp timestamp;
773 
775  {
780 
785 
789  std::vector<size_t> matches_lr_row_index;
790 
794  std::vector<size_t> matches_IDs;
795 
796  };
797 
799  std::vector<img_pairing_data_t> lr_pairing_data;
800 
802  std::vector<cv::DMatch> orb_matches; // <----- to be deleted
803 
805  std::vector<size_t> orb_matches_ID; // <----- to be deleted
806 
808  size_t img_h, img_w;
809 
810  TImagePairData() : timestamp(INVALID_TIMESTAMP), img_h(0), img_w(0) { }
811  };
812 
814 
816  {
818  const TImagePairData *prev_imgpair, *cur_imgpair;
819 
823  std::vector<vector_index_pairs_t> tracked_pairs;
824  };
825 
829  TImagePairDataPtr m_current_imgpair, m_prev_imgpair;
831  std::vector<int> m_threshold;
832 
835  void m_update_indexes( TImagePairData::img_data_t & data, size_t octave, const bool order );
836 
839  void m_featlist_to_kpslist( CStereoOdometryEstimator::TImagePairData::img_data_t & img_data );
840 
843  void m_adaptive_non_max_sup(
844  const size_t & num_out_points,
845  const vector<cv::KeyPoint> & keypoints,
846  const cv::Mat & descriptors,
847  vector<cv::KeyPoint> & out_kp_rad,
848  cv::Mat & out_kp_desc,
849  const double & min_radius_th = 0 );
850 
853  void m_non_max_sup(
854  const size_t & num_out_points,
855  const vector<cv::KeyPoint> & keypoints,
856  const cv::Mat & descriptors,
857  vector<cv::KeyPoint> & out_kp_rad,
858  cv::Mat & out_kp_desc,
859  const size_t & imgH,
860  const size_t & imgW,
861  vector<bool> & survivors );
862 
865  void m_non_max_sup(
866  const vector<cv::KeyPoint> & keypoints, // IN
867  vector<bool> & survivors, // IN/OUT
868  const size_t & imgH, // IN
869  const size_t & imgW, // IN
870  const size_t & num_out_points ) const; // IN
871 
874  bool m_evalRGN(
875  const TKeyPointList & list1_l, // input -- left image coords at time 't'
876  const TKeyPointList & list1_r, // input -- right image coords at time 't'
877  const TKeyPointList & list2_l, // input -- left image coords at time 't+1'
878  const TKeyPointList & list2_r, // input -- right image coords at time 't+1'
879  const vector<bool> & mask, // input -- true/false: use/do not use corresponding keypoint
880  const vector<TPoint3D> & lmks, // input -- projected 'list1_x' points in 3D (computed outside just once)
881  const vector<double> & deltaPose, // input -- (w1,w2,w3,t1,t2,t3)
882  const mrpt::utils::TStereoCamera & stereoCam, // input -- stereo camera parameters
883  Eigen::MatrixXd & out_newPose, // output
884  Eigen::MatrixXd & out_gradient,
885  vector<double> & out_residual,
886  double & out_cost,
887  VOErrorCode & out_error_code );
888 
889  void m_pinhole_stereo_projection(
890  const vector<TPoint3D> &lmks, // [input] the input 3D landmarks
891  const TStereoCamera &cam, // [input] the stereo camera
892  const vector<double> &delta_pose, // [input] the tested movement of the camera
893  vector< pair<TPixelCoordf,TPixelCoordf> > &out_pixels, // [output] the pixels of the landmarks in the (left & right) images
894  vector<Eigen::MatrixXd> &out_jacobian);
895 
896  // Save to stream methods
898  bool m_dump_keypoints_to_stream(
899  std::ofstream & stream,
900  const vector<cv::KeyPoint> & keypoints,
901  const cv::Mat & descriptors );
902 
904  bool m_dump_matches_to_stream(
905  std::ofstream & stream,
906  const vector<cv::DMatch> & matches,
907  const vector<size_t> & matches_ids );
908 
909  bool m_load_keypoints_from_stream(
910  std::ifstream & stream,
911  vector<cv::KeyPoint> & keypoints,
912  cv::Mat & descriptors );
913 
914  bool m_load_matches_from_stream(
915  std::ifstream & stream,
916  vector<cv::DMatch> & matches,
917  vector<size_t> & matches_ids );
918 
919  inline bool m_jacobian_is_good( Eigen::MatrixXd & jacobian )
920  {
921  for( int r = 0; r < jacobian.rows(); ++r ) {
922  for( int c = 0; c < jacobian.cols(); ++c ) {
923  if( mrpt::math::isNaN(jacobian(r,c)) || !mrpt::math::isFinite(jacobian(r,c)) )
924  return false;
925  }
926  }
927  return true;
928  }
929 
930  void m_filter_by_fundmatrix(
931  const vector<cv::Point2f> & prevPts,
932  const vector<cv::Point2f> & nextPts,
933  vector<uchar> & status ) const;
934 
935  //---------------------------------------------------------------
940  void thread_gui();
943 
948 
950  {
951  mrpt::utils::TPixelCoord px_pL, px_pR, px_cL, px_cR;
952  };
953 
955  {
956  mrpt::system::TTimeStamp timestamp;
958  std::vector<int> stats_feats_per_octave;
960  std::vector<TTrackedPixels> stats_tracked_feats;
962  std::string text_msg_from_detect;
966 
968  vector<size_t> draw_pairings_ids;
969 
972  {
973  std::swap(timestamp, o.timestamp);
974  img_left.swap(o.img_left);
975  img_right.swap(o.img_right);
976  stats_feats_per_octave.swap(o.stats_feats_per_octave);
977  stats_FAST_thresholds_per_octave.swap(o.stats_FAST_thresholds_per_octave);
978  std::swap(stats_tracked_feats, o.stats_tracked_feats);
979  text_msg_from_lr_match.swap(o.text_msg_from_lr_match);
980  text_msg_from_detect.swap(o.text_msg_from_detect);
981  text_msg_from_conseq_match.swap(o.text_msg_from_conseq_match);
982  text_msg_from_optimization.swap(o.text_msg_from_optimization);
983  draw_pairings_all.swap(o.draw_pairings_all);
984  draw_pairings_ids.swap(o.draw_pairings_ids);
985  std::swap(inc_pose, o.inc_pose);
986  }
987  TInfoForTheGUI();
988  };
989 
994  TInfoForTheGUI m_gui_info_cache[2];
996 
1000 
1002  //---------------------------------------------------------------
1003 
1009  void stage1_prepare_rectify(
1010  TStereoOdometryRequest & in_imgs,
1011  TImagePairData & out_imgpair
1012  );
1013 
1017  void stage2_detect_features(
1018  TImagePairData::img_data_t & img_data,
1019  mrpt::utils::CImage & gui_image,
1020  bool update_dyn_thresholds = false );
1021 
1025  void stage3_match_left_right(
1027  const TStereoCamera & stereoCamera );
1028 
1033  void stage4_track(
1034  TTrackingData & out_tracked_feats,
1035  TImagePairData & prev_imgpair,
1036  TImagePairData & cur_imgpair );
1037 
1041  void stage5_optimize(
1042  TTrackingData & out_tracked_feats,
1043  const mrpt::utils::TStereoCamera & stereoCam,
1044  TStereoOdometryResult & result,
1045  const vector<double> & initial_estimation = vector<double>(6,0) );
1046 
1047  }; // end of class "CStereoOdometryEstimator"
1048 
1049 } // end of namespace
std::vector< cv::KeyPoint > orb_feats
Definition: libstereo-odometry.h:767
bool isORBThMax()
Definition: libstereo-odometry.h:541
void dumpToConsole()
Definition: libstereo-odometry.h:306
CImage & getRefCurrentImageLeft()
Definition: libstereo-odometry.h:696
std::vector< cv::Mat > pyr_feats_desc
ORB Descriptors of the features.
Definition: libstereo-odometry.h:764
cv::Mat orb_desc
Definition: libstereo-odometry.h:768
Definition: libstereo-odometry.h:147
std::vector< size_t > matches_lr_row_index
Definition: libstereo-odometry.h:789
bool enable_robust_1to1_match
Only match if a pair of L/R features have the best match score to each other (default: false) ...
Definition: libstereo-odometry.h:466
CImage getCopyCurrentImageRight()
Definition: libstereo-odometry.h:699
void dumpToConsole()
Definition: libstereo-odometry.h:373
mrpt::synch::CCriticalSection m_gui_info_cs
Definition: libstereo-odometry.h:999
int getORBThreshold()
Definition: libstereo-odometry.h:537
int m_current_fast_th
Definition: libstereo-odometry.h:745
std::vector< cv::DMatch > TDMatchList
Definition: libstereo-odometry.h:109
double minimum_KLT_response
Minimum KLT response to not to discard a feature as being in a textureless zone (Default: 10) ...
Definition: libstereo-odometry.h:397
int KLT_win
Window for the KLT response evaluation (Default: 4)
Definition: libstereo-odometry.h:396
void setThisFrameAsKF()
Definition: libstereo-odometry.h:675
Definition: libstereo-odometry.h:815
bool vo_debug
(def:false) Set/Unset showing application debugging info
Definition: libstereo-odometry.h:271
void resetORBThreshold()
Definition: libstereo-odometry.h:539
void dumpToConsole()
Definition: libstereo-odometry.h:411
unsigned int num_gn_iterations
Definition: libstereo-odometry.h:132
KpRadiusSorter(const std::vector< double > &radius_data)
Definition: libstereo-odometry.h:114
bool isFASTThMax()
Definition: libstereo-odometry.h:534
int ifm_win_w
Definition: libstereo-odometry.h:294
size_t orb_nfeats
Number of features to be detected (only for ORB)
Definition: libstereo-odometry.h:405
double minimum_ORB_response
Minimum ORB response [Harris response] to not to discard a feature as being in a textureless zone (De...
Definition: libstereo-odometry.h:407
#define DUMP_BOOL_VAR(_B)
Definition: libstereo-odometry.h:75
double min_z
Definition: libstereo-odometry.h:469
bool draw_tracking
Default = true.
Definition: libstereo-odometry.h:371
double std_noise_pixels
(def:1) – The standard deviation assumed for feature coordinates (this parameter is only needed to sc...
Definition: libstereo-odometry.h:325
void copyFromForceLoad(const CImage &o)
void dumpToConsole()
Definition: libstereo-odometry.h:471
bool vo_use_matches_ids
(def:false) Set/Unset tracking of the IDs of the matches through time
Definition: libstereo-odometry.h:269
Definition: libstereo-odometry.h:142
CPose3D inc_pose
Definition: libstereo-odometry.h:965
size_t img_w
Definition: libstereo-odometry.h:808
TRectifyParams params_rectify
Definition: libstereo-odometry.h:502
std::string text_msg_from_optimization
Definition: libstereo-odometry.h:964
rso::vector_pixel_pairs_t draw_pairings_all
Definition: libstereo-odometry.h:967
const std::vector< double > & m_radius_data
Definition: libstereo-odometry.h:113
void setIds(const vector< size_t > &ids)
Definition: libstereo-odometry.h:685
stlplus::smart_ptr< TImagePairData > TImagePairDataPtr
Definition: libstereo-odometry.h:813
std::vector< cv::DMatch > orb_matches
Definition: libstereo-odometry.h:802
TSMMethod
Definition: libstereo-odometry.h:454
int initial_FAST_threshold
The initial threshold of the FAST feature detector, which will be dynamically adapted to fulfill targ...
Definition: libstereo-odometry.h:409
vector< size_t > outliers
outliers in each octave after optimization : includes NMS and residual thresholding (idx of current m...
Definition: libstereo-odometry.h:239
TStereoOdometryResult()
Definition: libstereo-odometry.h:251
int getFASTThreshold()
Definition: libstereo-odometry.h:530
bool vo_pause_it
(def:false) Set/Unset pausing the application after each iteration
Definition: libstereo-odometry.h:272
vector< double > m_last_computed_pose
Definition: libstereo-odometry.h:754
CObservationStereoImagesPtr stereo_imgs
Definition: libstereo-odometry.h:208
vector< vector< size_t > > * precomputed_matches_ID
Definition: libstereo-odometry.h:218
void resetIds()
Definition: libstereo-odometry.h:684
double sad_max_ratio
The maximum ratio between the two smallest SAD when searching for pairings (Default: 0...
Definition: libstereo-odometry.h:298
void setORBThreshold(int value)
Definition: libstereo-odometry.h:538
Definition: libstereo-odometry.h:313
TInfoForTheGUI * m_next_gui_info
Definition: libstereo-odometry.h:993
std::vector< int > stats_feats_per_octave
Definition: libstereo-odometry.h:958
bool read_bool(const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
double max_y_diff
Maximum allowed distance in pixels from the same row in the images for corresponding feats...
Definition: libstereo-odometry.h:468
mrpt::utils::CImage img_left
Definition: libstereo-odometry.h:957
size_t m_num_tracked_pairs_from_last_frame
Definition: libstereo-odometry.h:737
mrpt::system::TTimeStamp timestamp
Definition: libstereo-odometry.h:771
size_t m_last_match_ID
Identificator of the last match ID.
Definition: libstereo-odometry.h:741
double residual_threshold
(def:10) – Residual threshold for detecting outliers
Definition: libstereo-odometry.h:327
bool use_robust_kernel
(def:true) – Set/Unset using robust kernel for optimization
Definition: libstereo-odometry.h:319
std::vector< size_t > matches_IDs
Definition: libstereo-odometry.h:794
TDMethod detect_method
Method to detect features (also affects to the matching process)
Definition: libstereo-odometry.h:390
bool isFASTThMin()
Definition: libstereo-odometry.h:533
#define MRPT_TODO(x)
int orb_min_th
Definition: libstereo-odometry.h:463
string vo_out_dir
(def:'out') Sets the output directory for saving debug files
Definition: libstereo-odometry.h:273
Definition: libstereo-odometry.h:449
struct rso::t_change_in_pose_output t_change_in_pose_output
Definition: libstereo-odometry.h:235
int read_int(const std::string &section, const std::string &name, int defaultValue, bool failIfNotFound=false) const
std::vector< size_t > orb_matches_ID
Definition: libstereo-odometry.h:805
int m_gui_info_cache_next_index
Will alternate between 0 and 1.
Definition: libstereo-odometry.h:995
Definition: libstereo-odometry.h:142
uint32_t sad_max_distance
The maximum SAD value to consider a pairing as a potential match (Default: ~400)
Definition: libstereo-odometry.h:458
double min_mod_out_vector
(def:0.001) – Minimum modulus of the step output vector to continue iterating (ending condition) ...
Definition: libstereo-odometry.h:324
bool use_precomputed_data
Definition: libstereo-odometry.h:214
TInterFrameMatchingParams params_if_match
Definition: libstereo-odometry.h:505
TLeftRightMatchParams params_lr_match
Definition: libstereo-odometry.h:504
double target_feats_per_pixel
Desired number of features per square pixel (Default: 10/1000)
Definition: libstereo-odometry.h:393
int num_it_final
number of iterations in the two stages of optimization
Definition: libstereo-odometry.h:241
bool draw_all_raw_feats
Default = false.
Definition: libstereo-odometry.h:369
mrpt::system::TThreadHandle m_thread_gui
Definition: libstereo-odometry.h:941
Definition: libstereo-odometry.h:365
double kernel_param
(def:3) – Robust kernel parameter (pseudo-Huber)
Definition: libstereo-odometry.h:320
std::string text_msg_from_conseq_match
Definition: libstereo-odometry.h:963
mrpt::utils::CTimeLogger m_profiler
Definition: libstereo-odometry.h:732
void setVerbosityLevel(int level)
Definition: libstereo-odometry.h:527
std::vector< std::pair< mrpt::utils::TPixelCoord, mrpt::utils::TPixelCoord > > vector_pixel_pairs_t
Definition: libstereo-odometry.h:140
TStereoOdometryRequest()
Definition: libstereo-odometry.h:223
mrpt::poses::CPose3D change_in_pose
Definition: libstereo-odometry.h:130
int m_verbose_level
0: None (only critical msgs), 1: verbose, 2:even more verbose
Definition: libstereo-odometry.h:752
Definition: libstereo-odometry.h:142
TInfoForTheGUI * m_gui_info
Definition: libstereo-odometry.h:998
VOErrorCode
Definition: libstereo-odometry.h:142
Definition: libstereo-odometry.h:954
CImage getCopyCurrentImageLeft()
Definition: libstereo-odometry.h:698
Definition: libstereo-odometry.h:142
size_t bad_tracking_th
(def:5) – Minimum number of tracked features to yield a tracking error
Definition: libstereo-odometry.h:328
vector< pair< size_t, size_t > > detected_feats
number of detected features in each octave : .first (left image) and .second (right image) ...
Definition: libstereo-odometry.h:248
void dumpToConsole()
Definition: libstereo-odometry.h:333
vector< TKeyPointList > * precomputed_right_feats
Definition: libstereo-odometry.h:215
NMSMethod nmsMethod
Method to perform non maximal suppression.
Definition: libstereo-odometry.h:401
Definition: libstereo-odometry.h:949
unsigned int num_gn_final_iterations
Definition: libstereo-odometry.h:133
bool m_threads_must_close
set to true at destruction to signal all threads that they must end.
Definition: libstereo-odometry.h:942
VOErrorCode m_error
Definition: libstereo-odometry.h:749
std::vector< int > stats_FAST_thresholds_per_octave
Definition: libstereo-odometry.h:959
Definition: libstereo-odometry.h:111
mrpt::vision::CStereoRectifyMap m_stereo_rectifier
Definition: libstereo-odometry.h:830
void enable_time_profiler(bool enable=true)
Definition: libstereo-odometry.h:521
Definition: libstereo-odometry.h:266
Definition: libstereo-odometry.h:756
double read_double(const std::string &section, const std::string &name, double defaultValue, bool failIfNotFound=false) const
vector< size_t > stereo_matches
number of stereo matches in each octave :
Definition: libstereo-odometry.h:249
const TImagePairData * prev_imgpair
Definition: libstereo-odometry.h:818
TDetectParams params_detect
Definition: libstereo-odometry.h:503
bool rectified_images
Indicates if the stereo pair has parallel optical axes.
Definition: libstereo-odometry.h:467
mrpt::utils::CImage img_right
Images to be shown on the left & right panels of the display.
Definition: libstereo-odometry.h:957
double sad_max_ratio
The maximum ratio between the two smallest SAD when searching for pairings (Default: 0...
Definition: libstereo-odometry.h:459
int fast_min_th
Definition: libstereo-odometry.h:408
mrpt::vision::CImagePyramid pyr
Pyramid of grayscale images.
Definition: libstereo-odometry.h:760
bool use_custom_initial_pose
(def:false) – Use the (input) custom initial pose but do not save it for later use (useful when getCh...
Definition: libstereo-odometry.h:330
Definition: libstereo-odometry.h:142
vector< double > out_residual
residual for each observation (tracked match)
Definition: libstereo-odometry.h:240
Definition: libstereo-odometry.h:120
CPose3D outPose
Definition: libstereo-odometry.h:238
bool isORBThMin()
Definition: libstereo-odometry.h:540
void setMaxMatchID(const size_t id)
Definition: libstereo-odometry.h:726
void getValues(vector< cv::KeyPoint > &leftKP, vector< cv::KeyPoint > &rightKP, cv::Mat &leftDesc, cv::Mat &rightDesc, vector< cv::DMatch > &matches, vector< size_t > &matches_id)
Definition: libstereo-odometry.h:704
vector_index_pairs_t matches_lr
Definition: libstereo-odometry.h:779
size_t initial_max_iters
(def:10) – Maximum number of iterations for the initial stage
Definition: libstereo-odometry.h:323
unsigned int m_it_counter
Iteration counter.
Definition: libstereo-odometry.h:753
#define INVALID_TIMESTAMP
KpRowSorter(const TKeyPointList &data)
Definition: libstereo-odometry.h:123
void setFASTThreshold(int value)
Definition: libstereo-odometry.h:531
img_data_t right
Definition: libstereo-odometry.h:772
const TKeyPointList & m_data
Definition: libstereo-odometry.h:122
TDMethod
Definition: libstereo-odometry.h:388
std::vector< vector_index_pairs_t > tracked_pairs
Definition: libstereo-odometry.h:823
mrpt::utils::TStereoCamera stereo_cam
Definition: libstereo-odometry.h:211
mrpt::utils::CTimeLogger & get_time_profiler()
Definition: libstereo-odometry.h:524
std::vector< TKeyPointList > pyr_feats_kps
Features in each pyramid (keypoint version) <- will substitute [orb_matches].
Definition: libstereo-odometry.h:762
size_t m_lastID
Identificator of the last tracked feature.
Definition: libstereo-odometry.h:733
bool non_maximal_suppression
Enable/disable the non-maximal suppression after the detection (5x5 windows is used) ...
Definition: libstereo-odometry.h:400
TIFMMethod
Definition: libstereo-odometry.h:291
std::vector< cv::KeyPoint > TKeyPointList
Definition: libstereo-odometry.h:108
bool filter_fund_matrix
Whether or not use fundamental matrix to remove outliers between inter-frame matches (unused by now) ...
Definition: libstereo-odometry.h:304
std::vector< std::pair< size_t, size_t > > vector_index_pairs_t
Definition: libstereo-odometry.h:139
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
void swap(TInfoForTheGUI &o)
Definition: libstereo-odometry.h:971
vector< vector< size_t > > m_kf_ids
Definition: libstereo-odometry.h:740
TSMMethod match_method
The selected method to perform stereo matching. Compatibility: {smSAD} -> {ORB,KLT,FAST[ER],FAST[ER]+ORB} and {smDescBF,smDescRbR} -> {ORB,FAST[ER]+ORB}.
Definition: libstereo-odometry.h:455
std::vector< img_pairing_data_t > lr_pairing_data
Definition: libstereo-odometry.h:799
mrpt::utils::TPixelCoord px_pR
Definition: libstereo-odometry.h:951
TLeastSquaresParams params_least_squares
Definition: libstereo-odometry.h:506
std::vector< mrpt::vector_size_t > pyr_feats_index
Index of feature indices per row.
Definition: libstereo-odometry.h:763
TGeneralParams params_general
Definition: libstereo-odometry.h:508
std::string text_msg_from_detect
Definition: libstereo-odometry.h:962
bool m_reset
Definition: libstereo-odometry.h:739
double orb_max_distance
Maximum allowed Hamming distance between a pair of features to be considered a match (unused by now) ...
Definition: libstereo-odometry.h:301
mrpt::system::TTimeStamp timestamp
This is the key field that signals when the whole structure's changed & GUI must be refreshed...
Definition: libstereo-odometry.h:956
bool show_gui
Show GUI? (Default = true)
Definition: libstereo-odometry.h:368
vector< size_t > & getRefCurrentIDs(const size_t octave)
Definition: libstereo-odometry.h:701
bool valid
whether or not the result is valid
Definition: libstereo-odometry.h:243
size_t size(const MATRIXLIKE &m, int dim)
Definition: libstereo-odometry.h:383
void loadParamsFromConfigFile(const mrpt::utils::CConfigFile &iniFile, const std::vector< std::string > &sections)
Definition: libstereo-odometry.h:554
Definition: libstereo-odometry.h:142
std::vector< TTrackedPixels > stats_tracked_feats
Definition: libstereo-odometry.h:960
Definition: libstereo-odometry.h:205
Definition: libstereo-odometry.h:129
std::string text_msg_from_lr_match
Definition: libstereo-odometry.h:961
bool m_error_in_tracking
Definition: libstereo-odometry.h:748
#define ASSERT_(f)
size_t m_last_kf_max_id
Maximum ID of a match belonging to certain frame defined as 'KF'.
Definition: libstereo-odometry.h:738
void dumpToConsole()
Definition: libstereo-odometry.h:275
size_t max_iters
(def:100) – Final maximum number of iterations for the refinement stage
Definition: libstereo-odometry.h:322
void dumpToConsole()
Definition: libstereo-odometry.h:187
TImagePairDataPtr m_prev_imgpair
Definition: libstereo-odometry.h:829
NMSMethod
Definition: libstereo-odometry.h:387
bool repeat
Definition: libstereo-odometry.h:221
vector< cv::Mat > * precomputed_right_desc
Definition: libstereo-odometry.h:216
bool use_previous_pose_as_initial
(def:true) – Use the previous computed pose as the initial one for the next frame ...
Definition: libstereo-odometry.h:329
void loadParamsFromConfigFileName(const std::string &fileName, const std::vector< std::string > &sections)
Definition: libstereo-odometry.h:666
VOErrorCode error_code
error code for the method
Definition: libstereo-odometry.h:244
t_change_in_pose_output()
Definition: libstereo-odometry.h:135
void dumpToConsole()
Definition: libstereo-odometry.h:358
Definition: libstereo-odometry.h:353
std::vector< mrpt::vision::TSimpleFeatureList > pyr_feats
Features in each pyramid.
Definition: libstereo-odometry.h:761
vector< size_t > draw_pairings_ids
Definition: libstereo-odometry.h:968
size_t tracked_feats_from_last_KF
Definition: libstereo-odometry.h:245
TImagePairData()
Definition: libstereo-odometry.h:810
void resetFASTThreshold()
Definition: libstereo-odometry.h:532
int m_current_orb_th
Definition: libstereo-odometry.h:746
std::vector< int > m_threshold
Definition: libstereo-odometry.h:831
uint32_t sad_max_distance
The maximum SAD value to consider a pairing as a potential match (Default: ~200)
Definition: libstereo-odometry.h:297
std::vector< double > out_residual
Definition: libstereo-odometry.h:131
size_t orb_nlevels
The number of pyramid levels.
Definition: libstereo-odometry.h:406
int nOctaves
Number of octaves to create.
Definition: libstereo-odometry.h:356
bool vo_save_files
(def:false) Set/Unset storage of some information of the system in files as the process runs ...
Definition: libstereo-odometry.h:270
double orb_max_distance
Maximum allowed Hamming distance between a pair of features to be considered a match.
Definition: libstereo-odometry.h:462
bool m_jacobian_is_good(Eigen::MatrixXd &jacobian)
Definition: libstereo-odometry.h:919
#define ASSERTMSG_(f, __ERROR_MSG)
size_t m_kf_max_match_ID
Definition: libstereo-odometry.h:742
CImage & getRefCurrentImageRight()
Definition: libstereo-odometry.h:697
TIFMMethod ifm_method
Inter-frame matching method.
Definition: libstereo-odometry.h:292
size_t min_distance
The allowed minimun distance between features.
Definition: libstereo-odometry.h:402
bool draw_lr_pairings
Default = false.
Definition: libstereo-odometry.h:370
TGUIParams params_gui
Definition: libstereo-odometry.h:507
TDMatchList matches_lr_dm
Definition: libstereo-odometry.h:784
vector< TDMatchList > * precomputed_matches
Definition: libstereo-odometry.h:217
int m_win_keyhit
Definition: libstereo-odometry.h:947
size_t m_num_tracked_pairs_from_last_kf
Definition: libstereo-odometry.h:736
size_t max_incr_cost
(def:3) – Maximum allowed number of times the cost can grow
Definition: libstereo-odometry.h:326