List of usage examples for android.hardware.camera2 CameraCharacteristics CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
Key CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
To view the source code for android.hardware.camera2 CameraCharacteristics CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES.
Click Source Link
List of frame rate ranges for CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE android.control.aeTargetFpsRange supported by this camera device.
For devices at the LEGACY level or above:
For constant-framerate recording, for each normal android.media.CamcorderProfile CamcorderProfile , that is, a android.media.CamcorderProfile CamcorderProfile that has android.media.CamcorderProfile#quality quality in the range [ android.media.CamcorderProfile#QUALITY_LOW QUALITY_LOW , android.media.CamcorderProfile#QUALITY_2160P QUALITY_2160P ], if the profile is supported by the device and has android.media.CamcorderProfile#videoFrameRate videoFrameRate x
, this list will always include (x
,x
).
Also, a camera device must either not support any android.media.CamcorderProfile CamcorderProfile , or support at least one normal android.media.CamcorderProfile CamcorderProfile that has android.media.CamcorderProfile#videoFrameRate videoFrameRate x
>= 24.
For devices at the LIMITED level or above:
min
, max
) and (max
, max
) where min
<= 15 and max
= the maximum output frame rate of the maximum YUV_420_888 output size.Units: Frames per second (FPS)
This key is available on all devices.
From source file:com.askjeffreyliu.camera2barcode.camera.CameraSource.java
/** * Sets up member variables related to camera. * * @param width The width of available size for camera preview * @param height The height of available size for camera preview *///from ww w.j a v a2 s .co m private void setUpCameraOutputs(int width, int height) { try { if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { return; } if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) { throw new RuntimeException("Time out waiting to lock camera opening."); } if (manager == null) manager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE); mCameraId = manager.getCameraIdList()[mFacing]; CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { return; } // For still image captures, we use the largest available size. Size largest = getBestAspectPictureSize(map.getOutputSizes(ImageFormat.JPEG)); // Find out if we need to swap dimension to get the preview size relative to sensor // coordinate. int displayRotation = mDisplayOrientation; //noinspection ConstantConditions int mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); boolean swappedDimensions = false; switch (displayRotation) { case Surface.ROTATION_0: case Surface.ROTATION_180: if (mSensorOrientation == 90 || mSensorOrientation == 270) { swappedDimensions = true; } break; case Surface.ROTATION_90: case Surface.ROTATION_270: if (mSensorOrientation == 0 || mSensorOrientation == 180) { swappedDimensions = true; } break; default: Log.e(TAG, "Display rotation is invalid: " + displayRotation); } Point displaySize = new Point(Utils.getScreenWidth(mContext), Utils.getScreenHeight(mContext)); int rotatedPreviewWidth = width; int rotatedPreviewHeight = height; int maxPreviewWidth = displaySize.x; int maxPreviewHeight = displaySize.y; if (swappedDimensions) { rotatedPreviewWidth = height; rotatedPreviewHeight = width; maxPreviewWidth = displaySize.y; maxPreviewHeight = displaySize.x; } if (maxPreviewWidth > MAX_PREVIEW_WIDTH) { maxPreviewWidth = MAX_PREVIEW_WIDTH; } if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) { maxPreviewHeight = MAX_PREVIEW_HEIGHT; } // 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. Size[] outputSizes = Utils.sizeToSize(map.getOutputSizes(SurfaceTexture.class)); mPreviewSize = chooseOptimalSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = mDisplayOrientation; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight()); } else { mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth()); } // Check if the flash is supported. Boolean available = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE); mFlashSupported = available == null ? false : available; // control.aeTargetFpsRange Range<Integer>[] availableFpsRange = characteristics .get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); configureTransform(width, height); manager.openCamera(mCameraId, mStateCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while trying to lock camera opening.", e); } catch (NullPointerException e) { // Currently an NPE is thrown when the Camera2API is used but not supported on the // device this code runs. Log.d(TAG, "Camera Error: " + e.getMessage()); } }