Go to the documentation of this file.00001
00002 #ifndef sdet_nms_h
00003 #define sdet_nms_h
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <vcl_vector.h>
00044 #include <vbl/vbl_array_2d.h>
00045 #include <vil/vil_image_view.h>
00046 #include <vgl/vgl_point_2d.h>
00047 #include <vgl/vgl_vector_2d.h>
00048
00049
00050 class sdet_nms_params
00051 {
00052 public:
00053
00054 enum PFIT_TYPE {PFIT_3_POINTS=0, PFIT_9_POINTS=1};
00055
00056 double thresh_;
00057 PFIT_TYPE pfit_type_;
00058 unsigned margin_;
00059 double rel_thresh_;
00060 bool use_adaptive_thresh_;
00061
00062 sdet_nms_params(double thresh=1.0, PFIT_TYPE pfit_type=PFIT_3_POINTS, unsigned margin=1, double rel_thresh=2.5, bool adaptive_thresh=false):
00063 thresh_(thresh), pfit_type_(pfit_type), margin_(margin), rel_thresh_(rel_thresh), use_adaptive_thresh_(adaptive_thresh) {}
00064 ~sdet_nms_params() {}
00065 };
00066
00067 class sdet_nms
00068 {
00069 protected:
00070 double thresh_;
00071 sdet_nms_params::PFIT_TYPE parabola_fit_type_;
00072 unsigned margin_;
00073 double rel_thresh_;
00074 bool use_adaptive_thresh_;
00075
00076
00077 const vil_image_view<double>& dir_x_;
00078 const vil_image_view<double>& dir_y_;
00079 const vil_image_view<double>& grad_mag_;
00080
00081
00082
00083
00084 vbl_array_2d<double> x_;
00085 vbl_array_2d<double> y_;
00086 vbl_array_2d<double> dir_;
00087 vbl_array_2d<double> mag_;
00088 vbl_array_2d<double> deriv_;
00089
00090 protected:
00091
00092 sdet_nms();
00093
00094 public:
00095
00096 sdet_nms(const sdet_nms_params& nsp,
00097 const vil_image_view<double>& dir_x,
00098 const vil_image_view<double>& dir_y,
00099 const vil_image_view<double>& grad_mag);
00100
00101
00102 ~sdet_nms() {}
00103
00104
00105 unsigned width() const { return mag_.cols(); }
00106 unsigned height() const { return mag_.rows(); }
00107
00108
00109 vbl_array_2d<double>& mag() { return mag_; }
00110
00111
00112 vbl_array_2d<double>& deriv() { return deriv_; }
00113
00114
00115 void apply() {}
00116
00117
00118 void apply( bool collect_tokens,
00119 vcl_vector<vgl_point_2d<double> >& loc,
00120 vcl_vector<double>& orientation,
00121 vcl_vector<double>& mag);
00122
00123 void apply( bool collect_tokens,
00124 vcl_vector<vgl_point_2d<double> >& loc,
00125 vcl_vector<double>& orientation,
00126 vcl_vector<double>& mag,
00127 vcl_vector<double>& d2f);
00128
00129 void apply( bool collect_tokens,
00130 vcl_vector<vgl_point_2d<double> >& loc,
00131 vcl_vector<double>& orientation,
00132 vcl_vector<double>& mag,
00133 vcl_vector<double>& d2f,
00134 vcl_vector<vgl_point_2d<int> >& pix_loc);
00135
00136 void clear();
00137
00138
00139
00140 int intersected_face_number(const vgl_vector_2d<double>& direction);
00141 double intersection_parameter(const vgl_vector_2d<double>& direction, int face_num);
00142 void f_values(int x, int y, const vgl_vector_2d<double>& direction, double s, int face_num, double *f);
00143
00144 void get_relative_corner_coordinates(int face_num, int *corners);
00145
00146 double subpixel_s(double *s, double *f, double & max_f, double &max_d);
00147
00148 double subpixel_s(int x, int y, const vgl_vector_2d<double>& direction, double &max_f);
00149 void find_distance_s_and_f_for_point(int x, int y, vgl_homg_line_2d<double> line,
00150 double &d, double &s, const vgl_vector_2d<double>& direction);
00151 };
00152
00153
00154 #endif // sdet_nms_h