gpt4 book ai didi

java - ARCore – 光估计

转载 作者:行者123 更新时间:2023-11-30 01:55:44 27 4
gpt4 key购买 nike

我一直在尝试了解如何在我的 Android 应用中使用 ARCore 的光估计功能。大多数关于光估计的教程都是针对 Unity 的。不过我的项目使用的是 Android Studio。

如果有人可以解释如何使用光估计来在关闭灯光时触发着色器或动画的变化?

最佳答案

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

让我们看看 Android Studio 中用于 ARCore 光估计的代码应该是什么样子:

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 亮度。

关于java - ARCore – 光估计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54609526/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com