Herror ::create_pose (
    const HTuple &TransX,
    const HTuple &TransY,
    const HTuple &TransZ,
    const HTuple &Rot1,
    const HTuple &Rot2,
    const HTuple &Rot3,
    const HTuple &OrderOfTransform,
    const HTuple &OrderOfRotation,
    const HTuple &ViewOfTransform,
    HTuple *Pose
)

Create 3D pose parameters.

::create_pose creates 3D pose parameters Pose, which define a 3D transformation. The translation and rotation of the 3D pose are described by parameters (TransX, TransY, TransZ) and (Rot1, Rot2, Rot3), respectively. The parameter ViewOfTransform determines whether the transformation describes the transformation of a point ('point') or of a coordinate system ('coordinate_system'). OrderOfTransform determines whether during the transformation the rotation is applied first ('Rp+T') or whether the translation is applied first ('R(p-T)'). The meaning of the three rotation parameters is determined by OrderOfRotation. The values 'gba' and 'abg' specify that Rot1 is the rotation angle alpha (around the x-axis), Rot2 is the rotation angle beta (around the y-axis), and Rot3 is the rotation angle gamma (around the z-axis). For 'gba', the order is gamma , beta , alpha , while for 'abg' it is alpha , beta , gamma . If OrderOfRotation is passed as 'rodriguez', the rotation parameters are interpreted as Rodriguez rotation vector.

Pose is a tuple of length seven. The first three values hold the translation vector [TransX, TransY, TransZ], the following three parameters hold the rotations Rot1, Rot2, and Rot3, and the last value holds the so-called representation type of the 3D pose parameters, and thus the transformation.

The possible combinations of ViewOfTransform, OrderOfTransform, and OrderOfRotation lead to 12 different representation types for the 3D transformations. In particular, they are:

   | No.|OrderOfTransform | OrderOfRotation |  ViewOfTransform   |Code |
   ---------------------------------------------------------------------
   |  1 |     'Rp+T'      |     'gba'       |      'point'       |  0  | 
   |  2 |     'Rp+T'      |     'abg'       |      'point'       |  2  | 
   |  3 |     'Rp+T'      |  'rodriguez'    |      'point'       |  4  | 
   |  4 |     'Rp+T'      |     'gba'       | 'coordinate_system'|  1  | 
   |  5 |     'Rp+T'      |     'abg'       | 'coordinate_system'|  3  | 
   |  6 |     'Rp+T'      |  'rodriguez'    | 'coordinate_system'|  5  | 
   |  7 |    'R(p-T)'     |     'gba'       |      'point'       |  8  | 
   |  8 |    'R(p-T)'     |     'abg'       |      'point'       | 10  | 
   |  9 |    'R(p-T)'     |  'rodriguez'    |      'point'       | 12  | 
   | 10 |    'R(p-T)'     |     'gba'       | 'coordinate_system'|  9  | 
   | 11 |    'R(p-T)'     |     'abg'       | 'coordinate_system'| 11  | 
   | 12 |    'R(p-T)'     |  'rodriguez'    | 'coordinate_system'| 13  |
         

Note, that in general the symbols R and T in the parameter OrderOfTransform are not the same as within the common notation of a homogeneous transformation matrix.

The type of a 3D transformation can be queried with ::get_pose_type. The output of this operator, however, is not the code of the number of the transformation type, but the sight and order of the transformation, and the order of the rotations, corresponding to the parameters of ::create_pose. Different representation types can be converted into one another with ::convert_pose_type. The description of these conversions is given below.

The representation type no. 1 with code '0' corresponds to a transformation using homogeneous transformation matrices, see ::pose_to_hom_mat3d, because when multiplying a 3D vector by a homogeneous transformation matrix, the rotation and translation as also determined first, a point is transformed, and the rotation order is set to gamma - beta -

 alpha 
by ::pose_to_hom_mat3d (see also ::affine_trans_point_3d). The three rotation angles alpha , beta , and gamma are determined by the parameters Rot1, Rot2, and Rot3. We have:
               T    (1)          (1)
  P_2 = (x,y,z)  = R   *  P_1 + T

                                               (1)
      = R_x(alpha) R_y(beta) R_z(gamma) P_1 + T

  where:

               / 1    0           0       \
  R_x(alpha) = | 0 cos(alpha) -sin(alpha) |  rotation around the x-axis
               \ 0 sin(alpha)  cos(alpha) /

              / cos(beta)   0   sin(beta) \
  R_y(beta) = |    0        1      0      |  rotation around the y-axis
              \ -sin(beta)  0   cos(beta) /

               / cos(gamma) -sin(gamma) 0 \
  R_z(gamma) = | sin(gamma)  cos(gamma) 0 |  rotation around the z-axis
               \    0          0        1 /


  ==>
  
   (1)  / r_11 r_12 r_13 \
  R   = | r_21 r_22 r_23 | 
        \ r_31 r_32 r_33 / 

  where:

  r_11 =  cos(beta) cos(gamma)
  r_12 = -cos(beta) sin(gamma)
  r_13 =  sin(beta)
  r_21 =  sin(alpha) sin(beta) cos(gamma) + cos(alpha) sin(gamma)
  r_22 = -sin(alpha) sin(beta) sin(gamma) + cos(alpha) cos(gamma)
  r_23 = -sin(alpha) cos(beta)
  r_31 = -cos(alpha) sin(beta) cos(gamma) + sin(alpha) sin(gamma)
  r_32 =  cos(alpha) sin(beta) sin(gamma) + sin(alpha) cos(gamma)
  r_33 =  cos(alpha) cos(beta)

The representation type no. 1 is the reference type for all calibration operators in HALCON. Therefore, the conversions from all other representation types into type 1 will be given below. The inverse conversions can be obtained by inverting the calculations below. For the conversions, several basic conversion types can be identified. These are the conversions from the representation types 2, 3, 4, and 7. All other conversions are derived from these basic conversions. The individual conversions are given by:

   - Type 2 ('Rp+T', 'abg', 'point')
     With respect to type 1, the order of rotations is reversed.
     First, a rotation around the x-axis, then around the new y-axis,
     and finally around the z-axis created by the 2nd rotation is
     performed.  As for type 1, the parameters Rot1,
     Rot2, Rot3 determine the rotation angles
     alpha, beta, and gamma.  The translation vector
     [TransX, TransY, TransZ] is
     identical for types 1 and 2.  For the conversion we have:

                      T 
         P_2 = (x,y,z)  = R   *  P_1 + T

                       (2)         (2)          (2)         (2)
             = R_z(gamma  ) R_y(beta  ) R_x(alpha  ) P_1 + T

                       (1)         (1)          (1)         (1)
             = R_x(alpha  ) R_y(beta  ) R_z(gamma  ) P_1 + T

         ==>


          (1)   (2)          (1)         (1)          (1)
         R   = R   = R_x(alpha  ) R_y(beta  ) R_z(gamma  )
                             (2)         (2)          (2)     
                   = R_z(gamma  ) R_y(beta  ) R_x(alpha  ) 

         where:

               /  (2)  (2)  (2) \
               | r_11 r_12 r_13 |
          (2)  |  (2)  (2)  (2) |
         R   = | r_21 r_22 r_23 |
               |  (2)  (2)  (2) |
               \ r_31 r_32 r_33 / 

         where:

      (2)            (2)        (2)
     r_11 =  cos(gamma ) cos(beta )
      (2)            (2)        (2)         (2)           (2)         (2)
     r_12 =  cos(gamma ) sin(beta ) sin(alpha ) - sin(gamma ) cos(alpha )
      (2)            (2)        (2)         (2)           (2)         (2)
     r_13 =  cos(gamma ) sin(beta ) cos(alpha ) + sin(gamma ) sin(alpha ) 
      (2)            (2)        (2)
     r_21 =  sin(gamma ) cos(beta ) 
      (2)            (2)        (2)         (2)           (2)         (2)
     r_22 =  sin(gamma ) sin(beta ) sin(alpha ) + cos(gamma ) cos(alpha )
      (2)            (2)        (2)         (2)           (2)         (2)
     r_23 =  sin(gamma ) sin(beta ) cos(alpha ) - cos(gamma ) sin(alpha )
      (2)           (2)   
     r_31 = -sin(beta )
      (2)           (2)         (2)
     r_32 =  cos(beta ) sin(alpha )
      (2)           (2)         (2)
     r_33 =  cos(beta ) cos(alpha )

                (1)              (2) 2      (2) 2
         cos(beta  ) = sqrt( (r_11  ) + (r_12  ) )

        ==>

                         /      (2)           (2)     \
              (1)        |     r_23          r_33     |
         gamma   = atan2 |- ----------- , ----------- |
                         |         (1)           (1)  |
                         \  cos(beta  )   cos(beta  ) /

             (1)         (2)           (1)
         beta   = atan2( r_13 , cos(beta  ) )
         
                         /      (2)           (2)     \
              (1)        |     r_12          r_11     |
         alpha   = atan2 |- ----------- , ----------- |
                         |         (1)           (1)  |
                         \  cos(beta  )   cos(beta  ) /

          (1)   (2)
         T   = T


     Here, atan2(y,x) denotes arctan(x/y) while taking into account
     the signs of x and y, in order to determine the correct
                                                 (1)
     quadrant.  For the pathological case cos(beta  ) = 0, the
     problem is unsolvable because the representation of a rotation
     by three parameters exhibits a singularity.  In this case, the
     rotation matrix is perturbed minimally, thus avoiding the
     singularity.  (The angle beta is modified in steps of 0.00001
     degrees.)

   - Type 3 ('Rp+T', 'rodriguez', 'point')
     The Rodriguez vector is an alternative representation of a
     rotation in space.  The direction of the vector defines the
     axis of rotation.  The length of the vector usually defines the
     rotation angle with positive orientation.  Here, a variation of
     the Rodriguez vector is used, where the length of the vector
     defines the tangent of half the rotation angle.

     Thus, the parameters Rot1, Rot2, and
     Rot3 do not describe rotation angles, but correspond
     to the three values of the vector [r_x, r_y, r_z].  The
     translation vector [TransX, TransY, TransZ]
     is identical for types 1 and 3.  The conversion of the rotation
     part of the transformation from type 3 to type 1 is given by
                                                            (1)
     converting the Rodriguez vector to the rotation matrix R  :

                       2
         h = ----------------------
                   2     2     2
              1 + r_x + r_y + r_z

                        2     2
         r_11 = 1 - h (r_y + r_z)
         r_12 = h ( r_x r_y - r_z)
         r_13 = h ( r_x r_z + r_y)
         r_21 = h ( r_y r_x + r_z)
                        2     2
         r_22 = 1 - h (r_z + r_x)
         r_23 = h ( r_y r_z - r_x)
         r_31 = h ( r_z r_x - r_y)
         r_32 = h ( r_z r_y + r_x)
                        2     2
         r_33 = 1 - h (r_x + r_y)

   - Type 4 ('Rp+T', 'gba', 'coordinate_system')
     In contrast to type 1, type 4 describes the transformation of
     a coordinate system instead of the transformation of a point.
     As for type 1, the parameters Rot1, Rot2,
     Rot3 define the rotation angles alpha, beta, and
     gamma.  The translation vector [TransX,
     TransY, TransZ] is identical for types 1
     and 4.  The only difference is that the rotation angles are
     negated.  For the conversion we have:

                     T 
        P_2 = (x,y,z)  = R   *  P_1 + T

                      (4)         (4)          (4)         (4)
            = R_x(alpha  ) R_y(beta  ) R_z(gamma  ) P_1 + T

                      (1)         (1)          (1)         (1)
            = R_x(alpha  ) R_y(beta  ) R_z(gamma  ) P_1 + T

     where:

         (1)   (4)
        T   = T
            (1)       (4)
        alpha  = -alpha
            (1)       (4)
        beta   = -beta 
            (1)       (4)
        gamma  = -gamma 

   - Type 5 ('Rp+T', 'abg', 'coordinate_system')
     For the conversion of type 5 into type 1, a conversion into
     type 2 can be done first, followed by a conversion from type 2
     to type 1; see the explanations there.  Types 5 and 2 differ
     in the sight of the transformation (ViewOfTransform).
     Thus, as was the case for the conversion from type 4 to type 1,
     the signs of the rotation angles have to be changed.  Again,
     the parameters Rot1, Rot2, Rot3
     denote the rotation angles alpha, beta, and gamma.  The
     translation vector [TransX, TransY, TransZ]
     is identical for types 1 and 5.  For the conversion to type 2
     we have:

                     T 
        P_2 = (x,y,z)  = R   *  P_1 + T

                      (5)         (5)          (5)         (5)
            = R_z(gamma  ) R_y(beta  ) R_x(alpha  ) P_1 + T

                      (2)         (2)          (2)         (2)
            = R_z(gamma  ) R_y(beta  ) R_x(alpha  ) P_1 + T

     where:

         (2)   (5)
        T   = T
            (2)       (5)
        alpha  = -alpha
            (2)       (5)
        beta   = -beta 
            (2)       (5)
        gamma  = -gamma 

   - Type 6 ('Rp+T', 'rodriguez', 'coordinate_system')
     As for type 3, the rotation for type 6 is given by a
     Rodrigues vector.  The parameters Rot1, Rot2,
     and Rot3 do not describe angles, but correspond to the
     three values of the vector [r_x, r_y, r_z].  The translation
     vector (TransX, TransY, TransZ) is
     identical to type 1.  As above, the conversion of the rotation
     part to type 1 is done in two steps: First, the vector
     [r_x, r_y, r_x] is converted to a rotation matrix, resulting in
     a representation of type 4.  See the explanations on the
     conversion from type 3 to type 1.

     The second step is the conversion from type 4 to type 1, where
     additionally the rotation angles have to be negated.  See the
     explanations on the conversion from type 4 to type 1.

   - Type 7 ('R(p-T)', 'gba', 'point')
     In contrast to type 1, type 7 describes a transformation in
     which the translation is applied first, followed by the
     rotation.  As for type 1, the parameters Rot1,
     Rot2, and Rot3 define the rotation angles
     alpha, beta, and gamma.  For the transformation we have:

                     T    (1)          (1)   
        P_2 = (x,y,z)  = R   *  P_1 + T
                          (7)       (7)
                       = R  (P_1 - T  )
                          (7)      (7) (7)
                       = R  P_1 - R   T

        ==>

         (1)    (7)
        R    = R
         (1)      (7) (7)
        T    = - R   T

   - Type 8 ('R(p-T)', 'abg', 'point')
     The conversion from type 8 to type 1 is again carried out in
     two steps: First, a conversion to type 7 is done.  See the
     explanations on the conversion from type 2 to type 1.  In the
     second step, a conversion from type 7 to type 1 is done.  See
     the explanations there.  The parameters Rot1,
     Rot2, and Rot3 again denote the rotation
     angles alpha, beta, and gamma.

   - Type 9 ('R(p-T)', 'rodriguez', 'point')
     The conversion from type 9 to type 1 is again carried out in
     two steps: First, a conversion to type 7 is done.  See the
     explanations on the conversion from type 3 to type 1.  In the
     second step, a conversion from type 7 to type 1 is done.  See
     the explanations there.  The parameters Rot1,
     Rot2, and Rot3 do not describe rotation
     angles, but correspond to the three values of the Rodriguez
     vector [r_x, r_y, r_z].

   - Type 10 ('R(p-T)', 'gba', 'coordinate_system')
     The conversion from type 10 to type 1 is again carried out in
     two steps: First, a conversion to type 7 is done.  See the
     explanations on the conversion from type 4 to type 1.  In the
     second step, a conversion from type 7 to type 1 is done.  See
     the explanations there.  The parameters Rot1,
     Rot2, and Rot3 again denote the rotation
     angles alpha, beta, and gamma.

   - Type 11 ('R(p-T)', 'abg', 'coordinate_system')
     The conversion from type 11 to type 1 is carried out in three
     steps: First, a conversion to type 8 is done.  See the
     explanations on the conversion from type 5 to type 1.  In the
     second step, a conversion from type 8 to type 7 is done.  See
     the explanations on the conversion from type 2 to type 1.  In
     the third step, the conversion from type 7 to type 1 is done.
     See the explanations there.  The parameters Rot1,
     Rot2, and Rot3 again denote the rotation
     angles alpha, beta, and gamma.

   - Typ 12 ('R(p-T)', 'rodriguez', 'coordinate_system')
     The conversion from type 11 to type 1 is also carried out in
     three steps: First, a conversion to type 10 is done.  See the
     explanations on the conversion from type 6 to type 1.  In the
     second step, a conversion from type 10 to type 7 is done.  See
     the explanations on the conversion from type 4 to type 1.  In
     the third step, the conversion from type 7 to type 1 is done.
     See the explanations there.  The parameters Rot1,
     Rot2, and Rot3 do not describe rotation
     angles, but correspond to the three values of the Rodriguez
     vector [r_x, r_y, r_z].
Useful hint: For the description of the pose of a new coordinate system within a base coordinate system, it is usually easiest to start by visualizing both coordinate systems to be identical, i.e., to lie exactly on top of one another. After this, the new coordinate system is translated until its origin rests in the correct position. The vector describing this translation is given by [TransX, TransY, TransZ]. After this, the rotations are applied until the desired orientation of the new coordinate system is achieved within the base coordinate system. If the rotation order is chosen as gamma - beta - alpha , first a rotation around the z-axis in positive orientation is done. Then, a rotation around the new y-axis, and finally a rotation around the x-axis resulting from the second rotation is done. The rotation angle around the x-axis corresponds to alpha , and must be passed in Rot1, the rotation angle around the y-axis corresponds to beta , and must be passed in Rot2, while the rotation angle around the z-axis corresponds to gamma and has to be passed in Rot3. This description of a 3D transformation corresponds to type 10 with code '9'. Thus, ViewOfTransform = 'coordinate_system', OrderOfTransform = 'R(p-T)', and OrderOfRotation = 'gba' have to be passed to the operator.

In the programming example below, it is shown how the initial camera pose for a subsequent call to ::camera_calibration can be determined, if the position of the camera is coarsly measured in the world coordinate system. This is of special interest if the standard planar calibration target (see ::create_caltab) is not used, and thus the operator ::find_marks_and_pose cannot be applied. Instead, natural or artificial landmarks with known world coordinates can, of course, be used for calibration.

Let, for example, the relative camera position with respect to the origin of the world coordinate system be given by x = 1.08 m, y = 0.25 m, z = 0.62 m, i.e., the origin of the camera coordinate system has the world coordinates [1.08, 0.25, 0.62]. Let the camera coordinate system be oriented such that the line of sight of the camera corresponds to the positive z-axis. The orientation of the camera coordinate system with respect to the world coordinate system can be described by three rotation angles. In the example, the camera coordinate system is first rotated around the z-axis of the world coordinate system by 100 degrees, followed by a rotation around the new x-axis by -120 degrees. See also the example for ::hom_mat3d_to_pose.


Parameters

TransX (input_control)
real -> HTuple.double
Translation along the x-axis.
Default value: 0.1
Suggested values: -1.0, -0.75, -0.5, -0.25, -0.2, -0.1, -0.5, -0.25, -0.125, -0.01, 0, 0.01, 0.125, 0.25, 0.5, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0
Typical range of values: 0.05 <= TransX
Recommended increment: 0.05

TransY (input_control)
real -> HTuple.double
Translation along the y-axis.
Default value: 0.1
Suggested values: -1.0, -0.75, -0.5, -0.25, -0.2, -0.1, -0.5, -0.25, -0.125, -0.01, 0, 0.01, 0.125, 0.25, 0.5, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0
Typical range of values: 0.05 <= TransY
Recommended increment: 0.05

TransZ (input_control)
real -> HTuple.double
Translation along the z-axis.
Default value: 0.1
Suggested values: -1.0, -0.75, -0.5, -0.25, -0.2, -0.1, -0.5, -0.25, -0.125, -0.01, 0, 0.01, 0.125, 0.25, 0.5, 0.1, 0.2, 0.25, 0.5, 0.75, 1.0
Typical range of values: 0.05 <= TransZ
Recommended increment: 0.05

Rot1 (input_control)
real -> HTuple.double
First rotation value.
Default value: 90
Suggested values: 90, 180, 270
Typical range of values: 0 <= Rot1 <= 360
Minimum increment: 0.001
Recommended increment: 0.2

Rot2 (input_control)
real -> HTuple.double
Second rotation value.
Default value: 90
Suggested values: 90, 180, 270
Typical range of values: 0 <= Rot2 <= 360
Minimum increment: 0.001
Recommended increment: 0.2

Rot3 (input_control)
real -> HTuple.double
Third rotation value.
Default value: 90
Suggested values: 90, 180, 270
Typical range of values: 0 <= Rot3 <= 360
Minimum increment: 0.001
Recommended increment: 0.2

OrderOfTransform (input_control)
string -> HTuple.char *
Order of rotation and translation.
Default value: ''Rp+T''
Suggested values: ''Rp+T'', ''R(p-T)''

OrderOfRotation (input_control)
string -> HTuple.char *
Meaning of the rotation values.
Default value: ''gba''
Suggested values: ''gba'', ''abg'', ''rodriguez''

ViewOfTransform (input_control)
string -> HTuple.char *
View of transformation.
Default value: ''point''
Suggested values: ''point'', ''coordinate_system''

Pose (output_control)
pose-array -> HTuple.double * / long *
3D-Transformation.
Number of elements: 7


Example
HTuple CamParam, StartPose, FinalPose, Errors, Dummy;
// get the following parameter (landmark positions in world and image
// coordinates) by suitable operations
HTuple WorldPointsX, WorldPointsY, WorldPointsZ, PixelsRow, PixelsColumn;
// get internal camera parameters: */
::read_cam_par ("campar.dat", &CamParam) ;
// get rough camera start pose from relative camera pose:
::create_pose(1.08, 0.25, 0.62, -120, 0, 100, "R(p-T)", "gba", 
              "coordinate_system", &StartPose);
// calibration of external camera params:
::camera_calibration (WorldPointsX, WorldPointsY, WorldPointsZ, 
                      PixelsRow, PixelsColumn, CamParam, StartPose, 6,
                      &Dummy, &FinalPose, &Errors) ;

Result

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


Possible Successors

::pose_to_hom_mat3d, ::write_pose, ::camera_calibration, ::hand_eye_calibration


Alternatives

::read_pose, ::hom_mat3d_to_pose


See also

::convert_pose_type, ::get_pose_type, ::hom_mat3d_to_pose, ::pose_to_hom_mat3d, ::write_pose, ::read_pose


Module

Camera calibration



Copyright © 1996-2002 MVTec Software GmbH