gml_FingerFinder.h

00001 // gml_FingerFinder.h --
00002 //
00003 //    Define the gml_TFingerFinder class.
00004 //
00005 //  Copyright (c) 2003-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 April 2003 (JL).
00011 //  Revamped in February 2004 (JL).
00012 
00013 #ifndef __GML_FINGER_FINDER__
00014 #define __GML_FINGER_FINDER__
00015 
00016 #include "gml/base/gml_Errors.h"
00017 #include "gml/base/gml_Types.h"
00018 #include "gml/image/gml_Geometry.h"
00019 #include "gml/image/gml_Bitmap.h"
00020 #include "gml/vision/gml_Connexer.h"
00021 
00022 
00023 ////////////////////////////////////////////////////////////////////////////////
00024 //                                                                            //
00025 //                         gml_TFinger class declaration                      //
00026 //                                                                            //
00027 ////////////////////////////////////////////////////////////////////////////////
00028 
00029 ///
00030 /// Represent fingers found in images
00031 ///
00032 struct gml_TFinger
00033 {
00034   gml_TPointFloat fCenter;        ///< position of the fingertip center (pixels)
00035   gml_TPointFloat fOrientation;   ///< vector giving the finger orientation (pixels)
00036   Float32         fRadius;        ///< fingertip radius (pixels)
00037 } ;
00038 
00039 ////////////////////////////////////////////////////////////////////////////////
00040 //                                                                            //
00041 //                     gml_TFingerFinder class declaration                    //
00042 //                                                                            //
00043 ////////////////////////////////////////////////////////////////////////////////
00044 
00045 
00046 /// A complex scanner that processes a segmentation map (scalar image) and
00047 /// detects fingertip-shaped regions.
00048 ///
00049 /// @warning
00050 /// the data members are made public so the <finger_finder> scanner can
00051 /// access them; they are *not* to be modified by client code !
00052 
00053 class gml_TFingerFinder
00054 {
00055 public:
00056 
00057   ///
00058   /// Init --
00059   ///   Setup the data structures.
00060   ///
00061   gml_TError Init ();
00062   
00063   ///
00064   /// Dispose --
00065   ///   Release the data structures.
00066   ///
00067   void Dispose ();
00068   
00069   ///
00070   /// Setup --
00071   ///   Setup the data structures for a given view scale.
00072   /// If the <reqViewScale> hasn't changed the data structures no
00073   /// allocation or computation will occur.
00074   ///
00075   gml_TError Setup (
00076     Float64 reqViewScale            ///< requested view scale (meters/pixel)
00077   );
00078   
00079   ///
00080   /// Process --
00081   ///   Process the <source> bitmap and place in <fingers> the detected fingertips.
00082   ///
00083   gml_TError Process (
00084     gml_TBitmap* source,            ///< [in]    source bitmap (binary image)
00085     gml_TRect*   sourceRect,        ///< [in]    source region of interest
00086     gml_TBoolean flagRejectMap,     ///< [in]    if true, <source> will be overwritten with a rejection map
00087     UInt32       reqTipFillFactor,  ///< [in]    minimal density around a fingertip
00088     UInt16      &nbFingers,         ///< [inout] input: maximum number of fingers (size of the <finger> array);
00089                                     ///<         output: actual number of detected fingers
00090     gml_TFinger* fingers            ///< [out]   detected fingertips
00091   );
00092 
00093   ///
00094   /// Dump --
00095   ///   Write the fields' value to stdout.
00096   ///
00097   void Dump ();
00098   
00099 public:
00100   // 
00101   // Defaults and constants
00102   //
00103 
00104   /// fingers are between 9 and 20 millimiters wide
00105   static Float64 sMinFingerRadius  () { return 4.5e-3;  }    ///< meters
00106   static Float64 sMaxFingerRadius  () { return 10.0e-3; }    ///< meters
00107 
00108   /// default view ratio
00109   static Float64 sDefaultViewScale () { return 2.0e-3;  }    ///< meters / pixel
00110 
00111   /// default required fill factor for fingertip regions
00112   static UInt8 sDefaultTipFillFactor () { return 90;    }    ///< percentage
00113 
00114 public:
00115   //
00116   // Private fields
00117   //
00118     
00119   Float64 fViewScale;           ///< the view ratio, expressed in meters / pixel
00120   UInt32  fTipFillFactor;       ///< the required fill factor of fingertips, percentage
00121 
00122   UInt32  fMinFingerRadius;     ///< the minimum finger radius, pixels
00123   UInt32  fMaxFingerRadius;     ///< the maximum finger radius, pixels
00124   
00125   SInt32  fDiskDiameter;        ///< pixels
00126   UInt8  *fDiskMask;            ///< as given by gml_Bresenham_DiskMask
00127   UInt32  fDiskArea;            ///< disk area
00128 
00129   SInt32  fCircleDiameter;      ///< pixels
00130   UInt32  fCircleNbPoints;      ///< number of contour points
00131   gml_TPoint *fCirclePointList; ///< list of relative contour points as given by gml_Bresenham_CirclePoints
00132   UInt32 *fPointsBuffer;        ///< temporary storage for contour points
00133   
00134   UInt32  fMinContourPoints;    ///< minimum number of contour pixels for a valid finger
00135   UInt32  fMaxContourPoints;    ///< maximum number of contour pixels for a valid finger
00136 
00137 protected:  
00138   gml_TConnexer *fConnexer;     ///< analyzer used to pre- and post-process the bitmap
00139   gml_TBitmap   *fFingerMap;    ///< output of the finger-finding scanner
00140   
00141 protected:
00142   //
00143   // Protected utility methods
00144   //
00145   
00146   /// Allocate <fFingerMap> as a G_8 bitmap the same size as <source> (if necessary)
00147   /// and zero it
00148   gml_TError AllocateAndZeroMap (gml_TBitmap *source);
00149 
00150 } ;
00151 
00152 
00153   
00154 
00155 #endif /* __GML_FINGER_FINDER__ */
00156 
Generated on Tue Jun 12 14:03:28 2007 for gml by Doxygen 1.5.2.