00001
00002
00003 #ifndef SLAM_OMNI_IMAGE_POINT_MANAGER_HPP
00004 #define SLAM_OMNI_IMAGE_POINT_MANAGER_HPP
00005
00006 #include "boost/tuple/tuple.hpp"
00007
00008 #include "kernel/dataLog.hpp"
00009
00010 #include "jmath/jblas.hpp"
00011
00012 #include "image/Image.hpp"
00013
00014 #ifndef THALES_TAROT_DISABLE
00015 #include "datareader/ImageReader.hpp"
00016 #endif
00017
00018 #include "geom/t3dEuler.hpp"
00019
00020 #include "camera/cameraBarreto.hpp"
00021 #include "camera/mask.hpp"
00022
00023 #ifndef THALES_TAROT_DISABLE
00024 #include "locpano/engine.hpp"
00025 #endif
00026
00027 #include "hpm/export.hpp"
00028 #include "hpm/engine.hpp"
00029
00030 #include "locpano/engine.hpp"
00031
00032 #include <slam/full3dPredictModel.hpp>
00033 #include "slampt/managerTools.hpp"
00034 #include <slam/bearingOnlySlam.hpp>
00035
00036 namespace jafar {
00037 namespace slampt {
00038
00039 #ifndef SWIG
00040
00046 class OmniImageFrameDataBase : public FrameDataBase {
00047
00048 public:
00049
00050 int databaseNbImagesMax;
00051 double databaseImageDistanceMin;
00052 int loopClosingIndexDistanceMin;
00053 double loopClosingImageDistanceMax;
00054
00055 jafar::locpano::Engine omniImageDB;
00056
00057 DBFrameList::iterator tentativeLoopClosing();
00058
00059 };
00060
00061 #endif // SWIG
00062
00066 class OmniImagePointManager :
00067 public jafar::kernel::DataLoggable,
00068 public slam::BoSlamEventAdapter
00069 {
00070
00071 private :
00072
00073 unsigned int idFactory;
00074
00075 slam::BearingOnlySlam& slam;
00076
00078 jafar::hpm::Engine& hpmEngineLoopClosing;
00079
00080 OmniImageFrameDataBase frameDataBase;
00081 jafar::datareader::ImageReader dataBaseImageReader;
00082
00083
00084 bool databaseImageAdded;
00085 double databaseImageDistance;
00086 bool loopClosingDetected;
00087 unsigned int loopClosingFrameIndex;
00088 double loopClosingImageDistance;
00089 unsigned int loopClosingNbUsedFeatures;
00090 unsigned int loopClosingElapsedTime;
00091
00092
00093 jafar::hpm::vecHarrisPoints loopClosingPoints;
00094
00095 typedef std::vector<QualityIndexPoint> QualityIndexPoints;
00096
00098 std::vector<QualityIndexPoints> pointsInZone;
00099 std::vector<unsigned int> nbFeaturesInZone;
00100
00102 typedef std::list<std::size_t> FeaturesList;
00103 FeaturesList knownFeatures;
00104 FeaturesList newFeatures;
00105
00106 boost::tuple<bool, unsigned int> isPointInZone(double u, double v);
00107
00108 static int computeIndex(double x_, int nbInt_, double xMax_);
00109
00110 unsigned int getNewFeatureId() { return ++idFactory;}
00111
00112 void addNewFeature(std::size_t index_, hpm::HarrisPoint& point_);
00113
00114 void addKnownFeature(std::size_t index_, jafar::hpm::HarrisPoint const& point_);
00115
00116 bool loopClosingDetection(image::Image const& image);
00117 void loopClosing(jafar::hpm::vecHarrisPoints& framePoints_, jafar::image::Image const& image);
00118
00119 void featureSelection(jafar::hpm::vecHarrisPoints& points_);
00120
00121 void addFrameToDataBase(jafar::hpm::vecHarrisPoints& points_, jafar::image::Image const& image);
00122
00123 void slamProcessObservations() const;
00124
00126 unsigned int currentFrameIndex;
00127
00128 jafar::datareader::ImageReader imageReader;
00129
00131 jafar::hpm::TrackingEngine& hpmTrackingEngine;
00132
00133 jafar::hpm::vecHarrisPoints vecPointsPrev;
00134 jafar::hpm::vecHarrisPoints vecPointsCur;
00135
00136 bool fillObservation(std::size_t index_, slam::Observation& obs) const;
00137
00138
00139 void removeLandmark(slam::BaseFeature const& landmark);
00140 void removeTentativeLandmark(slam::InitFeature const& landmark);
00141 void removeLandmark(unsigned int id);
00142
00143 public :
00144
00145
00146 jafar::camera::CameraParabolicBarreto camera;
00147 jafar::camera::PanoMask omniMask;
00148 unsigned int imageMargin;
00149 std::size_t nbZonesInRadius;
00150 std::size_t nbZonesInPeriphery;
00151 unsigned int nbDesiredFeaturesPerZone;
00152
00153 OmniImagePointManager(slam::BearingOnlySlam& slam_,
00154 jafar::camera::CameraParabolicBarreto& camera_,
00155 jafar::hpm::Engine& hpmEngineLoopClosing_,
00156 jafar::hpm::TrackingEngine& hpmTrackingEngine_);
00157
00158 ~OmniImagePointManager();
00159
00160 void setupManager(unsigned int imageMargin_,
00161 std::size_t nbZonesInRadius_,
00162 std::size_t nbZonesInPeriphery_,
00163 unsigned int nbDesiredFeaturesPerZone_);
00164
00165 void setupDataBase(int databaseNbImagesMax,
00166 double databaseImageDistanceMin,
00167 int loopClosingIndexDistanceMin,
00168 double loopClosingImageDistanceMax,
00169 std::string const& imageDir);
00170
00171 bool isLoopClosingDetected() const {return loopClosingDetected;}
00172
00173 unsigned int getLoopClosingFrameIndex() const {return loopClosingFrameIndex;}
00174
00175 jafar::hpm::vecHarrisPoints const& getLoopClosingPoints() const {return loopClosingPoints;}
00176
00177
00178
00179
00180 void writeLogHeader(jafar::kernel::DataLogger& dataLogger) const;
00181 void writeLogData(jafar::kernel::DataLogger& dataLogger) const;
00182
00183 jafar::datareader::ImageReader& getImageReader() {return imageReader;}
00184
00185 jafar::hpm::vecHarrisPoints const& getCurrentPoints() const {return vecPointsCur;}
00186 jafar::hpm::vecHarrisPoints const& getPreviousPoints() const {return vecPointsPrev;}
00187
00188 void initFrame(unsigned int frameIndex_);
00189 void initFrame(jafar::image::Image& image, int frameIndex_=-1);
00190 void initFrame(boost::posix_time::time_duration const& curTime, jafar::image::Image& image);
00191
00192 void processFrame(unsigned int frameIndex_);
00193 void processFrame(jafar::image::Image& image, int frameIndex_=-1);
00194
00195
00196
00197 };
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 }
00239 }
00240
00241 #endif // SLAM_OMNI_IMAGE_POINT_MANAGER_HPP