00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _VISUALFEATUREDESC_H_
00019 #define _VISUALFEATUREDESC_H_
00020
00021 #include "Object.h"
00022 #include <iostream>
00023
00024 namespace RobotFlow {
00025
00026 typedef enum
00027 {
00028 e_VISUALDESCRIPTOR_histogram = 0,
00029 e_VISUALDESCRIPTOR_integral,
00030 e_VISUALDESCRIPTOR_unknown
00031 } e_VISUALDESCRIPTOR_type;
00032
00033
00034
00035
00036
00037
00038 template <class FeatBaseType>
00039 class VisualFeatureDesc : public FD::Object
00040 {
00041 friend std::ostream &operator<<(std::ostream &o_out, const VisualFeatureDesc<FeatBaseType> &i_ref)
00042 {
00043 try {
00044 i_ref.printOn(o_out);
00045
00046 return o_out;
00047 }
00048 catch (FD::BaseException *e) {
00049 throw e->add(new FD::GeneralException("Exception in VisualFeatureDesc::operator<<:",__FILE__,__LINE__));
00050 }
00051 }
00052
00053 friend std::istream &operator>>(std::istream &i_in, VisualFeatureDesc<FeatBaseType> &o_ref)
00054 {
00055 try {
00056 o_ref.readFrom(i_in);
00057
00058 return i_in;
00059 }
00060 catch (FD::BaseException *e) {
00061 throw e->add(new FD::GeneralException("Exception in VisualFeatureDesc::operator>>:",__FILE__,__LINE__));
00062 }
00063 }
00064
00065 public:
00066 VisualFeatureDesc()
00067 : m_descType(e_VISUALDESCRIPTOR_unknown)
00068 {
00069 }
00070
00071 VisualFeatureDesc(e_VISUALDESCRIPTOR_type i_descType)
00072 : m_descType(i_descType)
00073 {
00074 }
00075
00076 VisualFeatureDesc(const VisualFeatureDesc<FeatBaseType> &i_ref)
00077 {
00078 m_descType = i_ref.m_descType;
00079 }
00080
00081 virtual ~VisualFeatureDesc()
00082 {
00083
00084 }
00085
00086 virtual VisualFeatureDesc<FeatBaseType> & operator =(const VisualFeatureDesc<FeatBaseType> &i_ref)
00087 {
00088
00089 if (&i_ref != this) {
00090 this->m_descType = i_ref.m_descType;
00091 }
00092
00093 return *this;
00094 }
00095
00096 virtual VisualFeatureDesc<FeatBaseType>* clone() const
00097 {
00098 return new VisualFeatureDesc<FeatBaseType>(*this);
00099 }
00100
00101
00102 virtual void printOn(std::ostream &out) const
00103 {
00104 throw new FD::GeneralException("Exception in VisualFeatureDesc::printOn: cannot use base class routine.",__FILE__,__LINE__);
00105 }
00106
00107
00108 virtual void readFrom(std::istream &in)
00109 {
00110 throw new FD::GeneralException("Exception in VisualFeatureDesc::readFrom: cannot use base class routine.",__FILE__,__LINE__);
00111 }
00112
00113 virtual double Similarity(const FeatBaseType *i_candidate, unsigned int i_size) const
00114 {
00115 throw new FD::GeneralException("Exception in VisualFeatureDesc::Similarity: cannot use base class routine.",__FILE__,__LINE__);
00116 }
00117
00118 virtual void Adapt(const FeatBaseType *i_candidate, unsigned int i_size, double i_rate)
00119 {
00120 throw new FD::GeneralException("Exception in VisualFeatureDesc::Adapt: cannot use base class routine.",__FILE__,__LINE__);
00121 }
00122
00123 virtual unsigned int GetSize() const
00124 {
00125 throw new FD::GeneralException("Exception in VisualFeatureDesc::GetSize: cannot use base class routine.",__FILE__,__LINE__);
00126 }
00127
00128 virtual FeatBaseType *GetFeatures()
00129 {
00130 throw new FD::GeneralException("Exception in VisualFeatureDesc::GetFeatures: cannot use base class routine.",__FILE__,__LINE__);
00131 }
00132
00133 virtual const FeatBaseType *GetCstFeatures() const
00134 {
00135 throw new FD::GeneralException("Exception in VisualFeatureDesc::GetCstFeatures: cannot use base class routine.",__FILE__,__LINE__);
00136 }
00137
00138 virtual bool GetValidity() const
00139 {
00140 throw new FD::GeneralException("Exception in VisualFeatureDesc::GetValidity: cannot use base class routine.",__FILE__,__LINE__);
00141 }
00142
00143 e_VISUALDESCRIPTOR_type GetType() const { return m_descType; }
00144
00145 void SetType(e_VISUALDESCRIPTOR_type i_type)
00146 {
00147 m_descType = i_type;
00148 }
00149
00150 virtual void SetSize(unsigned int i_size)
00151 {
00152 throw new FD::GeneralException("Exception in VisualFeatureDesc::SetSize: cannot use base class routine.",__FILE__,__LINE__);
00153 }
00154
00155 virtual void SetFeatures(const FeatBaseType *i_ref, unsigned int i_size)
00156 {
00157 throw new FD::GeneralException("Exception in VisualFeatureDesc::SetFeatures: cannot use base class routine.",__FILE__,__LINE__);
00158 }
00159
00160 virtual void SetValidity(bool i_flag)
00161 {
00162 throw new FD::GeneralException("Exception in VisualFeatureDesc::SetValidity: cannot use base class routine.",__FILE__,__LINE__);
00163 }
00164
00165 private:
00166 e_VISUALDESCRIPTOR_type m_descType;
00167 };
00168
00169 }
00170
00171 #endif