Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

/home/slang/XVision2/src/Tracking/XVFeature.h

00001 // *** BEGIN_XVISION2_COPYRIGHT_NOTICE ***
00002 // *** END_XVISION2_COPYRIGHT_NOTICE ***
00003 
00004 //-----------------------------------------------------------------------------
00005 //
00006 //  XVFeature.h
00007 //
00008 //  Sam Lang - 2.02.01
00009 //
00010 //-----------------------------------------------------------------------------
00011 
00012 
00013 #ifndef _XVFEATURE_H_
00014 #define _XVFEATURE_H_
00015 
00016 // Whatever types you decide to use for the STATE and ERROR of the XVStatePair,
00017 // the STATE type should be able to handle the operators + and - (adding or
00018 // subtracting two states)
00019 // and the ERROR type should be able to handle the logical operator &&
00020 // Also, You don't have to use the XVStatePair class to represent your states
00021 // in XVFeature and XVTracker, but if you don't, the class that you use should
00022 // also support the operators + and -
00023 // Abstractly, subtacting two states should give you a change in state (delta state)
00024 // or adding a change in state to a state should give you a new state.
00025 //
00026 
00027 template <class ST, class ER>
00028 class XVStatePair {
00029 
00030   typedef ST STATE;
00031   typedef ER ERROR;
00032 
00033  public:
00034   
00035   STATE state;
00036   ERROR error;
00037 
00038   XVStatePair(STATE s, ERROR e) : state(s), error(e) {}
00039   XVStatePair() {}
00040 };
00041 
00042 #define _XVSTATEPAIR_BIN_OP_(_OP_) \
00043 template <class ST, class ER> \
00044 XVStatePair<ST, ER> operator _OP_ (const XVStatePair<ST, ER> & s1, const XVStatePair<ST, ER> & s2){ \
00045   XVStatePair<ST, ER> newS; \
00046   newS.state = s1.state _OP_ s2.state; \
00047   newS.error = s1.error && s2.error; \
00048   return newS; \
00049 }
00050 
00051 _XVSTATEPAIR_BIN_OP_(+);
00052 _XVSTATEPAIR_BIN_OP_(-);
00053 
00054 #include <XVInteractive.h>
00055 
00056 template <class IMTYPE, class STATETYPE>
00057 class XVFeature {
00058 
00059  protected:
00060 
00061   STATETYPE currentState;
00062   bool  view;
00063 
00064  public:
00065 
00066   typedef STATETYPE STATE;
00067   typedef IMTYPE IMAGE;
00068 
00069   XVFeature() {}
00070   XVFeature(STATE init) : currentState(init) {}
00071   
00072   virtual void initState(STATE init) { currentState = init; view = true; }
00073 
00074   virtual STATE step(const IMTYPE &) = 0;
00075   
00076   // sets the state of this feature, then finds the next state from that
00077   virtual STATE step(const IMTYPE & im, const STATE & st){
00078 
00079     currentState = st;
00080     return this->step(im);    
00081   };
00082 
00083   virtual STATE getState(){ return currentState; }
00084   virtual void  setState(STATE & s){ currentState = s; };
00085 
00086   virtual bool inView(){ return view; }
00087 
00088   virtual STATE interactiveInit(XVInteractive &, const IMTYPE &) = 0;
00089   virtual void show(XVDrawable &) = 0;
00090 };
00091 
00092 #define _REGISTER_XVFEATURE_(_IM_TYPE_, _STATE_TYPE_) \
00093 template class XVFeature<_IM_TYPE_, _STATE_TYPE_ >;
00094 
00095 #endif

Generated at Thu Mar 29 22:37:28 2001 for XVision by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000