Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
dataBase.hpp
00001 /* $Id$ */
00002 
00003 #ifndef SIFT_DATA_BASE_HPP
00004 #define SIFT_DATA_BASE_HPP
00005 
00006 #include <iostream>
00007 #include <list>
00008 
00009 #include "boost/numeric/ublas/vector.hpp"
00010 
00011 namespace jafar {
00012   namespace sift {
00013 
00015     typedef boost::numeric::ublas::bounded_vector<int, 128> DescriptorType;
00016 
00018     int descriptorDistSquared(DescriptorType const& d1, DescriptorType const& d2);
00019 
00023     struct DBKey {
00024 
00025       typedef unsigned int IdType;
00026       static const unsigned int NoId = 0;
00027 
00028       IdType id;
00029       DescriptorType descriptor;
00030 
00031       DBKey(IdType id_, DescriptorType descriptor_) : 
00032   id(id_), descriptor(descriptor_) {}
00033 
00034     };
00035 
00039     struct SiftPoint {
00040 
00041       SiftPoint() : id(DBKey::NoId) {}
00042       SiftPoint(SiftPoint const& pt) :
00043   id(pt.id), u(pt.u), v(pt.v), scale(pt.scale), orientation(pt.orientation), descriptor(pt.descriptor) {}
00044 
00045       DBKey::IdType id;
00046 
00047       float u, v;
00048       float scale, orientation;
00049       DescriptorType descriptor;
00050 
00051     };
00052 
00053     std::ostream& operator <<(std::ostream& s, const SiftPoint& pt);
00054 
00059     class DataBase {
00060 
00061     private:
00062 
00063       DBKey::IdType idFactory;
00064       DBKey::IdType getId() {return ++idFactory;}
00065 
00066       typedef std::list<DBKey> DBKeysType;
00067 
00068       DBKeysType p_dbKeys;
00069 
00070     public:
00071 
00072       DataBase() : idFactory(DBKey::NoId) {};
00073       ~DataBase() {};
00074 
00081       bool findPoint(SiftPoint& pt, bool addToDb = false);
00082       
00083       template<class Container>
00084       void processPoints(Container& siftPoints, bool addToDb = false) {
00085   for (typename Container::iterator it = siftPoints.begin() ; it != siftPoints.end() ; ++it) {
00086     findPoint(*it, addToDb);
00087   }
00088       }
00089 
00090     };
00091 
00092   }
00093 }
00094 
00095 #endif // SIFT_DATA_BASE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:27 for Jafar by doxygen 1.7.6.1
LAAS-CNRS