00001
00002
00003 #ifndef _FDETECT_DESCRIPTOR_HPP_
00004 #define _FDETECT_DESCRIPTOR_HPP_
00005
00006 #include <iostream>
00007
00008 #include "image/Image.hpp"
00009
00010 #include "fdetect/InterestFeature.hpp"
00011 #include "fdetect/DetectionResult.hpp"
00012
00013 namespace jafar {
00014 namespace fdetect {
00015 class InterestFeature;
00021 class Descriptor {
00022 public:
00023 Descriptor(InterestFeature* ip) : m_ip(ip) {};
00024 virtual ~Descriptor() {}
00025 public:
00027 virtual void print(std::ostream& s) const =0;
00032 virtual double weakComparison(Descriptor *) const =0;
00038 virtual double strongComparison(Descriptor *, double angle) const =0;
00039 virtual Descriptor* clone() = 0;
00040 protected:
00041 InterestFeature* interestFeature() const { return m_ip;}
00042 private:
00043 InterestFeature* m_ip;
00044
00045
00046
00047
00048
00049 };
00054 class DescriptorFactory {
00055 public:
00056 virtual ~DescriptorFactory() {}
00061 inline void createDescriptor(InterestFeature* ip, image::Image const& image) {
00062 jafar::fdetect::Descriptor* des = internalCreateDescriptor(ip, image);
00063 ip->setDescriptor(des);
00064 }
00065 inline void createDescriptor(DetectionResult vips, image::Image const& image) {
00066 for(vInterestFeatures_it it = vips.beginFeatures(); it != vips.endFeatures(); it++)
00067 {
00068 createDescriptor(*it, image);
00069 }
00070 }
00071 protected:
00072 virtual Descriptor* internalCreateDescriptor(InterestFeature* ip, image::Image const& image) = 0;
00073 };
00074
00075 }
00076
00077 namespace fdetect_v2 {
00083 class Descriptor
00084 {
00085 public:
00086 enum Type {NONE, HARRIS, FLOAT, DOUBLE};
00087 Descriptor() {}
00088 virtual ~Descriptor() {}
00089 public:
00090
00091
00092 virtual Type type()
00093 {
00094 return NONE;
00095 };
00096 };
00097
00102 template<typename InterestFeatureT>
00103 class DescriptorFactory
00104 {
00105 public:
00106 typedef typename InterestFeatureT::DescriptorType DescriptorType;
00107 virtual ~DescriptorFactory() {}
00112 void createDescriptor(InterestFeatureT* ip,
00113 image::Image const& image) {
00114 DescriptorType des = internalCreateDescriptor(ip, image);
00115 ip->setDescriptor(des);
00116 }
00121 void createDescriptor(fdetect_v2::DetectionResult<InterestFeatureT> vips,
00122 image::Image const& image) {
00123 for(typename DetectionResult<InterestFeatureT>::const_iterator it = vips.begin();
00124 it != vips.end();
00125 ++it)
00126 {
00127 createDescriptor(*it, image);
00128 }
00129 }
00130 protected:
00131 virtual DescriptorType internalCreateDescriptor(InterestFeatureT* ip, image::Image const& image) = 0;
00132 };
00133
00134 }
00135 }
00136
00137 #endif