这是在java中打印几个camera2 Api特性的代码。您可以使用相同的概念并尝试在 c# 中实现。这可能不是有效的代码,但可以达到您的目的。
某些特性在某些手机中不起作用,因此这取决于您用于测试的手机。我试过 Nexus 5 和联想手机。
流配置映射特征。从这个链接:
private void setupCamera(int width, int height) {
CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
for(String cameraId: cameraManager.getCameraIdList()) {
CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
if(cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
continue;
}
StreamConfigurationMap map = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
//GET OUTPUT SIZES
mOutputsize = map.getOutputSizes(SurfaceTexture.class);
for(int i=0; i<mOutputsize.length; i++) {
Log.d("OUTPUT SIZES", String.valueOf(mOutputsize[i]));
}
//GET HIGH SPEED VIDEO SIZE
//All the sizes listed in this method are the subset of getOutputSizes(int) method
mHighSpeedVideoSize = map.getHighSpeedVideoSizes();
for(int j=0; j<mHighSpeedVideoSize.length; j++) {
Log.d("OUTPUT SIZES", "High speed video sizes");
Log.d("OUTPUT SIZES", mHighSpeedVideoSize[j].toString());
}
//GET THE IMAGE OUTPUT FORMAT (make sure you check if the array is pointing is null or not, otherwise you will have null point exception. The best way is to comment and see one by one)
mOutputFormat = map.getOutputFormats();
Log.d("OUTPUT SIZES", "Image Output Format: ");
Log.d("OUTPUT SIZES", "Image.format = RAW_SENSOR, Constant Value: 32 (0x00000020) " + String.valueOf(mOutputFormat[0]));
Log.d("OUTPUT SIZES", "Image.format = JPEG, Constant Value: 256 (0x00000100) " + String.valueOf(mOutputFormat[1]));
Log.d("OUTPUT SIZES", "Image.format = PRIVATE, Constant Value: 34 (0x00000022) " + String.valueOf(mOutputFormat[2]));
Log.d("OUTPUT SIZES", "Image.format = YUV_420_888, Constant Value: 35 (0x00000023) " + String.valueOf(mOutputFormat[3]));
我什至尝试从这个链接打印一些特征。这里是:
//COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES
int[] aberration = cameraCharacteristics.get(CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES);
String str2;
for(int i=0; i<aberration.length; i++) {
str2 = String.valueOf(aberration[i]);
Log.d("OUTPUT SIZES ABR ", str2);
}
Log.d("OUTPUT SIZES Length: ", String.valueOf(aberration.length));
//CONTROL_AE_COMPENSATION_RANGE
Range<Integer> exposureRange = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE);
String maxRange = String.valueOf(exposureRange);
Log.d("OUTPUT SIZES EXPO range", maxRange + "\n");
//CONTROL_AE_COMPENSATION_STEP
Rational step = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);
Log.d("OUTPUT SIZE COMP step", String.valueOf(step));
//CONTROL_AE_LOCK_AVAILABLE
boolean lock = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_LOCK_AVAILABLE);
Log.d("OUTPUT SIZES LOCK avai", String.valueOf(lock));
//CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES
int[] videoStabilizationModes = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES);
for(int i=0; i<videoStabilizationModes.length; i++) {
Log.d("OUTPUT SIZES STABI mode", String.valueOf(videoStabilizationModes[i]));
}
//CONTROL_MAX_REGIONS_AWB
Integer regionsAWB = cameraCharacteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AWB);
Log.d("OUTPUT SIZES REGION AWB", String.valueOf(regionsAWB));
//JPEG_AVAILABLE_THUMBNAIL_SIZES
Size[] jpegThumbnail = cameraCharacteristics.get(CameraCharacteristics.JPEG_AVAILABLE_THUMBNAIL_SIZES);
for(int i=0; i<jpegThumbnail.length; i++) {
Log.d("OUTPUT SIZES JPEG THUMB", String.valueOf(jpegThumbnail[i]));
}
//SENSOR_BLACK_LEVEL_PATTERN
BlackLevelPattern blackLevelPattern = cameraCharacteristics.get(CameraCharacteristics.SENSOR_BLACK_LEVEL_PATTERN);
Log.d("OUTPUT SIZES BLCK PTRN", String.valueOf(blackLevelPattern));
mCameraId = cameraId;
return;
}
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
PS:这不是完整的代码。这是我为此答案为相机应用程序编写的代码片段。我想你只需要知道特征。我在代码中使用了一些变量,但未在此答案中声明。我认为你现在不需要这些信息。快乐编码:)