vgl_affine_coordinates.h
Go to the documentation of this file.
1 // This is core/vgl/vgl_affine_coordinates.h
2 #ifndef vgl_affine_coordinates_h_
3 #define vgl_affine_coordinates_h_
4 //:
5 // \file
6 // \brief Computes 2-d and 3-d affine coordinates of point sets
7 //
8 // \author J.L. Mundy
9 // Jan 30, 2017
10 //
11 // \verbatim
12 // Modifications
13 // None
14 // \endverbatim
15 //
16 //-------------------------------------------------------------------------------
17 // Converts points into baycentric coordinates given an affine basis
18 // For 2-d, three points are required to form the basis
19 // For 3-d, four points are required to form the basis
20 #include <vector>
21 #ifdef _MSC_VER
22 # include <vcl_msvc_warnings.h>
23 #endif
24 #include <vgl/vgl_point_2d.h>
25 #include <vgl/vgl_point_3d.h>
26 
27 // Points are all coplanar. The first three points in pts are the basis, pts[0] is the origin
28 template <class T>
29 void vgl_affine_coordinates_2d(std::vector<vgl_point_2d<T> > const& pts, std::vector<vgl_point_2d<T> >& affine_pts);
30 
31 // The first four points in pts are the basis.
32 template <class T>
33 void vgl_affine_coordinates_3d(std::vector<vgl_point_3d<T> > const& pts, std::vector<vgl_point_3d<T> >& affine_pts);
34 
35 // Two 2-d pointsets define the 3-d basis(V0,V1,V2). The first four points in pts1 and pts2 are points that define
36 // this basis, i.e. V0 = pts[1]-pts[0], V1 = pts[2]-pts[0], etc..
37 // Based on the paper Affine Structure From Motion, J.Koenderink and A. van Doorn, J. Optical Society Am. Vol8,No.2, 1991
38 // The 2-d pointsets can be regarded as points from affine camera projections of a 3-d pointset.
39 // The reconstruction of a point P pts[i], i>3, is based on the idea that V2 and P project along the
40 // line of sight to the same points V2' and P' on the plane of V0 x V1 in view 1.
41 // In a different view, view2, V2 and V2', and P and P' will be displaced along parallel lines (the line of sight of view1).
42 // V2' and P' will project to the same 2-d affine coordinates in view 2.
43 // The ratio of these parallel displacement distances is used to define the 3-d affine coordintes of P.
44 template <class T>
45 void vgl_affine_coordinates_3d(std::vector<vgl_point_2d<T> > const& pts1, std::vector<vgl_point_2d<T> > const& pts2,
46  std::vector<vgl_point_3d<T> >& affine_pts);
47 #define VGL_AFFINE_COORDINATES_INSTANTIATE(T) extern "please include vgl/vgl_affine_coordinates.hxx first"
48 #endif // vgl_affine_coordinates_h_
a point in 2D nonhomogeneous space
void vgl_affine_coordinates_3d(std::vector< vgl_point_3d< T > > const &pts, std::vector< vgl_point_3d< T > > &affine_pts)
void vgl_affine_coordinates_2d(std::vector< vgl_point_2d< T > > const &pts, std::vector< vgl_point_2d< T > > &affine_pts)
a point in 3D nonhomogeneous space