Go to the documentation of this file.00001
00002 #ifndef bmvv_cal_manager_h_
00003 #define bmvv_cal_manager_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <vcl_vector.h>
00025 #include <vcl_map.h>
00026 #include <vcl_fstream.h>
00027 #include <vil/vil_image_resource_sptr.h>
00028 #include <vgl/vgl_point_2d.h>
00029 #include <vgl/vgl_point_3d.h>
00030 #include <vgl/vgl_line_segment_2d.h>
00031 #include <vgl/algo/vgl_p_matrix.h>
00032 #include <vsol/vsol_point_2d_sptr.h>
00033 #include <vsol/vsol_polygon_2d_sptr.h>
00034 #include <vsol/vsol_polygon_3d_sptr.h>
00035 #include <vgui/vgui_wrapper_tableau.h>
00036 #include <bgui/bgui_image_tableau_sptr.h>
00037 #include <vgui/vgui_range_map_params_sptr.h>
00038 #include <vgui/vgui_event.h>
00039 #include <vgui/vgui_soview2D.h>
00040 #include <bgui/bgui_vtol2D_tableau_sptr.h>
00041 #include <bgui/bgui_picker_tableau_sptr.h>
00042
00043 class vgui_window;
00044 class vgui_soview;
00045
00046 class bmvv_cal_manager : public vgui_wrapper_tableau
00047 {
00048 public:
00049 bmvv_cal_manager();
00050 ~bmvv_cal_manager();
00051 static bmvv_cal_manager *instance();
00052
00053
00054 void quit();
00055 void load_image();
00056 void save_image();
00057
00058
00059 void load_world();
00060
00061
00062 void adjust_contrast();
00063 void set_range_params();
00064 void clear_display();
00065 void clear_selected();
00066 void load_image_and_camera();
00067
00068
00069 void load_corrs();
00070 void save_corrs();
00071 void pick_correspondence();
00072 void remove_correspondence();
00073
00074
00075 void pick_vertical();
00076 void save_constraints();
00077
00078
00079 void set_identity_camera();
00080 void solve_camera();
00081 void compute_ransac_homography();
00082 void save_camera();
00083
00084
00085 void map_image_to_world();
00086
00087
00088
00089
00090 void set_height();
00091
00092 void pick_polygon();
00093
00094 void clear_world();
00095
00096 void confirm_polygon();
00097
00098 void save_world();
00099
00100 void save_world_ply2();
00101
00102 void read_world_ply2();
00103
00104
00105 void ply2_to_vrml();
00106
00107 void create_box();
00108
00109 vgui_window* get_window(){return win_;}
00110 void set_window(vgui_window* win){win_=win;}
00111 void init();
00112
00113
00114 virtual bool handle(const vgui_event&);
00115
00116 void load_image_file(vcl_string image_filename, bool greyscale);
00117 protected:
00118
00119 void draw_corr_point(const float x, const float y);
00120 void draw_vsol_points(const int cam,
00121 vcl_vector<vsol_point_2d_sptr> const & points,
00122 bool clear = true,
00123 const float r = 0,
00124 const float g = 1,
00125 const float b = 0);
00126
00127 void draw_vsol_point(const int cam,
00128 vsol_point_2d_sptr const & point,
00129 bool clear = false,
00130 const float r = 0,
00131 const float g = 1,
00132 const float b = 0);
00133
00134 void draw_vsol_polygon_3d(vsol_polygon_3d_sptr const & poly,
00135 bool clear, const float r=0, const float g=1,
00136 const float b=0);
00137
00138 void draw_polygons_3d(bool clear, const float r,
00139 const float g, const float b);
00140
00141 void add_image(vil_image_resource_sptr const& image,
00142 vgui_range_map_params_sptr rmps = 0,
00143 bool greyscale =false);
00144 vil1_image get_image_at(unsigned col, unsigned row);
00145 bool read_corrs(vcl_ifstream& str);
00146 bool draw_correspondences();
00147 bool draw_projected_world_points();
00148 void add_poly_vertices_to_world_pts(vsol_polygon_3d_sptr const& poly);
00149 void clear_correspondences();
00150 void project_world();
00151 int get_selected_proj_world_pt(vgl_point_2d<double>& pt);
00152 vgui_range_map_params_sptr
00153 range_params(vil_image_resource_sptr const& image);
00154 private:
00155 vil_image_resource_sptr img_;
00156 vgui_window* win_;
00157 bgui_image_tableau_sptr itab_;
00158 bgui_picker_tableau_sptr ptab_;
00159 bgui_vtol2D_tableau_sptr btab_;
00160 vcl_map<int, int> point_3d_map_;
00161 static bmvv_cal_manager *instance_;
00162 vcl_vector<vgl_point_2d<double> > corrs_;
00163 vcl_vector<bool> corrs_valid_;
00164 vcl_vector<vgl_point_2d<double> > proj_image_pts_;
00165 vcl_vector<vgui_soview2D_point* > corr_sovs_;
00166 vcl_vector<vgl_point_3d<double> > world_;
00167
00168 vgl_p_matrix<double> cam_;
00169
00170 vgl_p_matrix<double> prev_cam_;
00171
00172 vcl_vector<vgl_line_segment_2d<double> > verticals_;
00173
00174 double height_;
00175
00176 vsol_polygon_3d_sptr new_poly_;
00177
00178 vcl_vector<vsol_polygon_3d_sptr> polys_;
00179
00180 vcl_vector<vsol_polygon_2d_sptr> proj_polys_;
00181
00182 vcl_vector<vcl_vector<unsigned> > indexed_face_set_;
00183 };
00184
00185 #endif // bmvv_cal_manager_h_