Defines all required parameters to correct the distortion caused by the lenses.
Public Constructors
Public Methods
static Distortion |
cardboardV1Distortion()
Return distortion parameters for Cardboard v1.0.0.
|
float |
distort(float radius)
Distorts a radius by its distortion factor from the center of the lenses.
|
float |
distortionFactor(float radius)
Returns the distortion factor of a point.
|
boolean | |
Distortion |
getApproximateInverseDistortion(float maxRadius, int numCoefficients)
Builds an inverse-distortion object with least-squares-fitted coefficients.
|
float[] |
getCoefficients()
Returns the current coefficients for lens distortion correction.
|
void |
setCoefficients(float[] coefficients)
Sets the coefficients for lens distortion correction.
|
String |
toString()
Returns a string containing a concise, human-readable description of this object.
|
Inherited Methods
Public Constructors
public Distortion ()
public Distortion (Distortion other)
Constructs a copy of another distortion object.
Parameters
other | The distortion object to copy from. |
---|
Public Methods
public static Distortion cardboardV1Distortion ()
Return distortion parameters for Cardboard v1.0.0.
public float distort (float radius)
Distorts a radius by its distortion factor from the center of the lenses.
Parameters
radius | Radius from the lens center in tan-angle units. |
---|
Returns
- The distorted radius in tan-angle units.
public float distortionFactor (float radius)
Returns the distortion factor of a point.
Parameters
radius | Radius of the point from the lens center in tan-angle units. |
---|
Returns
- The distortion factor. Multiply by this factor to distort points.
public boolean equals (Object other)
Compares this instance with the specified object and indicates if they are equal.
Parameters
other | The object to compare this instance with. |
---|
Returns
true
if the objects are equal,false
otherwise.
public Distortion getApproximateInverseDistortion (float maxRadius, int numCoefficients)
Builds an inverse-distortion object with least-squares-fitted coefficients.
This is intended for implementing application-side custom distortion. Use .getCoefficients() on the returned object to retrieve the inverse distortion function's coefficients.
This is an approximate inverse, and using .distort() on the returned object will be faster but less accurate than using the distortInverse() method on the original. For useful results, the input distortion must be well-behaved in the 0..maxRadius range.
Example for 50 degree half-angle FOV (100 degrees total), this will create an inverse distortion where inverse.distort(r) approximately equals distortion.distortInverse(r) in the range r = 0 ... maxFovHalfAngle.
float maxFovHalfAngle = 50.0f * Math.PI / 180.0f; float maxRadiusLens = distortion.distortInverse(maxFovHalfAngle); Distortion inverse = distortion.getApproximateInverseDistortion( maxRadiusLens, 6);
Parameters
maxRadius | Maximum supported radius in tan-angle units in lens space (after applying barrel distortion). Should be set to inverseDistort(tan(maximum expected FOV angle)) to create an inverse that will be usable for inputs up to tan(maximum expected FOV angle). |
---|---|
numCoefficients | Number of desired coefficients, more provide a better fit. Does not need to match the number of coefficients in the input distortion object. 6 coefficients recommended for current GVR viewers, using more can get numerically unstable. |
Returns
- New distortion object.
public float[] getCoefficients ()
Returns the current coefficients for lens distortion correction.
Returns
- A floating point array with the current barrel distortion coefficients.
public void setCoefficients (float[] coefficients)
Sets the coefficients for lens distortion correction.
The coefficients Ki correspond to the pincushion distortion equation:
p' = p (1 + K1 r^2 + K2 r^4 + ... + Kn r^(2n))
Where r is the distance from the optical center, p the input point and p' the output point.
Parameters
coefficients | Barrel distortion coefficients to set. |
---|
public String toString ()
Returns a string containing a concise, human-readable description of this object.
Returns
- A printable representation of this object.