viso_stereo.h
Go to the documentation of this file.
00001 /*
00002 Copyright 2011. All rights reserved.
00003 Institute of Measurement and Control Systems
00004 Karlsruhe Institute of Technology, Germany
00005 
00006 This file is part of libviso2.
00007 Authors: Andreas Geiger
00008 
00009 libviso2 is free software; you can redistribute it and/or modify it under the
00010 terms of the GNU General Public License as published by the Free Software
00011 Foundation; either version 2 of the License, or any later version.
00012 
00013 libviso2 is distributed in the hope that it will be useful, but WITHOUT ANY
00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00015 PARTICULAR PURPOSE. See the GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License along with
00018 libviso2; if not, write to the Free Software Foundation, Inc., 51 Franklin
00019 Street, Fifth Floor, Boston, MA 02110-1301, USA
00020 */
00021 
00022 #ifndef VISO_STEREO_H
00023 #define VISO_STEREO_H
00024 
00025 #include "viso.h"
00026 #include "mcqd.h"
00027 #include <TooN/TooN.h>
00028 class VisualOdometryStereo : public VisualOdometry {
00029 
00030 public:
00031 
00032   // stereo-specific parameters (mandatory: base)
00033   struct parameters : public VisualOdometry::parameters {
00034     double  base;             // baseline (meters)
00035     int32_t ransac_iters;     // number of RANSAC iterations
00036     double  inlier_threshold; // fundamental matrix inlier threshold
00037     bool    reweighting;      // lower border weights (more robust to calibration errors)
00038     parameters () {
00039       base             = 1.0;
00040       ransac_iters     = 100;
00041       inlier_threshold = 2.0;
00042       reweighting      = true;
00043     }
00044   };
00045 
00046   // constructor, takes as inpute a parameter structure
00047   VisualOdometryStereo (parameters param);
00048 
00049   // deconstructor
00050   ~VisualOdometryStereo ();
00051 
00052   // process a new images, push the images back to an internal ring buffer.
00053   // valid motion estimates are available after calling process for two times.
00054   // inputs: I1 ........ pointer to rectified left image (uint8, row-aligned)
00055   //         I2 ........ pointer to rectified right image (uint8, row-aligned)
00056   //         dims[0] ... width of I1 and I2 (both must be of same size)
00057   //         dims[1] ... height of I1 and I2 (both must be of same size)
00058   //         dims[2] ... bytes per line (often equal to width)
00059   //         replace ... replace current images with I1 and I2, without copying last current
00060   //                     images to previous images internally. this option can be used
00061   //                     when small/no motions are observed to obtain Tr_delta wrt
00062   //                     an older coordinate system / time step than the previous one.
00063   // output: returns false if an error occured
00064   bool process (uint8_t *I1,uint8_t *I2,int32_t* dims,bool replace=false);
00065 
00066   using VisualOdometry::process;
00067         std::vector<Matcher::p_match> getMatches () { return p_matched1; }
00068 
00069 
00070 private:
00071 
00072   std::vector<double>  estimateMotion (std::vector<Matcher::p_match> p_matched);
00073   std::vector<double>  estimateMotionLinear (std::vector<Matcher::p_match> p_matched);
00074   std::vector<double>  estimateMotionMaxClique (std::vector<Matcher::p_match> p_matched);
00075   enum                 result { UPDATED, FAILED, CONVERGED };
00076   result               updateParameters(std::vector<Matcher::p_match> &p_matched,std::vector<int32_t> &active,std::vector<double> &tr,double step_size,double eps);
00077   result               updateParametersLinear(std::vector<Matcher::p_match> &p_matched,std::vector<int32_t> &active,std::vector<double> &tr,double step_size,double eps);
00078   result               updateParametersP3p(std::vector<Matcher::p_match> &p_matched,std::vector<int32_t> &active,TooN::Matrix<3,4> &tr,double step_size,double eps);
00079   void                 computeObservations(std::vector<Matcher::p_match> &p_matched,std::vector<int32_t> &active);
00080   void                 computeResidualsAndJacobian(std::vector<double> &tr,std::vector<int32_t> &active);
00081   void                 computeResidualsAndJacobianP3p(TooN::Matrix<3,4> &tr,std::vector<int32_t> &active);
00082   std::vector<int32_t> getInlier(std::vector<Matcher::p_match> &p_matched,std::vector<double> &tr);
00083   std::vector<int32_t> getInlier(std::vector<Matcher::p_match> &p_matched,TooN::Matrix<3,4> &tr);
00084   
00085   bool justice2Matches(Matcher::p_match &m1,Matcher::p_match &m2);
00086   void creatAdjMatrix(std::vector<Matcher::p_match>& p_matched,bool** &conn);
00087 
00088   double *X,*Y,*Z,*XC,*YC,*ZC;    // 3d points
00089   double *p_residual; // residuals (p_residual=p_observe-p_predict)
00090   double rx_old,ry_old,rz_old,tx_old,ty_old,tz_old;
00091   std::vector<Matcher::p_match>  p_matched1;
00092   // parameters
00093   parameters param;
00094 };
00095 
00096 #endif // VISO_STEREO_H
00097 


dlut_libvo
Author(s): Zhuang Yan
autogenerated on Thu Jun 6 2019 20:03:29