0

The extrinsic matrix for camera calibration based on the MATLAB link should be 4x3 matrix (including orientation and translation) means we need 12 elements, however, based on the explanation in Tango documentation we only get 3 numbers for translation and 4 numbers for rotation. How can I create that 4x3 matrix with these 7 numbers?

Thanks, Vahid.

VahidB
  • 11
  • 4

1 Answers1

0

The View Matrix is used to hold these values. It's a 4x4 matrix that allows to manipulate 3D poses (positions + orientations).

You can find more detail about this matrix here : http://www.3dgep.com/understanding-the-view-matrix/

Note that the Tango java library is based on Rajawali 3D library. You can see the structure of that MatrixX44 here:

https://github.com/Rajawali/Rajawali/blob/master/rajawali/src/main/java/org/rajawali3d/math/Matrix4.java

Especially, the following method shows as how the 7 values are stored. For an easier reading, you can assume the scale vector is on (1,1,1)

public Matrix4 setAll(@NonNull Vector3 position, @NonNull Vector3 scale, @NonNull Quaternion rotation) {
    // Precompute these factors for speed
    final double x2 = rotation.x * rotation.x;
    final double y2 = rotation.y * rotation.y;
    final double z2 = rotation.z * rotation.z;
    final double xy = rotation.x * rotation.y;
    final double xz = rotation.x * rotation.z;
    final double yz = rotation.y * rotation.z;
    final double wx = rotation.w * rotation.x;
    final double wy = rotation.w * rotation.y;
    final double wz = rotation.w * rotation.z;

    // Column 0
    m[M00] = scale.x * (1.0 - 2.0 * (y2 + z2));
    m[M10] = 2.0 * scale.y * (xy - wz);
    m[M20] = 2.0 * scale.z * (xz + wy);
    m[M30] = 0;

    // Column 1
    m[M01] = 2.0 * scale.x * (xy + wz);
    m[M11] = scale.y * (1.0 - 2.0 * (x2 + z2));
    m[M21] = 2.0 * scale.z * (yz - wx);
    m[M31] = 0;

    // Column 2
    m[M02] = 2.0 * scale.x * (xz - wy);
    m[M12] = 2.0 * scale.y * (yz + wx);
    m[M22] = scale.z * (1.0 - 2.0 * (x2 + y2));
    m[M32] = 0;

    // Column 3
    m[M03] = position.x;
    m[M13] = position.y;
    m[M23] = position.z;
    m[M33] = 1.0;
    return this;
}