viso_mono.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_MONO_H
00023 #define VISO_MONO_H
00024 
00025 #include "viso.h"
00026 
00027 class VisualOdometryMono : public VisualOdometry {
00028 
00029 public:
00030 
00031   // monocular-specific parameters (mandatory: height,pitch)
00032   struct parameters : public VisualOdometry::parameters {
00033     double                      height;           // camera height above ground (meters)
00034     double                      pitch;            // camera pitch (rad, negative=pointing down)
00035     int32_t                     ransac_iters;     // number of RANSAC iterations
00036     double                      inlier_threshold; // fundamental matrix inlier threshold
00037     double                      motion_threshold; // directly return false on small motions
00038     parameters () {
00039       height           = 1.0;
00040       pitch            = 0.0;
00041       ransac_iters     = 2000;
00042       inlier_threshold = 0.00001;
00043       motion_threshold = 100.0;
00044     }
00045   };
00046 
00047   // constructor, takes as inpute a parameter structure
00048   VisualOdometryMono (parameters param);
00049   
00050   // deconstructor
00051   ~VisualOdometryMono ();
00052   
00053   // process a new image, pushs the image back to an internal ring buffer.
00054   // valid motion estimates are available after calling process for two times.
00055   // inputs: I ......... pointer to rectified image (uint8, row-aligned)
00056   //         dims[0] ... width of I
00057   //         dims[1] ... height of I
00058   //         dims[2] ... bytes per line (often equal to width)
00059   //         replace ... replace current image with I, without copying last current
00060   //                     image to previous image 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 motion too small or an error occured
00064   bool process (uint8_t *I,int32_t* dims,bool replace=false);
00065 
00066 private:
00067 
00068   template<class T> struct idx_cmp {
00069     idx_cmp(const T arr) : arr(arr) {}
00070     bool operator()(const size_t a, const size_t b) const { return arr[a] < arr[b]; }
00071     const T arr;
00072   };  
00073 
00074   std::vector<double>  estimateMotion (std::vector<Matcher::p_match> p_matched);  
00075   Matrix               smallerThanMedian (Matrix &X,double &median);
00076   bool                 normalizeFeaturePoints (std::vector<Matcher::p_match> &p_matched,Matrix &Tp,Matrix &Tc);
00077   void                 fundamentalMatrix (const std::vector<Matcher::p_match> &p_matched,const std::vector<int32_t> &active,Matrix &F);
00078   void                 EtoRt(Matrix &E,Matrix &K,std::vector<Matcher::p_match> &p_matched,Matrix &X,Matrix &R,Matrix &t);
00079   int32_t              triangulateChieral (std::vector<Matcher::p_match> &p_matched,Matrix &K,Matrix &R,Matrix &t,Matrix &X);
00080   std::vector<int32_t> getInlier (std::vector<Matcher::p_match> &p_matched,Matrix &F);
00081   
00082   // parameters
00083   parameters param;  
00084 };
00085 
00086 #endif // VISO_MONO_H
00087 


libviso2
Author(s): Andreas Geiger, Stephan Wirth
autogenerated on Fri Aug 28 2015 13:37:45