Google cardBoard Android API (五):Distortion

20 篇文章 0 订阅
18 篇文章 0 订阅
public class Distortion

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

Public Constructors

Public Methods

staticDistortion
float
distort(float radius)
float
distortionFactor(float radius)
boolean
equals(Object other)
Distortion
getApproximateInverseDistortion(float maxRadius, int numCoefficients)
float[]
void
setCoefficients(float[] coefficients)
String

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 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
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值