00001 #ifndef TRV_CORE_HPP
00002 #define TRV_CORE_HPP
00003
00004 #include "traversability/trv_homography.hpp"
00005 #include "traversability/trv_homographyGeom.hpp"
00006 #include "traversability/trv_homographyFine.hpp"
00007 #include "traversability/trv_homographyMosaic.hpp"
00008 #include "traversability/trv_util.hpp"
00009 #include "traversability/trv_tracker.hpp"
00010 #include "traversability/trv_densificator.hpp"
00011
00012 #include <image/Image.hpp>
00013 #include "jmath/jblas.hpp"
00014 #include "jmath/ublasExtra.hpp"
00015 #include "kernel/jafarException.hpp"
00016
00017
00018
00019 namespace jafar {
00020 namespace traversability {
00021
00031 class Core
00032 {
00033 public:
00034
00035
00036 int imBufferCnt;
00037 int imBufferSize;
00038 jafar::image::Image* imBuffer;
00039
00040
00041 int poseBufferCnt;
00042 int poseBufferSize;
00043 CameraPoseParameters* poseBuffer;
00044
00045
00046 int trvBufferCnt;
00047 int trvBufferSize;
00048 jafar::image::Image* trvBuffer;
00049
00050
00051
00052 int homBufferCnt;
00053 int homBufferSize;
00054 jblas::mat33* homBuffer;
00055
00056
00057
00058 int preBufferCnt;
00059 int preBufferSize;
00060 jblas::mat33* preBuffer;
00061
00062
00063 int actIdx0;
00064 int actIdx1;
00065 jafar::image::Image* actIm0_ptr;
00066 jafar::image::Image* actIm1_ptr;
00067 jafar::image::Image* actMsk1_ptr;
00068 CameraPoseParameters* actPose0_ptr;
00069 CameraPoseParameters* actPose1_ptr;
00070
00071
00072 jafar::image::Image im0_1_fine;
00073 jafar::image::Image im0_1_geom;
00074 jafar::image::Image mask1_fine;
00075 jafar::image::Image mask1_geom;
00076
00077
00078 HomographyGeom Hgeom;
00079 HomographyFine Hfine;
00080 HomographyMosaic Hmos;
00081 HomographyFine HmosUpdate;
00082 HomographyGeom HpreCalc;
00083
00084
00085 jblas::mat33 H_C0C1g;
00086 jblas::mat33 H_C1C0g;
00087 jblas::mat33 H_C0C1f;
00088 jblas::mat33 H_C1C0f;
00089
00090
00091 jblas::mat33 H_C0C1;
00092 jblas::mat33 H_C1C0;
00093
00094 Tracker* tracker;
00095
00096 Densificator* densificator;
00097
00098
00099 ImageInfo imageInfo;
00100
00101 bool optWithGeomPrecalculation;
00102
00103 public:
00104 Core ( TrackerType ttype, int bufferSize, int imWidth, int imHeight,
00105 int winHalfWidth, int winHalfHeight, bool withGeomPrecalc = false );
00106 ~Core ( void );
00107
00108
00115 void setupGeometry ( const PlaneParameters &plane, const CameraIntrinsicParameters &internals);
00116
00117
00118
00119 TrackerType getTrackerType ( void ) const { return tracker->getTrackerType(); }
00120
00121
00127 void setPose ( const int idx, const CameraPoseParameters &camPose ) {
00128 ++poseBufferCnt;
00129
00130 poseBuffer[idx%poseBufferSize] = camPose;
00131 }
00138 void setImage ( const int idx, const jafar::image::Image &_im ) {
00139 ++imBufferCnt;
00140 imBuffer[idx%imBufferSize] = _im;
00141 }
00148 void init ( const int idx0, const int idx1 );
00149
00150
00151 jafar::image::Image getImage ( int idx ) const { return imBuffer[idx%imBufferSize]; }
00157 jafar::image::Image getTrv ( unsigned int idx=-1 ) const {
00158 if (trvBufferCnt==-1) JFR_WARNING("There is no traversability information available");
00159 return (idx==-1) ? trvBuffer[(trvBufferCnt)%trvBufferSize] : trvBuffer[idx%trvBufferSize]; }
00160 jafar::image::Image getImage0_1_fine ( void ) const { return im0_1_fine; }
00161 jafar::image::Image getImage0_1_geom ( void ) const { return im0_1_geom; }
00162 jafar::image::Image getMask1_fine ( void ) const { return mask1_fine; }
00163
00164
00165 MatchesContainer* getMatches ( void ) { return tracker->matches(); }
00166
00167
00168
00169 void calcTracker ( jafar::image::Image &img0, jafar::image::Image &img1 );
00176 void calcTracker ( int step = 1 );
00177
00182 void calcHgeom ( void );
00189 void calcHfine ( const jafar::image::Image &prevTravMask );
00193 void calcDensify ( void );
00194 void calcH_mosUpdate ( int idx0, int idx1 );
00195 void applyHomography ( const jblas::mat33 &H_C0C1,
00196 const jafar::image::Image &img0,
00197 jafar::image::Image &img0_1 );
00198
00199 private:
00200 void updateHmosBasic ( void );
00201 public:
00205 jblas::mat33 getH_C0Cn( void );
00206
00207
00208
00209
00210
00211
00212
00213
00214
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
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300