00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef mrpt_vision_types_H
00030 #define mrpt_vision_types_H
00031
00032 #include <mrpt/utils/CImage.h>
00033 #include <mrpt/utils/CLoadableOptions.h>
00034 #include <mrpt/utils/TMatchingPair.h>
00035
00036 #include <mrpt/vision/link_pragmas.h>
00037
00038 namespace mrpt
00039 {
00040 namespace vision
00041 {
00042 using std::vector;
00043 using namespace mrpt::slam;
00044 using namespace mrpt::math;
00045 using namespace mrpt::utils;
00046
00047
00048 typedef uint64_t TLandmarkID;
00049 typedef uint64_t TCameraPoseID;
00050
00051 typedef std::map<TCameraPoseID,CPose3D> TFramePosesMap;
00052 typedef std::vector<CPose3D> TFramePosesVec;
00053
00054 typedef std::map<TLandmarkID,TPoint3D> TLandmarkLocationsMap;
00055 typedef std::vector<TPoint3D> TLandmarkLocationsVec;
00056
00057
00058 struct VISION_IMPEXP TFeatureObservation
00059 {
00060 inline TFeatureObservation() { }
00061 inline TFeatureObservation(const TLandmarkID _id_feature, const TCameraPoseID _id_frame, const TPixelCoordf _px) : id_feature(_id_feature), id_frame(_id_frame), px(_px) { }
00062
00063 TLandmarkID id_feature;
00064 TCameraPoseID id_frame;
00065 TPixelCoordf px;
00066 };
00067
00068
00069
00070 struct TRelativeFeaturePos
00071 {
00072 inline TRelativeFeaturePos() { }
00073 inline TRelativeFeaturePos(const mrpt::vision::TCameraPoseID _id_frame_base, const mrpt::math::TPoint3D _pos) : id_frame_base(_id_frame_base), pos(_pos) { }
00074
00075 mrpt::vision::TCameraPoseID id_frame_base;
00076 mrpt::math::TPoint3D pos;
00077 };
00078
00079
00080 typedef std::map<mrpt::vision::TFeatureID, TRelativeFeaturePos> TRelativeFeaturePosMap;
00081
00082
00083
00084
00085
00086
00087 struct VISION_IMPEXP TSequenceFeatureObservations : public std::vector<TFeatureObservation>
00088 {
00089 typedef std::vector<TFeatureObservation> BASE;
00090
00091 inline TSequenceFeatureObservations() {}
00092 inline TSequenceFeatureObservations(size_t size) : BASE(size) {}
00093 inline TSequenceFeatureObservations(const TSequenceFeatureObservations& o) : BASE(o) {}
00094
00095
00096
00097
00098
00099 void saveToTextFile(const std::string &filName, bool skipFirstCommentLine = false) const;
00100
00101
00102 void loadFromTextFile(const std::string &filName);
00103
00104
00105
00106
00107 size_t removeFewObservedFeatures(size_t minNumObservations = 3);
00108
00109
00110
00111
00112 void decimateCameraFrames(const size_t decimate_ratio);
00113
00114
00115
00116
00117 void compressIDs(
00118 std::map<TCameraPoseID,TCameraPoseID> *old2new_camIDs=NULL,
00119 std::map<TLandmarkID,TLandmarkID> *old2new_lmIDs=NULL );
00120
00121 };
00122
00123
00124 struct VISION_IMPEXP TCamCalibBAResults
00125 {
00126 std::vector<mrpt::poses::CPose3DQuat,Eigen::aligned_allocator<mrpt::poses::CPose3DQuat> > camera_poses;
00127 std::vector<mrpt::math::TPoint3D> landmark_positions;
00128 };
00129
00130
00131
00132
00133
00134 struct VISION_IMPEXP TStereoSystemParams : public mrpt::utils::CLoadableOptions
00135 {
00136
00137
00138 TStereoSystemParams( );
00139
00140
00141
00142 void loadFromConfigFile(
00143 const mrpt::utils::CConfigFileBase &source,
00144 const std::string §ion);
00145
00146
00147
00148 void dumpToTextStream(CStream &out) const;
00149
00150
00151
00152 enum TUnc_Prop_Method
00153 {
00154
00155
00156 Prop_Linear = -1,
00157
00158
00159 Prop_UT,
00160
00161
00162 Prop_SUT
00163 };
00164
00165 TUnc_Prop_Method uncPropagation;
00166
00167
00168 CMatrixDouble33 F;
00169
00170
00171
00172 CMatrixDouble33 K;
00173
00174
00175 float baseline;
00176
00177
00178 float stdPixel;
00179
00180
00181 float stdDisp;
00182
00183
00184 float maxZ;
00185
00186
00187 float minZ;
00188
00189
00190 float maxY;
00191
00192
00193 float factor_k;
00194
00195
00196 float factor_a;
00197
00198
00199 float factor_b;
00200
00201
00202
00203
00204
00205 };
00206
00207
00208
00209 struct VISION_IMPEXP TROI
00210 {
00211
00212 TROI();
00213 TROI(float x1, float x2, float y1, float y2, float z1, float z2);
00214
00215
00216 float xMin;
00217 float xMax;
00218 float yMin;
00219 float yMax;
00220 float zMin;
00221 float zMax;
00222 };
00223
00224
00225
00226 struct VISION_IMPEXP TImageROI
00227 {
00228
00229 TImageROI();
00230 TImageROI( float x1, float x2, float y1, float y2 );
00231
00232
00233
00234
00235 float xMin, xMax;
00236
00237
00238 float yMin, yMax;
00239 };
00240
00241
00242
00243 struct VISION_IMPEXP TMatchingOptions : public mrpt::utils::CLoadableOptions
00244 {
00245
00246
00247
00248 enum TMatchingMethod
00249 {
00250
00251
00252 mmCorrelation = 0,
00253
00254
00255 mmDescriptorSIFT,
00256
00257
00258 mmDescriptorSURF,
00259
00260
00261 mmSAD
00262 };
00263
00264
00265 bool useEpipolarRestriction;
00266 bool hasFundamentalMatrix;
00267 bool parallelOpticalAxis;
00268 bool useXRestriction;
00269 bool addMatches;
00270
00271 CMatrixDouble33 F;
00272
00273
00274 TMatchingMethod matching_method;
00275 float epipolar_TH;
00276
00277
00278 float maxEDD_TH;
00279 float EDD_RATIO;
00280
00281
00282 float minCC_TH;
00283 float minDCC_TH;
00284 float rCC_TH;
00285
00286
00287 float maxEDSD_TH;
00288 float EDSD_RATIO;
00289
00290
00291 double maxSAD_TH;
00292 double SAD_RATIO;
00293
00294
00295 bool estimateDepth;
00296 double maxDepthThreshold;
00297
00298
00299
00300
00301 TMatchingOptions( );
00302
00303
00304
00305 void loadFromConfigFile(
00306 const mrpt::utils::CConfigFileBase &source,
00307 const std::string §ion);
00308
00309
00310
00311 void dumpToTextStream(CStream &out) const;
00312
00313 };
00314
00315
00316
00317 struct VISION_IMPEXP TMultiResMatchingOutput
00318 {
00319 int nMatches;
00320
00321 std::vector<int> firstListCorrespondences;
00322 std::vector<int> secondListCorrespondences;
00323 std::vector<int> firstListFoundScales;
00324 std::vector<double> firstListDistance;
00325
00326 TMultiResMatchingOutput() : nMatches(0),
00327 firstListCorrespondences(), secondListCorrespondences(),
00328 firstListFoundScales(), firstListDistance() {}
00329
00330 };
00331
00332
00333
00334 struct VISION_IMPEXP TMultiResDescMatchOptions : public mrpt::utils::CLoadableOptions
00335 {
00336 bool useOriFilter;
00337 double oriThreshold;
00338
00339 bool useDepthFilter;
00340
00341 double matchingThreshold;
00342 double matchingRatioThreshold;
00343 unsigned int lowScl1, lowScl2;
00344 unsigned int highScl1, highScl2;
00345
00346 int searchAreaSize;
00347 int lastSeenThreshold;
00348 int timesSeenThreshold;
00349
00350 int minFeaturesToFind;
00351 int minFeaturesToBeLost;
00352
00353
00354
00355 TMultiResDescMatchOptions() :
00356 useOriFilter( true ), oriThreshold( 0.2 ),
00357 useDepthFilter( true ), matchingThreshold( 1e4 ), matchingRatioThreshold( 0.5 ),
00358 lowScl1(0), lowScl2(0), highScl1(6), highScl2(6), searchAreaSize(20), lastSeenThreshold(10), timesSeenThreshold(5),
00359 minFeaturesToFind(30), minFeaturesToBeLost(5) {}
00360
00361 TMultiResDescMatchOptions(
00362 const bool &_useOriFilter, const double &_oriThreshold, const bool &_useDepthFilter,
00363 const double &_th, const double &_th2, const unsigned int &_lwscl1, const unsigned int &_lwscl2,
00364 const unsigned int &_hwscl1, const unsigned int &_hwscl2, const int &_searchAreaSize, const int &_lsth, const int &_tsth,
00365 const int &_minFeaturesToFind, const int &_minFeaturesToBeLost ) :
00366 useOriFilter( _useOriFilter ), oriThreshold( _oriThreshold ), useDepthFilter( _useDepthFilter ),
00367 matchingThreshold ( _th ), matchingRatioThreshold ( _th2 ), lowScl1( _lwscl1 ), lowScl2( _lwscl2 ),
00368 highScl1( _hwscl1 ), highScl2( _hwscl2 ), searchAreaSize( _searchAreaSize ), lastSeenThreshold( _lsth ), timesSeenThreshold( _tsth ),
00369 minFeaturesToFind( _minFeaturesToFind ), minFeaturesToBeLost(_minFeaturesToBeLost) {}
00370
00371 void loadFromConfigFile( const mrpt::utils::CConfigFileBase &cfg, const std::string §ion );
00372 void saveToConfigFile( mrpt::utils::CConfigFileBase &cfg, const std::string §ion );
00373 void dumpToTextStream( mrpt::utils::CStream &out) const;
00374
00375 };
00376
00377
00378
00379 struct VISION_IMPEXP TMultiResDescOptions : public mrpt::utils::CLoadableOptions
00380 {
00381 unsigned int basePSize;
00382 vector<double> scales;
00383 unsigned int comLScl, comHScl;
00384 double sg1, sg2, sg3;
00385 bool computeDepth;
00386 double fx,cx,cy,baseline;
00387 bool computeHashCoeffs;
00388
00389 double cropValue;
00390
00391
00392
00393 TMultiResDescOptions() :
00394 basePSize(23), sg1 (0.5), sg2(7.5), sg3(8.0), computeDepth(true), fx(0.0), cx(0.0), cy(0.0), baseline(0.0), computeHashCoeffs(false), cropValue(0.2)
00395 {
00396 scales.resize(7);
00397 scales[0] = 0.5;
00398 scales[1] = 0.8;
00399 scales[2] = 1.0;
00400 scales[3] = 1.2;
00401 scales[4] = 1.5;
00402 scales[5] = 1.8;
00403 scales[6] = 2.0;
00404 comLScl = 0;
00405 comHScl = 6;
00406 }
00407
00408 TMultiResDescOptions( const unsigned int &_basePSize, const vector<double> &_scales,
00409 const unsigned int &_comLScl, const unsigned int &_comHScl,
00410 const double &_sg1, const double &_sg2, const double &_sg3,
00411 const bool &_computeDepth, const double &_fx, const double &_cx, const double &_cy, const double &_baseline, const bool &_computeHashCoeffs, const double &_cropValue ):
00412 basePSize( _basePSize ), comLScl( _comLScl ), comHScl( _comHScl ),
00413 sg1( _sg1 ), sg2( _sg2 ), sg3( _sg3 ),
00414 computeDepth( _computeDepth ), fx( _fx ), cx( _cx ), cy( _cy ), baseline( _baseline ), computeHashCoeffs( _computeHashCoeffs), cropValue( _cropValue )
00415 {
00416 scales.resize( _scales.size() );
00417 for(unsigned int k = 0; k < _scales.size(); ++k)
00418 scales[k] = _scales[k];
00419 }
00420
00421 void loadFromConfigFile( const mrpt::utils::CConfigFileBase &cfg, const std::string §ion );
00422 void saveToConfigFile( mrpt::utils::CConfigFileBase &cfg, const std::string §ion );
00423 void dumpToTextStream( mrpt::utils::CStream &out) const;
00424
00425 };
00426
00427
00428 }
00429 }
00430
00431
00432 #endif