gpt4 book ai didi

google-project-tango - 如何从 c#/Unity 设置探戈相机曝光和 iso 参数

转载 作者:行者123 更新时间:2023-12-04 23:12:17 25 4
gpt4 key购买 nike

我正在尝试禁用相机自动曝光。根据此处的文档,https://developers.google.com/project-tango/apis/c/reference/group/config-params ,可以在配置中设置 color_mode_auto、color_exp 和 color_iso 值。

我已经尝试在 TangoApplication.cs 中创建 TangoConfig 对象后立即为其设置值,但我收到一条警告,说这些 TangoConfig 无法设置相关键(键字符串名称直接取自上面的文档) .

是否可以在 C# 中设置这些值,如果可以,正确的位置在哪里?

最佳答案

您可能需要编写一个插件来设置 Unity 相机实例的 iso 值和曝光。您可以通过一些涉及解析相机实例的棘手黑客将实例作为正在运行的相机的引用,然后您应该能够注入(inject) iso/曝光参数。

此类插件的一个示例是 Camera Capture Kit for Unity (https://www.assetstore.unity3d.com/en/#!/content/56673)

它将使您能够连接到相机并应用属性。以下是有关如何解析相机的片段。

Class clsPlayer = Class.forName("com.unity3d.player.UnityPlayer");
Field fCurrentActivity = clsPlayer.getDeclaredField("currentActivity");
fCurrentActivity.setAccessible(true);
com.unity3d.player.UnityPlayerActivity currentActivity = (com.unity3d.player.UnityPlayerActivity)fCurrentActivity.get(null);
ret.playerActivity = currentActivity;

Field fPlayer = currentActivity.getClass().getDeclaredField("mUnityPlayer");
fPlayer.setAccessible(true);
com.unity3d.player.UnityPlayer player = (com.unity3d.player.UnityPlayer)fPlayer.get(currentActivity);
ret.player = player;

Field f = player.getClass().getDeclaredField("y");
f.setAccessible(true);
java.util.ArrayList cameraArrays = (java.util.ArrayList)f.get( player );
int sz = cameraArrays.size();

然后您将不得不更改 Android 插件中的参数,使用类似这样的东西(取自 Camera Capture Kit)

Camera.Parameters params = ret.camera.getParameters();

String flat = params.flatten();
String iso_keyword=null;
if(flat.contains("iso-values")) {
iso_keyword="iso";
} else if(flat.contains("iso-mode-values")) {
iso_keyword="iso";
} else if(flat.contains("iso-speed-values")) {
iso_keyword="iso-speed";
} else if(flat.contains("nv-picture-iso-values")) {
iso_keyword="nv-picture-iso";
}
if( iso_keyword == null ) {
Log.d("Unity", "CameraCaptureKit: It looks like there was no support for iso on the device." );
return;
}

String strSupportedIsoValues = UnityCamera_GetSupportedISOValues();
ArrayList<String> supportedIsoValues = new ArrayList<String>(Arrays.asList(strSupportedIsoValues.split(",") ));
//ArrayList<String> supportedIsoValues = Arrays.asList( strSupportedIsoValues.split(",") );
boolean contains = false;
for( String isoValue : supportedIsoValues ) {
if(isoValue.contains(newValue)) {
contains = true;
break;
}
}
if( contains == false ) {
Log.d("Unity", "CameraCaptureKit: failed to set ISO, the value " + newValue + " is not supported. ( " + strSupportedIsoValues + " )" );
return;
}

// update the camera.
params.set( iso_keyword, newValue );
ret.camera.setParameters(params);

干杯

关于google-project-tango - 如何从 c#/Unity 设置探戈相机曝光和 iso 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36483336/

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