Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

VisualFeatureDesc.h

Go to the documentation of this file.
00001 /* Copyright (C) 2005 Pierre Moisan (Pierre.Moisan@USherbrooke.ca) 
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Lesser General Public
00005    License as published by the Free Software Foundation; either
00006    version 2.1 of the License, or (at your option) any later version.
00007    
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Lesser General Public License for more details.
00012    
00013    You should have received a copy of the GNU Lesser General Public
00014    License along with this library; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 // This should be an abstract base class. Since many containers (like Vector)
00035 // do not allow abstract functions, each abstract function throws an exception
00036 // to avoid the direct use of the base class "abstract" routines.
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                         // Enable cascading
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                         // Enable cascading
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                 // Avoid self assignment
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         // Default routine to print a VisualFeatureDesc object to an output stream
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         // Default routine to read a VisualFeatureDesc object from an input stream
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

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4