Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
klt.h
00001 /*********************************************************************
00002  * klt.h
00003  *
00004  * Kanade-Lucas-Tomasi tracker
00005  *********************************************************************/
00006 
00007 #ifndef _KLT_H_
00008 #define _KLT_H_
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 typedef float KLT_locType;
00015 typedef unsigned char KLT_PixelType;
00016 
00017 #define KLT_BOOL int
00018 
00019 #ifndef TRUE
00020 #define TRUE  1
00021 #define FALSE 0
00022 #endif
00023 
00024 #ifndef NULL
00025 #define NULL  0
00026 #endif
00027 
00028 #define KLT_TRACKED           0
00029 #define KLT_NOT_FOUND        -1
00030 #define KLT_SMALL_DET        -2
00031 #define KLT_MAX_ITERATIONS   -3
00032 #define KLT_OOB              -4
00033 #define KLT_LARGE_RESIDUE    -5
00034 #define KLT_LANDSCAPE        -6
00035 
00036 #include "klt_util.h" /* for affine mapping */
00037 
00038 /*******************
00039  * Structures
00040  */
00041 
00042 typedef struct  {
00043   /* Available to user */
00044   int mindist;      /* min distance b/w features */
00045   int window_width, window_height;
00046   KLT_BOOL sequentialMode;  /* whether to save most recent image to save time */
00047   /* can set to TRUE manually, but don't set to */
00048   /* FALSE manually */
00049   KLT_BOOL smoothBeforeSelecting; /* whether to smooth image before */
00050   /* selecting features */
00051   KLT_BOOL writeInternalImages; /* whether to write internal images */
00052   /* tracking features */
00053   KLT_BOOL lighting_insensitive;  /* whether to normalize for gain and bias (not in original algorithm) */
00054   
00055   /* Available, but hopefully can ignore */
00056   int min_eigenvalue;   /* smallest eigenvalue allowed for selecting */
00057   float min_determinant;  /* th for determining lost */
00058   float min_displacement; /* th for stopping tracking when pixel changes little */
00059   int max_iterations;   /* th for stopping tracking when too many iterations */
00060   float max_residue;    /* th for stopping tracking when residue is large */
00061   float grad_sigma;
00062   float smooth_sigma_fact;
00063   float pyramid_sigma_fact;
00064   int nSkippedPixels;   /* # of pixels skipped when finding features */
00065   int borderx;      /* border in which features will not be found */
00066   int bordery;
00067   int nPyramidLevels;   /* computed from search_ranges */
00068   int subsampling;    /*    " */
00069 
00070   
00071   /* for affine mapping */ 
00072   int affine_window_width, affine_window_height;
00073   int affineConsistencyCheck; /* whether to evaluates the consistency of features with affine mapping 
00074          -1 = don't evaluates the consistency
00075          0 = evaluates the consistency of features with translation mapping
00076          1 = evaluates the consistency of features with similarity mapping
00077          2 = evaluates the consistency of features with affine mapping
00078             */
00079   int affine_max_iterations;  
00080   float affine_max_residue;
00081   float affine_min_displacement;        
00082   float affine_max_displacement_differ; /* th for the difference between the displacement calculated 
00083              by the affine tracker and the frame to frame tracker in pel*/
00084 
00085   /* User must not touch these */
00086   void *pyramid_last;
00087   void *pyramid_last_gradx;
00088   void *pyramid_last_grady;
00089 }  KLT_TrackingContextRec, *KLT_TrackingContext;
00090 
00091 
00092 typedef struct  {
00093   KLT_locType x, errorx;
00094   KLT_locType y, errory;
00095   int val, errorval;  
00096   /* for affine mapping */
00097   _KLT_FloatImage aff_img; 
00098   _KLT_FloatImage aff_img_gradx;
00099   _KLT_FloatImage aff_img_grady;
00100   KLT_locType aff_x;
00101   KLT_locType aff_y;
00102   KLT_locType aff_Axx;
00103   KLT_locType aff_Ayx;
00104   KLT_locType aff_Axy;
00105   KLT_locType aff_Ayy;
00106 }  KLT_FeatureRec, *KLT_Feature;
00107 
00108 typedef struct  {
00109   int nFeatures;
00110   KLT_Feature *feature;
00111 }  KLT_FeatureListRec, *KLT_FeatureList;
00112 
00113 typedef struct  {
00114   int nFrames;
00115   KLT_Feature *feature;
00116 }  KLT_FeatureHistoryRec, *KLT_FeatureHistory;
00117 
00118 typedef struct  {
00119   int nFrames;
00120   int nFeatures;
00121   KLT_Feature **feature;
00122 }  KLT_FeatureTableRec, *KLT_FeatureTable;
00123 
00124 
00125 
00126 /*******************
00127  * Functions
00128  */
00129 
00130 /* Create */
00131 KLT_TrackingContext KLTCreateTrackingContext(void);
00132 KLT_FeatureList KLTCreateFeatureList(
00133   int nFeatures);
00134 KLT_FeatureHistory KLTCreateFeatureHistory(
00135   int nFrames);
00136 KLT_FeatureTable KLTCreateFeatureTable(
00137   int nFrames,
00138   int nFeatures);
00139 
00140 /* Free */
00141 void KLTFreeTrackingContext(
00142   KLT_TrackingContext tc);
00143 void KLTFreeFeatureList(
00144   KLT_FeatureList fl);
00145 void KLTFreeFeatureHistory(
00146   KLT_FeatureHistory fh);
00147 void KLTFreeFeatureTable(
00148   KLT_FeatureTable ft);
00149 
00150 /* Processing */
00151 void KLTSelectGoodFeatures(
00152   KLT_TrackingContext tc,
00153   KLT_PixelType *img,
00154   int ncols,
00155   int nrows,
00156   KLT_FeatureList fl);
00157 void KLTSelectGoodFeaturesWindow(
00158   KLT_TrackingContext tc,
00159   KLT_PixelType *img,
00160   int ncols,
00161   int nrows,
00162   KLT_FeatureList fl,
00163   int zone_x, int zone_y, int zone_w, int zone_h);
00164 void KLTTrackFeatures(
00165   KLT_TrackingContext tc,
00166   KLT_PixelType *img1,
00167   KLT_PixelType *img2,
00168   int ncols,
00169   int nrows,
00170   KLT_FeatureList fl);
00171 void KLTReplaceLostFeatures(
00172   KLT_TrackingContext tc,
00173   KLT_PixelType *img,
00174   int ncols,
00175   int nrows,
00176   KLT_FeatureList fl);
00177 void KLTReplaceLostFeaturesWindow(
00178   KLT_TrackingContext tc,
00179   KLT_PixelType *img,
00180   int ncols,
00181   int nrows,
00182   KLT_FeatureList fl,
00183   int zone_x, int zone_y, int zone_w, int zone_h);
00184 
00185 /* Utilities */
00186 int KLTCountRemainingFeatures(
00187   KLT_FeatureList fl);
00188 void KLTPrintTrackingContext(
00189   KLT_TrackingContext tc);
00190 void KLTChangeTCPyramid(
00191   KLT_TrackingContext tc,
00192   int search_range);
00193 void KLTUpdateTCBorder(
00194   KLT_TrackingContext tc);
00195 void KLTStopSequentialMode(
00196   KLT_TrackingContext tc);
00197 void KLTSetVerbosity(
00198   int verbosity);
00199 float _KLTComputeSmoothSigma(
00200   KLT_TrackingContext tc);
00201 
00202 /* Storing/Extracting Features */
00203 void KLTStoreFeatureList(
00204   KLT_FeatureList fl,
00205   KLT_FeatureTable ft,
00206   int frame);
00207 void KLTExtractFeatureList(
00208   KLT_FeatureList fl,
00209   KLT_FeatureTable ft,
00210   int frame);
00211 void KLTStoreFeatureHistory(
00212   KLT_FeatureHistory fh,
00213   KLT_FeatureTable ft,
00214   int feat);
00215 void KLTExtractFeatureHistory(
00216   KLT_FeatureHistory fh,
00217   KLT_FeatureTable ft,
00218   int feat);
00219 
00220 /* Writing/Reading */
00221 void KLTWriteFeatureListToPPM(
00222   KLT_FeatureList fl,
00223   KLT_PixelType *greyimg,
00224   int ncols,
00225   int nrows,
00226   char *filename);
00227 void KLTWriteFeatureListToImg(
00228   KLT_FeatureList fl,
00229   KLT_PixelType *greyimg,
00230   int ncols,
00231   int nrows,
00232   KLT_PixelType *RGBimg);
00233 void KLTWriteFeatureList(
00234   KLT_FeatureList fl,
00235   char *filename,
00236   char *fmt);
00237 void KLTWriteFeatureHistory(
00238   KLT_FeatureHistory fh,
00239   char *filename,
00240   char *fmt);
00241 void KLTWriteFeatureTable(
00242   KLT_FeatureTable ft,
00243   char *filename,
00244   char *fmt);
00245 KLT_FeatureList KLTReadFeatureList(
00246   KLT_FeatureList fl,
00247   char *filename);
00248 KLT_FeatureHistory KLTReadFeatureHistory(
00249   KLT_FeatureHistory fh,
00250   char *filename);
00251 KLT_FeatureTable KLTReadFeatureTable(
00252   KLT_FeatureTable ft,
00253   char *filename);
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257 
00258 #endif
00259 
00260 
00261 
00262 
00263 
00264 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:24 for Jafar by doxygen 1.7.6.1
LAAS-CNRS