00001
00002 #ifndef bmrf_curve_3d_builder_h_
00003 #define bmrf_curve_3d_builder_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <bmrf/bmrf_curve_3d_sptr.h>
00016 #include <bmrf/bmrf_curvel_3d_sptr.h>
00017 #include <bmrf/bmrf_network_sptr.h>
00018 #include <bmrf/bmrf_node_sptr.h>
00019 #include <bmrf/bmrf_arc_sptr.h>
00020 #include <vnl/vnl_double_3x4.h>
00021 #include <vnl/vnl_double_4x4.h>
00022 #include <vgl/vgl_vector_3d.h>
00023 #include <vcl_utility.h>
00024 #include <vcl_set.h>
00025 #include <vcl_map.h>
00026 #include <vcl_vector.h>
00027
00028
00029
00030 class bmrf_curve_3d_builder
00031 {
00032 public:
00033 typedef vcl_pair<bmrf_arc_sptr, bmrf_curvel_3d_sptr> time_match;
00034 typedef vcl_vector<time_match> match_vector;
00035
00036
00037 bmrf_curve_3d_builder();
00038 bmrf_curve_3d_builder(const bmrf_network_sptr&);
00039
00040 ~bmrf_curve_3d_builder() {}
00041
00042
00043 void set_network(const bmrf_network_sptr& network);
00044
00045
00046
00047 void init_cameras(const vnl_double_3x4& C0, double scale = 1.0);
00048
00049
00050
00051 bool build(int min_prj = 3, int min_len = 10, double trim_thresh = 0.001);
00052
00053
00054 void reconstruct(float sigma = 0.5);
00055
00056
00057
00058 bool compute_bounding_box(const float *inlier_fractions = NULL, bool align_ep = false);
00059
00060
00061 vcl_set<bmrf_curve_3d_sptr> curves() const;
00062
00063
00064 vcl_map<int,vnl_double_3x4> cameras() const;
00065
00066
00067 vgl_vector_3d<double> direction() const;
00068
00069
00070 vnl_double_4x4 bb_xform() const;
00071
00072 protected:
00073
00074 void compute_camera_offsets();
00075
00076
00077 void find_alpha_bounds();
00078
00079
00080 vcl_set<bmrf_curvel_3d_sptr>
00081 build_curvels(vcl_set<bmrf_curvel_3d_sptr>& all_curvels, double alpha) const;
00082
00083
00084 vcl_set<bmrf_curvel_3d_sptr>
00085 extend_curves( vcl_set<bmrf_curve_3d_sptr>& growing_curves,
00086 double alpha );
00087
00088
00089 vcl_vector<bmrf_arc_sptr> find_arcs_at(double alpha) const;
00090
00091
00092 void reconstruct_point(bmrf_curvel_3d_sptr curvel) const;
00093
00094
00095 void append_curvels(vcl_set<bmrf_curvel_3d_sptr>& curvels,
00096 vcl_set<bmrf_curve_3d_sptr>& growing_curves,
00097 int min_prj);
00098
00099
00100 double append_correct(const bmrf_curvel_3d_sptr& new_c, const bmrf_curvel_3d_sptr& prev_c) const;
00101
00102 protected:
00103
00104 bmrf_network_sptr network_;
00105
00106
00107 double min_alpha_;
00108 double max_alpha_;
00109
00110 vcl_set<bmrf_curve_3d_sptr> curves_;
00111
00112
00113 vcl_map<int,vnl_double_3x4> C_;
00114
00115
00116 vcl_map<int,double> offsets_;
00117
00118
00119 vgl_vector_3d<double> direction_;
00120
00121
00122 vnl_double_4x4 bb_xform_;
00123 };
00124
00125 #endif // bmrf_curve_3d_builder_h_