Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

bmrf_curve_3d_builder.h

Go to the documentation of this file.
00001 // This is brl/bseg/bmrf/bmrf_curve_3d_builder.h
00002 #ifndef bmrf_curve_3d_builder_h_
00003 #define bmrf_curve_3d_builder_h_
00004 //:
00005 // \file
00006 // \brief A class to build 3D curves from a bmrf_network
00007 // \author Matt Leotta, (mleotta@lems.brown.edu)
00008 // \date 3/23/04
00009 //
00010 // \verbatim
00011 //  Modifications
00012 // \endverbatim
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 //: A 3D curve builder
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   //: Constructor
00037   bmrf_curve_3d_builder();
00038   bmrf_curve_3d_builder(const bmrf_network_sptr&);
00039   //: Destructor
00040   ~bmrf_curve_3d_builder() {}
00041 
00042   //: Set the network
00043   void set_network(const bmrf_network_sptr& network);
00044 
00045   //: Initialize the camera matrices (using a specified camera)
00046   // \param scale determines the separation between cameras
00047   void init_cameras(const vnl_double_3x4& C0, double scale = 1.0);
00048   
00049   //: Build The curves
00050   //  Curves with less than \p min_prj projections are removed
00051   bool build(int min_prj = 3, int min_len = 10, double trim_thresh = 0.001);
00052 
00053   //: Reconstruct the 3D curves from the curvel chains
00054   void reconstruct(float sigma = 0.5);
00055 
00056   //: Compute the bounding box aligned with vehicle direction
00057   // \param inlier_fractions is an array of 3 float for inlier fraction in {X,Y,Z}
00058   bool compute_bounding_box(const float *inlier_fractions = NULL, bool align_ep = false);
00059 
00060   //: Return the constructed curves
00061   vcl_set<bmrf_curve_3d_sptr> curves() const;
00062 
00063   //: Return the cameras used in the reconstruction
00064   vcl_map<int,vnl_double_3x4> cameras() const;
00065 
00066   //: Return the 3D direction of motion of the curves
00067   vgl_vector_3d<double> direction() const;
00068 
00069   //: Return the bounding box transformation
00070   vnl_double_4x4 bb_xform() const;
00071 
00072  protected:
00073   //: Compute the relative change in spacing between cameras
00074   void compute_camera_offsets();
00075   
00076   //: Determine the alpha bounds from the network
00077   void find_alpha_bounds();
00078   
00079   //: Build curvels by linking across time through probable arcs
00080   vcl_set<bmrf_curvel_3d_sptr>
00081     build_curvels(vcl_set<bmrf_curvel_3d_sptr>& all_curvels, double alpha) const;
00082 
00083   //: extend all curves to the next alpha 
00084   vcl_set<bmrf_curvel_3d_sptr> 
00085     extend_curves( vcl_set<bmrf_curve_3d_sptr>& growing_curves, 
00086                    double alpha );
00087 
00088   //: Find all arcs where both nodes are valid at \p alpha
00089   vcl_vector<bmrf_arc_sptr> find_arcs_at(double alpha) const;
00090 
00091   //: Reconstruct the 3d location of a curvel from its projections
00092   void reconstruct_point(bmrf_curvel_3d_sptr curvel) const;
00093 
00094   //: Match the \p curvels to the ends of the \p growing_curves
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   //: Return a measure (0.0 to 1.0) of how well \p new_c matches \p prev_c
00100   double append_correct(const bmrf_curvel_3d_sptr& new_c, const bmrf_curvel_3d_sptr& prev_c) const;
00101 
00102  protected:
00103   //: The network
00104   bmrf_network_sptr network_;
00105 
00106   //: Bounds on the alpha values in the network;
00107   double min_alpha_;
00108   double max_alpha_;
00109 
00110   vcl_set<bmrf_curve_3d_sptr> curves_;
00111 
00112   //: Map from frame numbers to cameras
00113   vcl_map<int,vnl_double_3x4> C_;
00114 
00115   //: Map from frame numbers to camera offsets
00116   vcl_map<int,double> offsets_;
00117   
00118   //: 3D direction unit vector
00119   vgl_vector_3d<double> direction_;
00120 
00121   //: This transform maps the unit cube into the vehicle aligned bounding box
00122   vnl_double_4x4 bb_xform_;
00123 };
00124 
00125 #endif // bmrf_curve_3d_builder_h_

Generated on Thu Jan 10 14:51:52 2008 for contrib/brl/bseg/bmrf by  doxygen 1.4.4