bazar  1.3.1
yape.h
Go to the documentation of this file.
1 /*
2 Copyright 2005, 2006 Computer Vision Lab,
3 Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4 All rights reserved.
5 
6 This file is part of BazAR.
7 
8 BazAR is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 BazAR is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 BazAR; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21 #ifndef YAPE_H
22 #define YAPE_H
23 
24 #include <vector>
25 #include <cv.h>
26 
27 #include <starter.h>
28 #include "keypoint.h"
29 
30 const int yape_max_radius = 20;
31 
88 class yape
89 {
90 public:
92  yape(int width, int height);
93  virtual ~yape();
94 
95  void set_radius(int radius);
96  int get_radius(void) { return radius; }
97 
98  void set_tau(int tau);
99  int get_tau(void) { return tau; }
100 
101  void activate_bins(void) { set_use_bins(true); } // Default
102  void disactivate_bins(void) { set_use_bins(false); }
103  void set_use_bins(bool p_use_bins) { use_bins = p_use_bins; }
104  bool get_use_bins(void) { return use_bins; }
105  void set_bins_number(int nb_u, int nb_v) { bin_nb_u = nb_u; bin_nb_v = nb_v;}
106 
108  void activate_subpixel(void) { set_use_subpixel(true); }
109  void disactivate_subpixel(void) { set_use_subpixel(false); } // Default
110  void set_use_subpixel(bool p_use_subpixel) { use_subpixel = p_use_subpixel; }
111 
112  void set_minimal_neighbor_number(int p_minimal_neighbor_number) { minimal_neighbor_number = p_minimal_neighbor_number;}
114 
115  int detect(IplImage * image, keypoint * points, int max_point_number, IplImage * smoothed_image = 0);
116 
118  void raw_detect(IplImage *im);
119 
121  int pick_best_points(keypoint * points, unsigned int max_point_number);
122 
124  static int static_detect(IplImage * image, keypoint * points, int max_point_number, int radius = 7, int tau = 10);
125 
127  void save_image_of_detected_points(char * name, IplImage * image, keypoint * points, int points_nb);
128 
130  IplImage * get_scores_image(void) { return scores; }
131  IplImage * get_filtered_image(void) { return filtered_image; }
132 
133  void subpix_refine(IplImage *im, keypoint *p);
134 
135 protected:
136  void reserve_tmp_arrays(void);
137 
138  int get_local_maxima(IplImage * image, int R, float scale /*, keypoint * points, int max_point_number */);
139 
140  void perform_one_point(const unsigned char * I, const int x, short * Scores,
141  const int Im, const int Ip,
142  const short * dirs, const unsigned char opposite, const unsigned char dirs_nb);
143 
144  bool double_check(IplImage * image, int x, int y, short * dirs, unsigned char dirs_nb);
145  bool third_check(const short * Sb, const int next_line);
147 
148  void precompute_directions(IplImage * image, short * _Dirs, int * _Dirs_nb, int R);
149  void init_for_monoscale(void);
150 
151  // Image size:
152  int width, height;
153 
154  // Radius: scale parameter for point detection
155  int radius;
156 
157  // Tau: threshold to decide if two intensities are similar.
158  int tau;
159 
160  // Directions:
161  struct dir_table {
162  short t[yape_max_radius][1024];
163  };
165  int *Dirs_nb;
166 
167  // For keypoint sorting:
168  typedef std::vector<keypoint> keypoint_vector;
170 
171  // Bins etc:
172  bool use_bins;
175 
176  // Subpixel (always 'on' for pyramidal version)
178 
179  // Intermediate images:
180  IplImage * scores, * filtered_image;
181 
182  // For statistics in the Finite State Machine:
183  int stats_state[100], stats_iter[100];
184 
185  // For the Finite State Machine:
186  int score;
187  int a, b;
188  int A, B0, B1, B2;
189  int state;
190 
191  CvMat * H;
192  CvMat * mg;
193  CvMat * shift;
194 };
195 
197 
200 class pyr_yape : public yape {
201 public:
202  pyr_yape(int w, int h, int nbLev);
203  virtual ~pyr_yape();
204 
206  int pyramidBlurDetect(IplImage *im, keypoint *points, int max_point_number, PyrImage *caller_pim = 0);
207 
209  int detect(IplImage *im, keypoint *points, int max_point_number)
210  {
211  return pyramidBlurDetect(im, points, max_point_number);
212  }
213 
215  int detect(PyrImage * image, keypoint * points, int max_point_number);
216 
218  void save_image_of_detected_points(char * name, IplImage * image, keypoint * points, int points_nb);
219 
221  void stat_points(keypoint *points, int nb_pts);
222 
223 //protected:
224  PyrImage *internal_pim; //< pyramid image, recylcled for each frame
227  int *pDirs_nb[12];
228 
230  bool equalize;
231 
232  void select_level(int l);
233 };
234 
235 #endif // YAPE_H