vpgl_ray_intersect.h
Go to the documentation of this file.
1 // This is core/vpgl/algo/vpgl_ray_intersect.h
2 #ifndef vpgl_ray_intersect_h_
3 #define vpgl_ray_intersect_h_
4 //:
5 // \file
6 // \brief Find the 3-d point closest to the intersection of rays from >= 2 cameras
7 // \author J. L. Mundy
8 // \date July 30, 2007
9 //
10 // given a sequence of image points (image_pts[i]), as viewed through a
11 // corresponding sequence of cameras (cams[i]), this class attempts to
12 // find the point in space (intersection_vert), such that the cumulative
13 // error of the image of intersection_vert wrt each image_pts[i] is
14 // minimized. More precisely, it finds intersection_vert for which the
15 // following quantity is attempted to be minimized (for n cameras and
16 // image points):
17 //
18 // $\sqrt(\sum_{i=1}^{n}( (u_i-image_pts[i][1])^2
19 // + (v_i-image_pts[i][2])^2))$
20 //
21 // where (u_i, v_i) is the image of intersection_vert through
22 // camera cams[i], and image_pts[i][1 and 2] are the "u" and "v"
23 // coordinates of image_pts[i].
24 //
25 
26 #include <vector>
27 #ifdef _MSC_VER
28 # include <vcl_msvc_warnings.h>
29 #endif
30 #include <vgl/vgl_point_2d.h>
31 #include <vgl/vgl_point_3d.h>
32 #include <vpgl/vpgl_camera.h>
33 
34 
35 template<typename T>
37 {
38  public:
39 
40  vpgl_ray_intersect(unsigned dim);
41  ~vpgl_ray_intersect() = default;
42 
43  //: Intersect the rays. return false if intersection fails
44  // Note image points are not homogeneous because require
45  // finite points to measure projection error
46  bool intersect(std::vector<const vpgl_camera<T>* > const& cams,
47  std::vector<vgl_point_2d<T> > const& image_pts,
48  vgl_point_3d<T> const& initial_intersection,
50 
51  protected:
52  //members
53  unsigned dim_;
54  std::vector<const vpgl_camera<T>* > f_cameras_; //cameras
55  std::vector<vgl_point_2d<T> > f_image_pts_; //image points
56 };
57 
58 
59 #endif // vpgl_ray_intersect_h_
vgl_homg_point_3d< Type > intersection(l const &l1, l const &l2)
bool intersect(std::vector< const vpgl_camera< T > * > const &cams, std::vector< vgl_point_2d< T > > const &image_pts, vgl_point_3d< T > const &initial_intersection, vgl_point_3d< T > &intersection)
Intersect the rays. return false if intersection fails.
std::vector< const vpgl_camera< T > * > f_cameras_
std::vector< vgl_point_2d< T > > f_image_pts_
A general camera class.
vpgl_ray_intersect(unsigned dim)
~vpgl_ray_intersect()=default