00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef YAPE_H
00022 #define YAPE_H
00023
00024 #include <vector>
00025 #include <cv.h>
00026
00027 #include "pyrimage.h"
00028 #include "keypoint.h"
00029 #include "distortion.h"
00030
00031 const int yape_max_radius = 20;
00032
00086 class yape
00087 {
00088 public:
00090 yape(int width, int height);
00091 virtual ~yape();
00092
00093 void set_radius(int radius);
00094 int get_radius(void) { return radius; }
00095
00096 void set_tau(int tau);
00097 int get_tau(void) { return tau; }
00098
00099 void activate_bins(void) { set_use_bins(true); }
00100 void disactivate_bins(void) { set_use_bins(false); }
00101 void set_use_bins(bool p_use_bins) { use_bins = p_use_bins; }
00102 bool get_use_bins(void) { return use_bins; }
00103 void set_bins_number(int nb_u, int nb_v) { bin_nb_u = nb_u; bin_nb_v = nb_v;}
00104
00106 void activate_subpixel(void) { set_use_subpixel(true); }
00107 void disactivate_subpixel(void) { set_use_subpixel(false); }
00108 void set_use_subpixel(bool p_use_subpixel) { use_subpixel = p_use_subpixel; }
00109
00110 void set_minimal_neighbor_number(int p_minimal_neighbor_number) { minimal_neighbor_number = p_minimal_neighbor_number;}
00111 int get_minimal_neighbor_number(void) { return minimal_neighbor_number; }
00112
00113 int detect(IplImage * image, keypoint * points, int max_point_number, IplImage * smoothed_image = 0);
00114
00116 void raw_detect(IplImage *im);
00117
00119 int pick_best_points(keypoint * points, unsigned int max_point_number);
00120
00122 static int static_detect(IplImage * image, keypoint * points, int max_point_number, int radius = 7, int tau = 10);
00123
00125 IplImage * get_scores_image(void) { return scores; }
00126 IplImage * get_filtered_image(void) { return filtered_image; }
00127
00128 void subpix_refine(IplImage *im, keypoint *p);
00129
00130 protected:
00131 void reserve_tmp_arrays(void);
00132
00133 int get_local_maxima(IplImage * image, int R, float scale );
00134
00135 void perform_one_point(const unsigned char * I, const int x, short * Scores,
00136 const int Im, const int Ip,
00137 const short * dirs, const unsigned char opposite, const unsigned char dirs_nb);
00138
00139 bool double_check(IplImage * image, int x, int y, short * dirs, unsigned char dirs_nb);
00140 bool third_check(const short * Sb, const int next_line);
00141 int minimal_neighbor_number;
00142
00143 void precompute_directions(IplImage * image, short * _Dirs, int * _Dirs_nb, int R);
00144 void init_for_monoscale(void);
00145
00146
00147 int width, height;
00148
00149
00150 int radius;
00151
00152
00153 int tau;
00154
00155
00156 struct dir_table {
00157 short t[yape_max_radius][1024];
00158 };
00159 dir_table *Dirs;
00160 int *Dirs_nb;
00161
00162
00163 typedef std::vector<keypoint> keypoint_vector;
00164 keypoint_vector tmp_points;
00165
00166
00167 bool use_bins;
00168 keypoint_vector bins[10][10];
00169 int bin_nb_u, bin_nb_v;
00170
00171
00172 bool use_subpixel;
00173
00174
00175 IplImage * scores, * filtered_image;
00176
00177
00178 int stats_state[100], stats_iter[100];
00179
00180
00181 int score;
00182 int a, b;
00183 int A, B0, B1, B2;
00184 int state;
00185
00186 CvMat * H;
00187 CvMat * mg;
00188 CvMat * shift;
00189 };
00190
00192
00194 class pyr_yape : public yape {
00195 public:
00196 pyr_yape(int w, int h, int nbLev);
00197 virtual ~pyr_yape();
00198
00200 int pyramidBlurDetect(IplImage *im, keypoint *points, int max_point_number, PyrImage *caller_pim = 0);
00201
00203 int detect(IplImage *im, keypoint *points, int max_point_number)
00204 {
00205 return pyramidBlurDetect(im, points, max_point_number);
00206 }
00207
00209 int detect(PyrImage * image, keypoint * points, int max_point_number);
00210
00212 void stat_points(keypoint *points, int nb_pts);
00213
00214 DistortParams *distortParams;
00215
00216 static void cmp_orientation(PyrImage *im, keypoint *points, int nbpts);
00217
00218
00219 PyrImage *internal_pim;
00220 PyrImage *pscores;
00221 dir_table *pDirs[12];
00222 int *pDirs_nb[12];
00223
00225 bool equalize;
00226
00227 void select_level(int l);
00228 };
00229
00230 #endif // YAPE_H