gml_FeatureTracker.h

00001 // gml_Tracker.h
00002 //
00003 //   Define of the gml_TFeatureTracker class.
00004 //
00005 //  Copyright (c) 2004 CLIPS-IMAG
00006 //
00007 //  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00008 //  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00009 //
00010 //  Created in March 2004 (JL).
00011 
00012 #ifndef __GML_TRACKER__
00013 #define __GML_TRACKER__
00014 
00015 // project includes
00016 #include "gml/base/gml_Errors.h"
00017 #include "gml/base/gml_Types.h"
00018 #include "gml/image/gml_Geometry.h"
00019 #include "gml/vision/gml_TrackedVector.h"
00020 #include "gml/base/gml_Timer.h"
00021 
00022 ////////////////////////////////////////////////////////////////////////////////
00023 //                                                                            //
00024 //                     gml_TFeatureTracker class declaration                  //
00025 //                                                                            //
00026 ////////////////////////////////////////////////////////////////////////////////
00027 
00028 /// gml_TFeatureTracker --
00029 ///
00030 ///   Track a set of points evolving in a 2D space over time.
00031 ///   Tracking is very basic here: no prediction, no filtering. It's well suited
00032 ///   for high frequency or slow movement applications.
00033 
00034 class gml_TFeatureTracker
00035 {
00036 public:
00037   ///
00038   /// Init --
00039   ///   Setup data structure for tracking
00040   ///
00041   gml_TError Init (
00042       UInt32 maxTrackedObjects,       ///< maximum number of simultaneously tracked objects
00043       gml_TArray<Float32>& maxSpeed,  ///< maximum speed of tracked objects, in pixels/second
00044       gml_TArray<Float32>& stability,
00045       gml_TArray<Float32>& weights
00046     );
00047     
00048   void Dispose ();
00049   
00050   ///
00051   /// Step --
00052   ///   Feed newly measured feature vectors to the tracker, and generate events.
00053   ///
00054   gml_TError Step (
00055       gml_TArray < gml_TArray<Float32> > features
00056     );
00057     
00058   ///
00059   /// Queue --
00060   ///   Return the queue of events to be processed
00061   ///
00062   gml_TError Queue (gml_TTrackedVector::EventQueue*& queue);
00063 
00064   ///
00065   /// Reset --
00066   ///   Forget about all known tracked objects.
00067   ///   The queue of events is updated accordingly with Disappear events.
00068   ///
00069   void Reset ();
00070 
00071   ///
00072   /// NbFeatures --
00073   ///
00074   UInt32 NbFeatures () { return fFeatures; }
00075   
00076   
00077 protected:
00078   gml_TTimer*                     fTimer;             ///< gives high-resolution absolute system time
00079   gml_TTrackedVector::EventQueue  fQueue;             ///< queue used to store the events
00080   UInt32                          fMaxTracks;         ///< maximum number of tracked objects
00081   UInt32                          fFeatures;          ///< number of features tracked
00082   gml_TArray<Float32>             fMaxSpeed;          ///< maximum speed of tracked objects, in pixels/second
00083   gml_TArray<Float32>             fStability;         ///< per-feature minimal displacement to suppose movement
00084   gml_TArray<Float32>             fWeights;           ///< per-feature weight used to calculate distances
00085   gml_TTrackedVector*             mTracked;           ///< array of currently tracked objects
00086   UInt32                          fNbTracks;          ///< number of objects currently tracked
00087   bool*                           mTrackedFlags;      ///< array of flags indicating if each
00088                                                       ///< of the corresponding elements in
00089                                                       ///< <mTracked> os in use
00090 
00091   // temporary storage for the Step() method
00092 
00093 private:
00094   SInt32 *mTrackedIndex;          ///< index of the gml_TPointFloat in <features> that
00095                                   ///< corresponds to each gml_TTrackedObject in <mTracked>
00096   bool *mFMatchFlags;             ///< indicates wether each point in <features> was
00097                                   ///< matched with a tracked object
00098   bool *mTFMatchFlags;            ///< indicates wether each tracked object in <mTracked>
00099                                   ///< was matched to a point in <points>
00100   gml_TArray<Float32> fMaxMove;   ///< per-feature maximal displacement to accept a match (calculated from fMaxSpeed)
00101 };
00102 
00103 #endif /* __FingerTracker__ */
00104 
Generated on Tue Jun 12 14:03:28 2007 for gml by Doxygen 1.5.2.