您的位置:首页 > 移动开发 > Android开发

Google cardBoard Android API (五):Distortion

2016-03-21 15:00 411 查看
public class Distortion

Defines all required parameters to correct the distortion caused by the lenses.


Public Constructors

Distortion()
Distortion(Distortion other)


Public Methods

staticDistortioncardboardV1Distortion()
floatdistort(float
radius)
floatdistortionFactor(float
radius)
booleanequals(Object other)
DistortiongetApproximateInverseDistortion(float
maxRadius, int numCoefficients)
float[]getCoefficients()
void)]setCoefficients(float[]
coefficients)
StringtoString()


Inherited Methods

▸From class java.lang.Object


Public Constructors


public Distortion ()


public Distortion (Distortion other)

Constructs a copy of another distortion object.


Parameters


otherThe 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


radiusRadius 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


radiusRadius 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


otherThe 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


maxRadiusMaximum 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).
numCoefficientsNumber 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 Cardboard devices, 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


coefficientsBarrel 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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: