Java Code Examples for android.hardware.camera2.CameraCharacteristics#getKeys()
The following examples show how to use
android.hardware.camera2.CameraCharacteristics#getKeys() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OSFragment.java From DeviceInfo with Apache License 2.0 | 5 votes |
@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; }
Example 2
Source File: CameraTexture2.java From PHONK with GNU General Public License v3.0 | 4 votes |
/** * 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; }