我试图禁用相机自动曝光。根据此处的文档https://developers.google.com/project-tango/apis/c/reference/group/config-params,可以在配置中设置color_mode_auto,color_exp和color_iso值。
我已经尝试在TangoApplication.cs中创建TangoConfig对象之后直接设置值,但我收到一条警告,说这些TangoConfig无法设置相关键(直接从文档中获取的键字符串名称)上文)。
是否可以在C#中设置这些值,如果是,那么正确的位置在哪里?
答案 0 :(得分:1)
您可能需要编写一个可以在Unity摄像头实例上设置iso值和曝光的插件。你可以通过一个实例来运行相机的参与,通过一些涉及解析相机实例的棘手的hackery,然后你应该能够注入iso /曝光参数。
此类插件的示例类似于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);
干杯