无法在包-camera2 CameraCharacteristics.Key之外访问类



我使用的是Camera2api,无法构造要查找的Key例如

public static CameraCharacteristics.Key<Byte> IS_SUPPORT_QCFA_SENSOR =
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.quadra_cfa.is_qcfa_sensor", Byte.class);

导致消息

'Key(java.lang.String, java.lang.Class<T>)' is not public in 'android.hardware.camera2.CameraCharacteristics.Key'. Cannot be accessed from outside package

但是,为了查找密钥,必须构建它们。developer.android.com上的文档显示这是

public static final class CameraCharacteristics.Key

如何构造密钥?或者解决这个问题?

最近在研究类似的东西时发现了这一点。看看来自的样本

https://github.com/dragonGR/packages_apps_SnapdragonCamera/blob/1c35bb80c3abfe6a7c5212572aa8abbeb9850eb2/src/com/android/camera/util/VendorTagUtil.java

它们使用CaptureRequest而不是CameraCharacteristics来定义密钥,并且可以在定义相机设备后进行访问。

也许值得一试,相反,链接有更多的细节。

private static CaptureRequest.Key<Integer> CdsModeKey =
new CaptureRequest.Key<>("org.codeaurora.qcamera3.CDS.cds_mode",
Integer.class);
and
private static boolean isSupported(CaptureRequest.Builder builder,
CaptureRequest.Key<?> key) {
boolean supported = true;
try {
builder.get(key);
}catch(IllegalArgumentException exception){
supported = false;
Log.d(TAG, "vendor tag " + key.getName() + " is not supported");
exception.printStackTrace();
}
if ( supported ) {
Log.d(TAG, "vendor tag " + key.getName() + " is supported");
}
return supported;
}

最新更新