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

/home/slang/XVision2/src/Pipes/PipeTracker.h

00001 # ifndef _PIPETRACKER_H_
00002 # define _PIPETRACKER_H_
00003 
00004 # include "PipeImage.h"
00005 
00006 // basically PipeTracker and PipeFeature  is a wrapper for XVFeature
00007 // while the loop is close in the fomer and open in the latter.
00008 
00009 template <class IMTYPE, class STATETYPE> class XVFeature;
00010 
00011 template<class C, class R, class A> 
00012 inline R (C::*_get_feature_step(void))(const A&) {
00013   return &C::step ;
00014 }
00015 
00016 template<class FEATURE>
00017 class PipeTracker : 
00018 public PipeModuleLift1<typename FEATURE::STATE, typename FEATURE::IMAGE,
00019  XVClassPtrFun1<typename FEATURE::STATE (XVFeature<typename FEATURE::IMAGE,
00020  typename FEATURE::STATE>::*)(const typename FEATURE::IMAGE &), 
00021  typename FEATURE::STATE, typename FEATURE::IMAGE, FEATURE> > {
00022   typedef typename FEATURE::STATE STATE ;
00023   typedef typename FEATURE::IMAGE IMAGE ;
00024   typedef XVFeature<IMAGE,STATE> BASEFEATURE ;
00025   typedef STATE (BASEFEATURE::*FUNPTR)(const IMAGE &) ;
00026   typedef XVClassPtrFun1<FUNPTR,STATE,IMAGE,FEATURE> FUN ;
00027   typedef PipeTracker<FEATURE> ThisType ;
00028   typedef PipeModuleLift1<STATE,IMAGE,FUN> BaseType;
00029  protected:
00030   ThisType * duplicate(void) const { return new ThisType(*this); }
00031  public:
00032   PipeTracker( FEATURE& f ) : 
00033     BaseType(FUN(_get_feature_step<BASEFEATURE,STATE,IMAGE>(),&f)) {}
00034   PipeTracker( const ThisType& f ) : BaseType(f) {}
00035   FEATURE * operator -> () { return fn.operator->() ; }
00036   const FEATURE * operator -> () const { return fn.operator->() ; }
00037   void show( XVDrawable& x ) { if( fn->inView() ) return fn->show(x) ; }
00038 
00039   // wrapper for initiativeInit
00040   template<class PIXEL>
00041   STATE init( Video<PIXEL>& video ) {
00042     XVImageRGB<PIXEL> image = video.next_frame_continuous();
00043     XVInteractWindowX<XV_RGB> win(&image);
00044     win.map();
00045     win.CopySubImage(&image);
00046     win.swap_buffers();
00047     win.flush();
00048     STATE r = fn->interactiveInit(win,image);
00049     win.unmap();
00050     return r ;
00051   }
00052 };
00053 
00054 template<class C, class R, class A1> 
00055 inline R (C::*_get_feature_step2(void))(const A1&, const R&) {
00056   return &C::step ;
00057 }
00058 
00059 template<class FEATURE>
00060 class PipeFeature : 
00061 public PipeModuleLift2<typename FEATURE::STATE, typename FEATURE::IMAGE,
00062  typename FEATURE::STATE, XVClassPtrFun2<typename FEATURE::STATE 
00063  (XVFeature<typename FEATURE::IMAGE,typename FEATURE::STATE>::*)
00064  (const typename FEATURE::IMAGE&, const typename FEATURE::STATE&), 
00065  typename FEATURE::STATE, typename FEATURE::IMAGE, typename FEATURE::STATE,
00066  FEATURE> > {
00067   typedef typename FEATURE::STATE STATE ;
00068   typedef typename FEATURE::IMAGE IMAGE ;
00069   typedef XVFeature<IMAGE,STATE> BASEFEATURE ;
00070   typedef STATE (BASEFEATURE::*FUNPTR)(const IMAGE &, const STATE&) ;
00071   typedef XVClassPtrFun2<FUNPTR,STATE,IMAGE,STATE,FEATURE> FUN ;
00072   typedef PipeFeature<FEATURE> ThisType ;
00073   typedef PipeModuleLift2<STATE,IMAGE,STATE,FUN> BaseType;
00074  protected:
00075   ThisType * duplicate(void) const { return new ThisType(*this); }
00076  public:
00077   PipeFeature( FEATURE& f ) : 
00078     BaseType(FUN(_get_feature_step2<BASEFEATURE,STATE,IMAGE>(),&f)) {}
00079   PipeFeature( const ThisType& f ) : BaseType(f) {}
00080   FEATURE * operator -> () { return fn.operator->() ; }
00081   const FEATURE * operator -> () const { return fn.operator->() ; }
00082   void show( XVDrawable& x ) { if( fn->inView() ) return fn->show(x) ; }
00083 
00084   // wrapper for initiativeInit
00085   template<class PIXEL>
00086   STATE init( Video<PIXEL>& video ) {
00087     XVImageRGB<PIXEL> image = video.next_frame_continuous();
00088     XVInteractWindowX<XV_RGB> win(&image);
00089     win.map();
00090     win.CopySubImage(&image);
00091     win.swap_buffers();
00092     win.flush();
00093     STATE r = fn->interactiveInit(win,image);
00094     win.unmap();
00095     return r ;
00096   }
00097 };
00098 
00099 # endif //_PIPETRACKER_H_

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