next up previous contents
Next: Adding/removing camera distortion Up: Cameras Previous: Building cameras   Contents

Projecting points and lines

Routines for projecting points and lines into an image are provided. The double precision routines are
      Gan_Vector3 v3X, v3x; /* declare camera/scene points X, x */
      Gan_Vector3 v3L, v3l; /* declare camera/scene lines L, l */

      /* fill camera point X & line L with values */
      gan_vec3_fill_q ( &v3X, 1.5, -0.8, 1.2 );
      gan_vec3_fill_q ( &v3L, 2.7,  3.9, 3.6 );

      /* project point from camera 3D coordinates onto the image X --> x */
      gan_camera_project_point_q ( &CameraD, &v3X, &v3x );

      /* project line from camera 3D coordinates onto the image L --> l */
      gan_camera_project_line_q ( &CameraD, &v3L, &v3l );
The point projection function implements the projection equations 5.1 and 5.2. The lines are represented in homogeneous 2D coordinates, so that the line ${\bf L}$ in camera coordinates actually describes a plane in 3D space intersecting the origin (optical centre). If ${\bf X}$ is a point in camera $X,Y,Z$ space, the line in the homogeneous 2D space of camera ``rays'' is defined by the equation

\begin{displaymath}{\bf L}.{\bf X}= 0\;\;\;\;\mbox{or}\;\;\;\; L_X X + L_Y Y + L_Z Z = 0
\end{displaymath}

The line in image coordinates ${\bf x}=(x\;y\;z_h)^{\top}$ is similarly defined as

\begin{displaymath}{\bf l}.{\bf x}= 0\;\;\;\;\mbox{or}\;\;\;\; l_x x + l_y y + l_z z_h = 0
\end{displaymath}

Projection of lines is only available for linear cameras, since when there is distortion lines in 3D space project to curves on the image. For a linear camera the relationship between ${\bf L}$ and ${\bf l}$ is

\begin{displaymath}{\bf l}= K^{-\top}{\bf L}
\end{displaymath}

There are also versions of the above routines which perform the projection in-place in the input vector. So for instance

      Gan_Vector3 v3Xx; /* declare point */
      Gan_Vector3 v3Ll; /* declare line */

      /* fill camera point X & line L with values */
      gan_vec3_fill_q ( &v3Xx, 1.5, -0.8, 1.2 );
      gan_vec3_fill_q ( &v3Ll, 2.7,  3.9, 3.6 );

      /* project point from camera 3D coordinates onto the image in-place */
      gan_camera_project_point_i ( &CameraD, &v3Xx );

      /* project line from camera 3D coordinates onto the image in-place */
      gan_camera_project_line_i ( &CameraD, &v3Ll );

Back-projection from image to camera coordinates operates similarly. To back-project a point and a line you can use

      Gan_Vector3 v3X, v3x; /* declare camera/scene points X, x */
      Gan_Vector3 v3L, v3l; /* declare camera/scene lines L, l */

      /* fill image point x & line l with values */
      gan_vec3_fill_q ( &v3x, 1.5, -0.8, 1.2 );
      gan_vec3_fill_q ( &v3l, 2.7,  3.9, 3.6 );

      /* back-project point from the image into camera 3D coordinates x --> X */
      gan_camera_backproject_point_q ( &CameraD, &v3x, &v3X ); /* OR */
      gan_camera_backproject_point_i ( &CameraD, &v3x ); /* in-place */

      /* backproject line from the image into camera 3D coordinates l --> L */
      gan_camera_backproject_line_q ( &CameraD, &v3l, &v3L ); /* OR */
      gan_camera_backproject_line_i ( &CameraD, &v3l ); /* in-place */

The single precision versions of these functions operate similarly. The single precision camera to image projection functions are

      Gan_Vector3_f v3X, v3x; /* declare camera/scene points X, x */
      Gan_Vector3_f v3L, v3l; /* declare camera/scene lines L, l */

      /* fill camera point X & line L with values */
      gan_vec3f_fill_q ( &v3X, 1.5F, -0.8F, 1.2F );
      gan_vec3f_fill_q ( &v3L, 2.7F,  3.9F, 3.6F );

      /* project point from camera 3D coordinates onto the image X --> x */
      gan_cameraf_project_point_q ( &CameraF, &v3X, &v3x ); /* OR */
      gan_cameraf_project_point_i ( &CameraF, &v3X ); /* in-place */

      /* project line from camera 3D coordinates onto the image L --> l */
      gan_cameraf_project_line_q ( &CameraF, &v3L, &v3l ); /* OR */
      gan_cameraf_project_line_i ( &CameraF, &v3L ); /* in-place */
The single precision image to camera back-projection functions are
      Gan_Vector3_f v3X, v3x; /* declare camera/scene points X, x */
      Gan_Vector3_f v3L, v3l; /* declare camera/scene lines L, l */

      /* fill image point x & line l with values */
      gan_vec3f_fill_q ( &v3x, 1.5F, -0.8F, 1.2F );
      gan_vec3f_fill_q ( &v3l, 2.7F,  3.9F, 3.6F );

      /* project point from camera 3D coordinates onto the image X --> x */
      gan_cameraf_backproject_point_q ( &CameraF, &v3x, &v3X ); /* OR */
      gan_cameraf_backproject_point_i ( &CameraF, &v3x ); /* in-place */

      /* project line from camera 3D coordinates onto the image L --> l */
      gan_cameraf_backproject_line_q ( &CameraF, &v3l, &v3L ); /* OR */
      gan_cameraf_backproject_line_i ( &CameraF, &v3l ); /* in-place */


next up previous contents
Next: Adding/removing camera distortion Up: Cameras Previous: Building cameras   Contents
2006-03-17