本文整理匯總了Java中android.hardware.camera2.CameraCharacteristics.getKeys方法的典型用法代碼示例。如果您正苦於以下問題:Java CameraCharacteristics.getKeys方法的具體用法?Java CameraCharacteristics.getKeys怎麽用?Java CameraCharacteristics.getKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.camera2.CameraCharacteristics
的用法示例。
在下文中一共展示了CameraCharacteristics.getKeys方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: formatCameraCharacteristics
import android.hardware.camera2.CameraCharacteristics; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private String formatCameraCharacteristics(CameraCharacteristics info) {
String infoText;
if (info != null) {
StringBuilder infoBuilder = new StringBuilder(
"Camera characteristics:\n\n");
for (CameraCharacteristics.Key<?> key : info.getKeys()) {
infoBuilder.append(String.format(Locale.US, "%s: ",
key.getName()));
Object val = info.get(key);
if (val.getClass().isArray()) {
// Iterate an array-type value
// Assumes camera characteristics won't have arrays of arrays as values
int len = Array.getLength(val);
infoBuilder.append("[ ");
for (int i = 0; i < len; i++) {
infoBuilder.append(String.format(Locale.US, "%s%s",
Array.get(val, i), (i + 1 == len) ? ""
: ", "));
}
infoBuilder.append(" ]\n\n");
} else {
// Single value
infoBuilder.append(String.format(Locale.US, "%s\n\n",
val.toString()));
}
}
infoText = infoBuilder.toString();
} else {
infoText = "No info";
}
return infoText;
}
示例2: setUpCameraOutputs
import android.hardware.camera2.CameraCharacteristics; //導入方法依賴的package包/類
/**
* Sets up member variables related to camera.
*/
private void setUpCameraOutputs(int width, int height) throws CameraAccessException {
MLog.d(TAG, "setUpCameraOutputs");
String[] cameras = mCameraManager.getCameraIdList();
for (int i = 0; i < cameras.length; i++) {
MLog.d(TAG, "camera " + cameras[i]);
}
String cameraId = cameras[0];
CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(cameraId);
List<CameraCharacteristics.Key<?>> keys = characteristics.getKeys();
for (int i = 0; i < keys.size(); i++) {
Object val = characteristics.get(keys.get(i));
MLog.d(TAG, "characteristic " + keys.get(i) + " " + val);
}
// is it facingcamera
Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
// For still image captures, we use the largest available size.
Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea());
mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/2);
mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, null);
// Danger, W.R.! Attempting to use too large a preview size could exceed the camera
// bus' bandwidth limitation, resulting in gorgeous previews but the storage of
// garbage capture data.
int rotatedPreviewWidth = 500;
int rotatedPreviewHeight = 500;
int maxPreviewWidth = 500;
int maxPreviewHeight = 500;
mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class),
rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth,
maxPreviewHeight, largest);
//TODO mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight());
mCameraId = cameraId;
}