在这个例子中,谷歌vr应用双目扭曲



我正在为谷歌纸板开发一个应用程序,它将播放两个视频,每只眼睛一个,以模拟3D视觉。我只打算使用google vr sdk来模拟将应用于每一帧的双目扭曲,但是从这个例子中不清楚哪个函数实际应用了扭曲。

/**
 * Draws a frame for an eye.
 *
 * @param eye The eye to render. Includes all required transformations.
 */
@Override
public void onDrawEye(Eye eye) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    ...
    // Apply the eye transformation to the camera.
    Matrix.multiplyMM(mView, 0, eye.getEyeView(), 0, mCamera, 0);
    // Set the position of the light
    Matrix.multiplyMV(mLightPosInEyeSpace, 0, mView, 0, LIGHT_POS_IN_WORLD_SPACE, 0);
    // Build the ModelView and ModelViewProjection matrices
    // for calculating cube position and light.
    float[] perspective = eye.getPerspective(Z_NEAR, Z_FAR);
    Matrix.multiplyMM(mModelView, 0, mView, 0, mModelCube, 0);
    Matrix.multiplyMM(mModelViewProjection, 0, perspective, 0, mModelView, 0);
    drawCube();
    // Draw the rest of the scene.
    ...
}

这个代码片段的描述如下:

这是事件的顺序:

  • 宝藏进入视线。
  • 我们应用投影矩阵。这提供了为指定眼睛渲染的场景。
  • Google VR SDK自动应用失真,以渲染最终场景。

然而,这第三步实际上并没有解释。因为我不是渲染和图像,只是使用现实生活中的视频,我只需要使用应用失真的代码部分,但是我不清楚这究竟是如何发生的。

如果有人有什么想法,请告诉我

public Distortion getestimateinversedistortion (float maxRadius, int numCoefficients)

构建具有最小二乘拟合系数的反失真对象。

这用于实现应用程序端自定义失真。在返回的对象上使用. getcoefficients()来检索逆失真函数的系数。

这是一个近似的逆,在返回的对象上使用. distortion()会比在原始对象上使用twistinverse()方法更快,但准确性更低。为了得到有用的结果,输入失真必须在0..maxRadius范围。

对于50度半角FOV(总共100度),这将创建一个反向失真,其中reverse . distortion (r)在r = 0…maxFovHalfAngle .

更多信息:https://developers.google.com/vr/android/reference/com/google/vr/sdk/base/Distortion

https://www.baekdal.com/insights/why相当-多- 360 vr -视频-误会————

最新更新