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 #ifndef CFeature_H
00029 #define CFeature_H
00030
00031 #include <mrpt/utils/CMRPTImage.h>
00032
00033 namespace mrpt
00034 {
00035 namespace vision
00036 {
00037 using namespace mrpt::utils;
00038
00039 class MRPTDLLIMPEXP CFeatureList;
00040 class MRPTDLLIMPEXP CMatchedFeatureList;
00041
00044 typedef uint64_t TFeatureID;
00047 enum TFeatureType
00048 {
00051 featSIFT,
00054 featKLT,
00057 featHarris,
00060 featSURF,
00063 featNotDefined
00064 };
00065
00066 enum TKLTFeatureStatus
00067 {
00070 statusKLT_IDLE,
00073 statusKLT_OOB,
00076 statusKLT_SMALL_DET,
00079 statusKLT_LARGE_RESIDUE,
00082 statusKLT_MAX_RESIDUE,
00085 statusKLT_TRACKED,
00088 statusKLT_MAX_ITERATIONS
00089 };
00090
00091
00092
00093
00094 DEFINE_SERIALIZABLE_PRE( CFeature )
00097 class MRPTDLLIMPEXP CFeature : public mrpt::utils::CSerializable
00098 {
00099 friend class CFeatureList;
00100 friend class CMatchedFeatureList;
00101
00102 DEFINE_SERIALIZABLE( CFeature )
00103
00104 public:
00107 float x,y;
00110 TFeatureID ID;
00111
00114 CMRPTImage patch;
00115
00118 unsigned int patchSize;
00119
00122 TFeatureType type;
00123
00126 TKLTFeatureStatus KLT_status;
00127
00130 float KLT_val;
00131
00134 float orientation;
00135
00138 float scale;
00139
00142 std::vector<unsigned char> descriptorSIFT;
00143
00146 std::vector<unsigned char> descriptorSURF;
00147
00150 bool hasDescriptorSIFT;
00151
00154 bool hasDescriptorSURF;
00155
00158 float descriptorSIFTDistanceTo( const CFeature &oFeature ) const;
00159
00162 float descriptorSURFDistanceTo( const CFeature &oFeature ) const;
00163
00166 TFeatureType get_type() const { return type; }
00167
00170 CFeature();
00171
00173 virtual ~CFeature() {}
00174
00175
00176 protected:
00177
00178
00179 };
00180
00181
00182
00183
00186 class MRPTDLLIMPEXP CFeatureList : public std::deque<CFeaturePtr>
00187 {
00188 public:
00189
00192 TFeatureType get_type() const {
00193 if( size() > 0 )
00194 return (*begin())->get_type();
00195 else
00196 return featNotDefined;
00197 }
00198
00201 void saveToTextFile( const std::string &fileName, bool APPEND = false );
00202
00205 TFeatureID getMaxID();
00206
00209 CFeaturePtr getByID( TFeatureID ID ) const;
00210
00213 void insert( const CFeaturePtr &feat );
00214
00217 CFeatureList::iterator remove( CFeatureList::iterator itFeat );
00218
00221 CFeatureList();
00222
00225 CFeatureList(const CFeatureList &o);
00226
00229 CFeatureList& operator=(const CFeatureList &o);
00230
00232 virtual ~CFeatureList();
00233
00234 };
00235
00236
00237
00238
00241 class MRPTDLLIMPEXP CMatchedFeatureList : public std::deque< std::pair<CFeaturePtr,CFeaturePtr> >
00242 {
00243 public:
00246 TFeatureType get_type() const {
00247 if( size() > 0 )
00248 return (begin()->first)->get_type();
00249 else
00250 return featNotDefined;
00251 }
00252
00255 void saveToTextFile(const std::string &fileName);
00256
00259 void insert( std::pair<CFeaturePtr,CFeaturePtr> mFeats );
00260
00263 CMatchedFeatureList::iterator remove( CMatchedFeatureList::iterator pMatchedFeats );
00264
00267 CMatchedFeatureList();
00268
00271 CMatchedFeatureList(const CMatchedFeatureList &o);
00272
00275 CMatchedFeatureList& operator=(const CMatchedFeatureList &o);
00276
00278 virtual ~CMatchedFeatureList();
00279 };
00280
00281 }
00282 }
00283
00284 #endif
00285