Herror ::project_3d_point (
    const HTuple &X,
    const HTuple &Y,
    const HTuple &Z,
    const HTuple &CamParam,
    HTuple *Row,
    HTuple *Column
)

Project 3D points into (sub-)pixels.

::project_3d_point is used to project one or more 3D points (with coordinates X, Y, and Z) into the image plane (in pixels). The coordinates X, Y, and Z are given in the camera coordinate system, i.e., they describe the position of the point relative to the camera.

The internal camera parameters CamParam (Focus, Sx, Sy, Cx, Cy, Kappa , ImageWidth and ImageHeight) describe the projection characteristics of the camera. The underlying camera model is a pinhole camera with radial distortions if the focal length passed in CamParam is greater than 0. It describes the transform of a 3D point P_C into a (sub-)pixel [r,c] of the video image by the following equations:

  P_C = (x,y,z)

    u = Focus * x / z
    v = Focus * y / z

   u' = (2*u) / (1+sqrt(1-4*Kappa*(u^2+v^2)))
   v' = (2*v) / (1+sqrt(1-4*Kappa*(u^2+v^2)))

    c = u' / Sx + Cx
    r = v' / Sy + Cy
If the focal length is passed as 0 in CamParam, the camera model of a \textbf{telecentric camera with radial distortions} is used, i.e., it is assumed that the optics of the lens of the camera performs a parallel projection. In this case, the corresponding equations are:
  P_C = (x,y,z) = R*P_W + T

    u = x
    v = y

   u' = (2*u) / (1+sqrt(1-4*Kappa*(u^2+v^2)))
   v' = (2*v) / (1+sqrt(1-4*Kappa*(u^2+v^2)))

    c = u' / Sx + Cx
    r = v' / Sy + Cy
These equations consist of a coordinate transform from the world coordinate system into the camera coordinate system, a perspective or parallel projection into the image plane, a radial distortion of the projected point, and finally a sampling and an image center displacement.


Parameters

X (input_control)
real-array -> HTuple.double
X-coordinates of the 3D points to be projected.

Y (input_control)
real-array -> HTuple.double
Y-coordinates of the 3D points to be projected.

Z (input_control)
real-array -> HTuple.double
Z-coordinates of the 3D points to be projected.

CamParam (input_control)
number-array -> HTuple.double / long
Internal camera parameters.
Number of elements: 8

Row (output_control)
real-array -> HTuple.double *
Row-coordinates of pixels.
Default value: 'ProjectedRow'

Column (output_control)
real-array -> HTuple.double *
Column-coordinates of pixels.
Default value: 'ProjectedCol'


Example
HTuple CamPose,HomMat3D,X1,Y1,Z1,X2,Y2,Z2,CamParam,Row,Column;
// read camera pose
::read_pose("campose.dat",&CamPose);
// transform camera pose to transformation matrix
::pose_to_hom_mat3d(CamPose,&HomMat3D);
// transform 3D points from source into destination coordinate system
X1[1] = 3.2;
X1[0] = 3.0;
Y1[1] = 4.5;
Y1[0] = 4.5;
Z1[1] = 6.2;
Z1[0] = 5.8;
::affine_trans_point_3d(X1,Y1,Z1,HomMat3D,&X2,&Y2,&Z2);
// read internal camera parameters
::read_cam_par("campar.dat",&CamParam);
// project 3D points into image
::project_3d_point(X2,Y2,Z2,CamParam,&Row,&Column);

Result

::project_3d_point returns H_MSG_TRUE if all parameter values are correct. If necessary, an exception handling is raised.


Possible Predecessors

::read_cam_par, ::affine_trans_point_3d


Possible Successors

::gen_region_points, ::gen_region_polygon, ::disp_polygon


See also

::camera_calibration, ::disp_caltab, ::read_cam_par, ::get_line_of_sight, ::affine_trans_point_3d


Module

Camera calibration



Copyright © 1996-2002 MVTec Software GmbH