Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
InterestFeature.hpp
00001 /* $Id$ */
00002 
00003 #ifndef _FDETECT_INTERESTFEATURE_HPP_
00004 #define _FDETECT_INTERESTFEATURE_HPP_
00005 
00006 #include <iostream>
00007 #include <vector>
00008 #include <map>
00009 
00010 #include <boost/archive/text_oarchive.hpp>
00011 #include <boost/archive/text_iarchive.hpp>
00012 #include <boost/serialization/optional.hpp>
00013 #include <boost/optional.hpp>
00014 #include "geom/InterestPoint.hpp"
00015 #include "jmath/jblas.hpp"
00016 
00017 namespace jafar {
00018   namespace fdetect {
00019     class Descriptor;
00024     class InterestFeature : public geom::InterestPoint {
00025 
00026     public:
00032       InterestFeature() : InterestPoint(), m_descriptor(NULL) {}
00033       InterestFeature(double u, double v) : InterestPoint(u,v), m_descriptor(NULL) { }
00034       InterestFeature(InterestFeature const& m) { copy(m); }
00035       InterestFeature& operator=(InterestFeature const& m);
00036       ~InterestFeature();
00037       void setDescriptor(Descriptor* descriptor);
00038       inline Descriptor* descriptor() const { return m_descriptor; }
00039       unsigned int parent_id;
00040 
00041     private:
00042       Descriptor* m_descriptor;
00043       void copy(const InterestFeature& m);
00045       friend class boost::serialization::access;
00046       template<class Archive>
00047       void serialize(Archive & ar, const unsigned int /* file_version */){
00048         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(geom::InterestPoint);
00049         ar & *m_descriptor;
00050       }
00051     };
00053     //    BOOST_IS_ABSTRACT(geom::InterestPoint)
00054 
00055     typedef std::vector<jafar::fdetect::InterestFeature*> vInterestFeatures;
00056     typedef vInterestFeatures::iterator vInterestFeatures_it;
00057     typedef vInterestFeatures::const_iterator vInterestFeatures_cit;
00058     typedef std::map<double, jafar::fdetect::InterestFeature*> double2InterestFeature;
00059 #ifndef SWIG
00060     std::ostream& operator <<(std::ostream& s, const InterestFeature& p_);
00061 #endif
00062 
00063   }
00064 
00065   namespace fdetect_v2 {
00070     template<typename DESCRIPTOR>
00071     class InterestFeature : public geom::InterestPoint {
00072 
00073     public:
00074       typedef DESCRIPTOR DescriptorType;
00075       InterestFeature() : InterestPoint() { }
00081       InterestFeature(double u, double v) : InterestPoint(u,v) { }
00089       InterestFeature(double u, double v, float size, float angle) : 
00090         InterestPoint(u,v) 
00091       { 
00092         m_size.reset(size);
00093         m_angle.reset(angle);
00094       }
00095       void setDescriptor(const DescriptorType& descriptor) {
00096         m_descriptor = descriptor;
00097       };
00098       const DescriptorType& descriptor() const 
00099       { 
00100         return m_descriptor; 
00101       }
00102       DescriptorType& descriptor() 
00103       { 
00104         DescriptorType& desc_ref = m_descriptor;
00105         return desc_ref; 
00106       }
00107       unsigned int parent_id;
00109       void setSize(float size) { m_size.reset(size); }
00111       void setAngle(float angle) { m_angle.reset(angle); }
00113       float const* size() const { return get_pointer(m_size); }
00115       float const* angle() const { return get_pointer(m_angle); }
00116       
00117     private:
00118       boost::optional<float> m_size;
00119       boost::optional<float> m_angle;
00120       DescriptorType m_descriptor;
00122       friend class boost::serialization::access;
00123       template<class Archive>
00124       void serialize(Archive & ar, const unsigned int /* file_version */){
00125         ar & boost::serialization::base_object<geom::InterestPoint>(*this);
00126         ar & m_descriptor;
00127         ar & m_size;
00128         ar & m_angle;
00129       }
00130     };
00131 
00132     template<typename DESCRIPTOR, typename T>
00133     class InterestFeatureWithData : public InterestFeature<DESCRIPTOR> 
00134     {
00135     public:
00136       typedef T DataType;
00137       
00138       InterestFeatureWithData() : 
00139         InterestFeature<DESCRIPTOR>() {}
00145       InterestFeatureWithData(double u, double v) : 
00146         InterestFeature<DESCRIPTOR>(u,v) {}
00154       InterestFeatureWithData(double u, double v, float size, float angle) : 
00155         InterestFeature<DESCRIPTOR>(u,v,size,angle) {}
00157       void setData(const T& data) 
00158       {
00159         m_data = data;
00160       }
00162       T getData() 
00163       {
00164         return m_data;
00165       }
00166     private:
00167       T m_data;
00168     };
00170     //    BOOST_IS_ABSTRACT(geom::InterestPoint)
00171     // template <typename DescriptorType>
00172     // typedef std::vector< jafar::fdetect::InterestFeature< DescriptorType > > vInterestFeatures2;
00173     // typedef vInterestFeatures2::iterator vInterestFeatures2_it;
00174     // typedef vInterestFeatures2::const_iterator vInterestFeatures2_cit;
00175     // template <typename DescriptorType>
00176     // typedef std::map<double, jafar::fdetect::InterestFeature< DescriptorType > > double2InterestFeature;
00177 #ifndef SWIG
00178     template <typename DESCRIPTOR>
00179     std::ostream& operator <<(std::ostream& s, const InterestFeature< DESCRIPTOR >& p_)
00180     {
00181       s << "id: "<< p_.id() << " ";
00182       s << "position: " << p_.u() << "," << p_.v() << " "; 
00183       s << "descriptor: " << p_.descriptor();
00184       return s;
00185     }
00186 #endif
00187 
00188   }
00189 }
00190 
00191 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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