public static class TLcdPanoramicTransformationFactory.SphericalTransformationBuilder extends Object
ILcdModelModelTransformations
that transform 3D reference CS
points to 2D image CS points for spherical camera images ("equirectangular images").
By default, this transformation expects the center of the image to point to east (X) and the top of the image up (Z).
You can change this by specifying a rotation(double[])
.
Constructor and Description |
---|
SphericalTransformationBuilder() |
Modifier and Type | Method and Description |
---|---|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
aspectRatio(double aAspectRatio)
Set the aspect ratio width:height of the image.
|
ILcdModelModelTransformation |
build()
Build the perspective transformation with this builder's current parameters.
|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
fov(double aHorizontalFov,
double aVerticalFov)
Set the horizontal and vertical field of view values.
|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
fromImage(int aImageWidth,
int aImageHeight,
double aPixelWidth,
double aPixelHeight)
Get the spherical camera parameters from image properties.
|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
horizontalFov(double aHorizontalFov)
Set the horizontal field of view value.
|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
principalPoint(double aPrincipalX,
double aPrincipalY)
Set the x and y coordinates of the image's principal point.
|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
rotation(double[] aRotation)
Set the 3 x 3 rotation matrix for the transformation.
|
TLcdPanoramicTransformationFactory.SphericalTransformationBuilder |
verticalFov(double aVerticalFov)
Set the vertical field of view value.
|
public ILcdModelModelTransformation build()
public TLcdPanoramicTransformationFactory.SphericalTransformationBuilder rotation(double[] aRotation)
By default, this transformation expects the center of the image to point to east (X) and the top of the image up (Z).
As such, the default value for this property is the identity matrix.
The rotation matrix describes how the 3D camera CS is rotated relative to the reference CS. It is provided as a row-major array of doubles:
[ m11, m12, m13, m21, m22, m23, m31, m32, m33 ]
You can use this rotation to orient your image in the world. Example 1: input image center is pointing north
Often, equirectangular/spherical images are defined so that the center of the image is looking north/Y. As this spherical transformation expects the center to look east/Z, you need to apply a rotation.
You can view this best as swapping the original axes with the desired axes. In this case, mapping X onto -Y, and Y onto X. You can also view this as rotating by 90 degrees counter-clockwise around the Z axis.
double[] axisSwapMatrix = new double[] { 0, -1, 0, 1, 0, 0, 0, 0, 1 };Example 2: input image center is pointing to a specific heading
The center of the image might not be pointing north, but in a specific heading derived from GPS or sensor information.
If you have heading information in the form an azimuth (degrees, clockwise starting north), you can apply a rotation around Z.
Matrix3d headingMatrix = new Matrix3d(); headingMatrix.rotZ(Math.toRadians(-heading));Example 3: combination of both
You can combine the two operations by multiplying the matrices into one.
Matrix3d combinedMatrix = new Matrix3d(); combinedMatrix.setIdentity(); combinedMatrix.mul(axisSwapMatrix); combinedMatrix.mul(headingMatrix); double[] combinedMatrixDoubles = new double[]{ combinedMatrix.m00, combinedMatrix.m01, combinedMatrix.m02, combinedMatrix.m10, combinedMatrix.m11, combinedMatrix.m12, combinedMatrix.m20, combinedMatrix.m21, combinedMatrix.m22 };
aRotation
- the 3 x 3 rotation matrix as array of doubles, ordered row-majorpublic TLcdPanoramicTransformationFactory.SphericalTransformationBuilder fov(double aHorizontalFov, double aVerticalFov)
horizontalFov(double)
and verticalFov(double)
.aHorizontalFov
- the horizontal field of view, in degreesaVerticalFov
- the vertical field of view, in degreespublic TLcdPanoramicTransformationFactory.SphericalTransformationBuilder horizontalFov(double aHorizontalFov)
The default value for this property is 360°. See also build()
.
aHorizontalFov
- the horizontal field of view, in degreespublic TLcdPanoramicTransformationFactory.SphericalTransformationBuilder verticalFov(double aVerticalFov)
The default value for this property is 180°. See also build()
.
aVerticalFov
- the vertical field of view, in degreespublic TLcdPanoramicTransformationFactory.SphericalTransformationBuilder aspectRatio(double aAspectRatio)
This property is used to calculate either the horizontal or
vertical field of view value if only one of them is provided.
It has no default value. See build()
.
aAspectRatio
- the aspect ratiopublic TLcdPanoramicTransformationFactory.SphericalTransformationBuilder principalPoint(double aPrincipalX, double aPrincipalY)
The principal point is the point on the image where the X axis of the camera CS intersects the image plane.
Note that the point is expressed in terms of the 2D image CS, in the range (0.0,0.0) to (1.0,1.0).
See TLcdPanoramicTransformationFactory
.
The default value for this property is (0.5,0.5).
aPrincipalX
- the x coordinate of the image's principal pointaPrincipalY
- the y coordinate of the image's principal pointpublic TLcdPanoramicTransformationFactory.SphericalTransformationBuilder fromImage(int aImageWidth, int aImageHeight, double aPixelWidth, double aPixelHeight)
The pixel size parameters are expressed in radians.
The image size parameters are expressed in number of pixels.
aImageWidth
- the width of the image (in pixels)aImageHeight
- the height of the image (in pixels)aPixelWidth
- the width of a single pixel (in radians)aPixelHeight
- the height of a single pixel (in radians)