ARCore光估计

问题描述 投票:1回答:1

我一直试图了解如何在我的Android应用程序中使用AR核心的光估计功能。关于光估计的大多数教程都是统一的。但是我正在为我的项目使用Android studio。如果有人能解释如何使用光估计在关闭灯光时触发着色器或动画的变化?

augmented-reality arcore
1个回答
0
投票

目前在ARCore中没有诚实的光估计,只是粗略的近似。

让我们看看Android Studio中用于ARCore的Light Estimation的代码应该如何:

try {
    session.setCameraTextureName(backgroundRenderer.getTextureId());

    Frame frame = session.update();
    Camera camera = frame.getCamera();

    // Compute lighting from average intensity of the image.
    // 3 components here are color factors, the fourth one is intensity.

    final float[] colorCorrectionRgba = new float[4];
    frame.getLightEstimate().getColorCorrection(colorCorrectionRgba, 0); 

} catch (Throwable t) {
    Log.e(TAG, "Exception on the OpenGL thread", t);
}

估计仅仅是来自手机彩色摄像机的整个捕获场景的平均亮度。 1.0是白色,0.0是黑色。它与您所在房间的实际亮度无关,但取决于相机如何通过曝光设置感知它。相机的曝光始终不准确,取决于相机指向的位置。您只获得整个场景的一个全局光估计值。您无法根据放置对象的特定区域亮度调整对象。

Hello_AR_Example项目的着色器将对象颜色与全局光估计相乘。这适应(并且通常降低)最终表面颜色的RGB亮度。

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.