00001 #ifndef brct_plane_sweeper_h_
00002 #define brct_plane_sweeper_h_
00003
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 #include <vcl_vector.h>
00033 #include <vcl_string.h>
00034 #include <vgl/algo/vgl_h_matrix_2d.h>
00035 #include <vil1/vil1_memory_image_of.h>
00036 #include <vil1/vil1_rgb.h>
00037 #include <vsol/vsol_box_2d_sptr.h>
00038 #include <vsol/vsol_point_3d_sptr.h>
00039 #include <vsol/vsol_point_2d_sptr.h>
00040 #include <bbas/bsol/bsol_point_index_2d.h>
00041 #include <brct/brct_plane_sweeper_params.h>
00042
00043 class brct_plane_sweeper : public brct_plane_sweeper_params
00044 {
00045 public:
00046 brct_plane_sweeper(brct_plane_sweeper_params const& sp);
00047 ~brct_plane_sweeper();
00048
00049
00050 vil1_memory_image_of<unsigned char> z_corr_image(const int i);
00051
00052 vcl_vector<vsol_point_2d_sptr> harris_corners(const int cam);
00053
00054
00055 bool set_image(const int cam, vil1_image const& image);
00056
00057
00058
00059
00060 bool read_homographies(vcl_string const& homography_file);
00061
00062
00063 bool compute_harris();
00064
00065
00066 vil1_memory_image_of<unsigned char> project_image_to_plane(const int plane,
00067 const int cam);
00068
00069
00070 bool map_image_to_image(const int from_cam, const double z,
00071 vil1_memory_image_of<unsigned char>& mapped_to_image,
00072 vil1_memory_image_of<unsigned char>& orig_to_image);
00073
00074
00075 bool overlapping_projections(const int plane,
00076 vcl_vector<vil1_memory_image_of<float> >& imgs);
00077
00078
00079 bool overlapping_projections(const double z,
00080 vcl_vector<vil1_memory_image_of<float> >& imgs);
00081
00082
00083
00084 bool overlapping_projections(const double z,
00085 vcl_vector<vil1_memory_image_of<float> >& imgs,
00086 vcl_vector<vcl_vector<vsol_point_2d_sptr> >& corners);
00087
00088
00089 vil1_memory_image_of<unsigned char>
00090 cross_correlate_projections(const int plane);
00091
00092
00093 vil1_memory_image_of<unsigned char>
00094 cross_correlate_projections(const double z);
00095
00096
00097 bool
00098 cross_correlate_proj_corners(const double z,
00099 vil1_image& back,
00100 vcl_vector<vsol_point_2d_sptr>& matched_cnrs,
00101 vcl_vector<vsol_point_2d_sptr>& back_prj_cnrs,
00102 vcl_vector<vsol_point_2d_sptr>& orig_cnrs0);
00103
00104
00105 bool depth_image(vil1_memory_image_of<unsigned char>& depth_out,
00106 vil1_memory_image_of<unsigned char>& coor_out);
00107
00108
00109 bool harris_depth_match(vcl_vector<vsol_point_3d_sptr>& points_3d,
00110 vcl_vector<vsol_point_2d_sptr>& proj_points);
00111
00112
00113 void corr_vals(const int col, const int row,
00114 vcl_vector<float>& z, vcl_vector<float>& corr);
00115
00116
00117 vsol_point_2d_sptr map_point(vsol_point_2d_sptr const& p, const int cam,
00118 const double z);
00119
00120
00121 bool
00122 map_harris_corners(const int from_cam, const double z,
00123 vcl_vector<vsol_point_2d_sptr>& mapped_to_points,
00124 vcl_vector<vsol_point_2d_sptr>& orig_to_points);
00125
00126
00127 void init_harris_match(const int from_cam);
00128
00129
00130 bool
00131 match_harris_corners(const int from_cam, const double z,
00132 vcl_vector<vsol_point_2d_sptr>& matched_points,
00133 vcl_vector<vsol_point_2d_sptr>& orig_to_points);
00134
00135 bool harris_sweep(const int from_cam);
00136
00137 vcl_vector<vsol_point_2d_sptr> matched_points_at_z_index(int z_index);
00138
00139 vcl_vector<vsol_point_3d_sptr> proj_points_3d();
00140
00141 vcl_vector<vsol_point_3d_sptr> world_points_3d();
00142
00143 bool save_world_points(vcl_string const& out_file);
00144
00145 protected:
00146
00147
00148 bool overlapping_box(vcl_vector<vgl_h_matrix_2d<double> > const& homgs,
00149 vsol_box_2d_sptr& box);
00150
00151 bool
00152 overlapping_projections(vcl_vector<vgl_h_matrix_2d<double> > const& homgs,
00153 vcl_vector<vil1_memory_image_of<float> >& imgs,
00154 double& tx, double& ty);
00155 bool
00156 overlapping_projections(vcl_vector<vgl_h_matrix_2d<double> > const& homgs,
00157 vcl_vector<vil1_memory_image_of<float> >& imgs,
00158 vcl_vector<vcl_vector<vsol_point_2d_sptr> >& corners,
00159 double& tx, double& ty);
00160
00161 void homographies_at_z(double z,
00162 vcl_vector<vgl_h_matrix_2d<double> >& homgs);
00163 vsol_box_2d_sptr
00164 depth_image_box(const double zmin, const double zmax);
00165
00166 vcl_vector<vsol_point_2d_sptr> project_corners(vgl_h_matrix_2d<double> const & H,
00167 vcl_vector<vsol_point_2d_sptr> const& corners);
00168
00169 bool
00170 correlate_corners(vcl_vector<vil1_memory_image_of<float> > const& imgs,
00171 vcl_vector<vcl_vector<vsol_point_2d_sptr> > const& cnrs,
00172 vcl_vector<vsol_point_2d_sptr>& matched_corners);
00173
00174 vil1_memory_image_of<vil1_rgb<unsigned char> >
00175 overlay_matches(vcl_vector<vsol_point_2d_sptr>,
00176 vil1_memory_image_of<float> const& back);
00177
00178 vsol_point_2d_sptr map_point(vsol_point_2d_sptr const& p,
00179 vgl_h_matrix_2d<double> const& Hcomp);
00180
00181 bool map_points(const int from_cam, const double z,
00182 vcl_vector<vsol_point_2d_sptr> const& from_points,
00183 vcl_vector<vsol_point_2d_sptr>& to_points);
00184
00185 bool intersecting_bounding_box(vgl_h_matrix_2d<double> const& Hcomp,
00186 vsol_box_2d_sptr const& from_box,
00187 vsol_box_2d_sptr const& to_box,
00188 vsol_box_2d_sptr & box);
00189
00190 bool map_image(const int from_cam, const double z,
00191 vil1_memory_image_of<float>& mapped_image);
00192
00193
00194 bool harris_valid_;
00195 bool homographies_valid_;
00196
00197
00198 int n_planes_;
00199 int n_cams_;
00200 float del_;
00201 int to_cam_;
00202
00203 vcl_vector<double> z_;
00204
00205 vcl_vector< vcl_vector<vgl_h_matrix_2d<double> > > homographies_;
00206
00207 vcl_vector<vil1_image> images_;
00208 vcl_vector<vil1_memory_image_of<float> > smooth_images_;
00209
00210 vcl_vector<vil1_memory_image_of<float> > z_corr_images_;
00211
00212 vcl_vector<vcl_vector<vsol_point_2d_sptr> > harris_corners_;
00213
00214 vcl_vector<vcl_vector<vsol_point_2d_sptr> > matched_corners_;
00215 bsol_point_index_2d pindx_;
00216 };
00217
00218 #endif // brct_plane_sweeper_h_