android.hardware.camera2.params.StreamConfigurationMap Java Examples
The following examples show how to use
android.hardware.camera2.params.StreamConfigurationMap.
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: VIACamera.java From VIA-AI with MIT License | 8 votes |
@TargetApi(21) public static Size[] querySupportResolution(Context context, int index) { CameraManager manager = (CameraManager)context.getSystemService(CAMERA_SERVICE); try { CameraCharacteristics chars = manager.getCameraCharacteristics(index+""); StreamConfigurationMap configurationMap = chars.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); return configurationMap.getOutputSizes(ImageFormat.YUV_420_888); } catch(CameraAccessException e){ e.printStackTrace(); } return null; }
Example #2
Source File: Helper.java From VIA-AI with MIT License | 8 votes |
public void forceScanAllCameras(Activity activity) { CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE); try { String[] idList = manager.getCameraIdList(); int maxCameraCnt = idList.length; for (int index = 0; index < maxCameraCnt; index++) { String cameraId = manager.getCameraIdList()[index]; CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); } } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #3
Source File: Camera2Proxy.java From CameraDemo with Apache License 2.0 | 6 votes |
@SuppressLint("MissingPermission") public void openCamera(int width, int height) { Log.v(TAG, "openCamera"); startBackgroundThread(); // 对应 releaseCamera() 方法中的 stopBackgroundThread() mOrientationEventListener.enable(); try { mCameraCharacteristics = mCameraManager.getCameraCharacteristics(Integer.toString(mCameraId)); StreamConfigurationMap map = mCameraCharacteristics.get(CameraCharacteristics .SCALER_STREAM_CONFIGURATION_MAP); // 拍照大小,选择能支持的一个最大的图片大小 Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); Log.d(TAG, "picture size: " + largest.getWidth() + "*" + largest.getHeight()); mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, 2); // 预览大小,根据上面选择的拍照图片的长宽比,选择一个和控件长宽差不多的大小 mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height, largest); Log.d(TAG, "preview size: " + mPreviewSize.getWidth() + "*" + mPreviewSize.getHeight()); // 打开摄像头 mCameraManager.openCamera(Integer.toString(mCameraId), mStateCallback, mBackgroundHandler); } catch (CameraAccessException e) { e.printStackTrace(); } }
Example #4
Source File: CameraFragment.java From SnapchatClone with MIT License | 6 votes |
private void setupCamera(int width, int height) { try { for (String camId: cameraManager.getCameraIdList()) { CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(camId); if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == cameraFacing) { StreamConfigurationMap streamConfigurationMap = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); previewSize = chooseOptimalSize(streamConfigurationMap.getOutputSizes(SurfaceTexture.class), streamConfigurationMap.getOutputSizes(ImageFormat.JPEG), width, height); cameraId = camId; return; } } } catch (Exception e) { e.printStackTrace(); } }
Example #5
Source File: Camera2Proxy.java From mobile-ar-sensor-logger with GNU General Public License v3.0 | 6 votes |
public Size configureCamera(int width, int height) { try { mCameraIdStr = CameraUtils.getRearCameraId(mCameraManager); mCameraCharacteristics = mCameraManager.getCameraCharacteristics(mCameraIdStr); sensorArraySize = mCameraCharacteristics.get( CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); StreamConfigurationMap map = mCameraCharacteristics.get(CameraCharacteristics .SCALER_STREAM_CONFIGURATION_MAP); mVideoSize = CameraUtils.chooseVideoSize( map.getOutputSizes(MediaRecorder.class), width, height, width); mFocalLengthHelper.setLensParams(mCameraCharacteristics); mFocalLengthHelper.setmImageSize(mVideoSize); mPreviewSize = CameraUtils.chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), width, height, mVideoSize); Log.d(TAG, "Video size " + mVideoSize.toString() + " preview size " + mPreviewSize.toString()); } catch (CameraAccessException e) { e.printStackTrace(); } return mPreviewSize; }
Example #6
Source File: OneCameraZslImpl.java From Camera2 with Apache License 2.0 | 6 votes |
/** * @return The largest supported picture size. */ public Size getDefaultPictureSize() { StreamConfigurationMap configs = mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); android.util.Size[] supportedSizes = configs.getOutputSizes(sCaptureImageFormat); // Find the largest supported size. android.util.Size largestSupportedSize = supportedSizes[0]; long largestSupportedSizePixels = largestSupportedSize.getWidth() * largestSupportedSize.getHeight(); for (int i = 0; i < supportedSizes.length; i++) { long numPixels = supportedSizes[i].getWidth() * supportedSizes[i].getHeight(); if (numPixels > largestSupportedSizePixels) { largestSupportedSize = supportedSizes[i]; largestSupportedSizePixels = numPixels; } } return new Size(largestSupportedSize.getWidth(), largestSupportedSize.getHeight()); }
Example #7
Source File: OneCameraCharacteristicsImpl.java From Camera2 with Apache License 2.0 | 6 votes |
@Override public List<Size> getSupportedPictureSizes(int imageFormat) { StreamConfigurationMap configMap; try { configMap = mCameraCharacteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); } catch (Exception ex) { Log.e(TAG, "Unable to obtain picture sizes.", ex); // See b/19623115 where java.lang.AssertionError can be thrown due to HAL error return new ArrayList<>(0); } ArrayList<Size> supportedPictureSizes = new ArrayList<>(); for (android.util.Size androidSize : configMap.getOutputSizes(imageFormat)) { supportedPictureSizes.add(new Size(androidSize)); } return supportedPictureSizes; }
Example #8
Source File: OneCameraCharacteristicsImpl.java From Camera2 with Apache License 2.0 | 6 votes |
@Override public List<Size> getSupportedPreviewSizes() { StreamConfigurationMap configMap; try { configMap = mCameraCharacteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); } catch (Exception ex) { Log.e(TAG, "Unable to obtain preview sizes.", ex); // See b/19623115 where java.lang.AssertionError can be thrown due to HAL error return new ArrayList<>(0); } ArrayList<Size> supportedPictureSizes = new ArrayList<>(); for (android.util.Size androidSize : configMap.getOutputSizes(SurfaceTexture.class)) { supportedPictureSizes.add(new Size(androidSize)); } return supportedPictureSizes; }
Example #9
Source File: OneCameraImpl.java From Camera2 with Apache License 2.0 | 6 votes |
/** * @return The largest supported picture size. */ public Size getDefaultPictureSize() { StreamConfigurationMap configs = mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); android.util.Size[] supportedSizes = configs.getOutputSizes(sCaptureImageFormat); // Find the largest supported size. android.util.Size largestSupportedSize = supportedSizes[0]; long largestSupportedSizePixels = largestSupportedSize.getWidth() * largestSupportedSize.getHeight(); for (int i = 1; i < supportedSizes.length; i++) { long numPixels = supportedSizes[i].getWidth() * supportedSizes[i].getHeight(); if (numPixels > largestSupportedSizePixels) { largestSupportedSize = supportedSizes[i]; largestSupportedSizePixels = numPixels; } } return new Size(largestSupportedSize.getWidth(), largestSupportedSize.getHeight()); }
Example #10
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしている写真サイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしている写真サイズのリスト */ @NonNull static List<Size> getSupportedPictureSizes(final CameraManager cameraManager, final String cameraId) { List<Size> pictureSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if(map != null) { pictureSizes = Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)); Collections.sort(pictureSizes, SIZE_COMPARATOR); } } catch (CameraAccessException e) { // ignore. } return pictureSizes; }
Example #11
Source File: Camera2Controller.java From pixelvisualcorecamera with Apache License 2.0 | 6 votes |
public Size[] getSupportedPictureSizes(String cameraId) { Size[] outputSizes = null; CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); try { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map != null) { outputSizes = map.getOutputSizes(ImageFormat.JPEG); } } catch (CameraAccessException e) { Log.w(TAG, e); } return outputSizes; }
Example #12
Source File: CameraImplV2.java From habpanelviewer with GNU General Public License v3.0 | 6 votes |
@Override public void setDeviceRotation(int deviceOrientation) { mDeviceOrientation = deviceOrientation; // configure transform if preview is running only if (isPreviewRunning()) { try { CameraCharacteristics characteristics = mCamManager.getCameraCharacteristics(mCamera.getId()); StreamConfigurationMap map = characteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { Log.w(TAG, "Could not find a valid preview size"); } else { final Point previewSize = chooseOptimalSize(toPointArray(map.getOutputSizes(ImageFormat.YUV_420_888))); setDeviceOrientation(previewSize); } } catch (CameraAccessException e) { Log.e(TAG, "Failed to set device orientation", e); } } }
Example #13
Source File: Camera2Utils.java From libcommon with Apache License 2.0 | 6 votes |
/** * 指定した条件に合う解像度を選択する * @param manager * @param cameraId * @param targetFace * @param width * @param height * @param degrees * @return * @throws CameraAccessException */ public static CameraConst.CameraInfo chooseOptimalSize( @NonNull final CameraManager manager, final String cameraId, @CameraConst.FaceType final int targetFace, final int width, final int height, final int degrees) throws CameraAccessException { if (DEBUG) Log.v(TAG, String.format("chooseOptimalSize:Size(%dx%d),targetFace=%d,degrees=%d", width, height, targetFace, degrees)); final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); final StreamConfigurationMap map = characteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); final Size previewSize = chooseOptimalSize(characteristics, map, width, height, degrees); final int orientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); if (!TextUtils.isEmpty(cameraId) && (previewSize != null)) { return new CameraConst.CameraInfo(cameraId, targetFace, orientation, previewSize.getWidth(), previewSize.getHeight()); } return null; }
Example #14
Source File: Camera2Helper.java From CameraCompat with MIT License | 6 votes |
@Override protected List<PreviewSize> getSupportedSize() { try { CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics( getCurrentCameraId()); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { return Collections.singletonList(new PreviewSize(mPreviewWidth, mPreviewHeight)); } Size[] supportedSize = map.getOutputSizes(SurfaceTexture.class); if (supportedSize == null || supportedSize.length == 0) { return Collections.singletonList(new PreviewSize(mPreviewWidth, mPreviewHeight)); } List<PreviewSize> results = new ArrayList<>(); for (Size size : supportedSize) { results.add(new PreviewSize(size.getWidth(), size.getHeight())); } return results; } catch (CameraAccessException e) { throw new CameraAccessError(); } }
Example #15
Source File: Camera2.java From MediaPickerInstagram with Apache License 2.0 | 6 votes |
/** * <p>Collects some information from {@link #mCameraCharacteristics}.</p> * <p>This rewrites {@link #mPreviewSizes}, {@link #mPictureSizes}, and optionally, * {@link #mAspectRatio}.</p> */ private void collectCameraInfo() { StreamConfigurationMap map = mCameraCharacteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { throw new IllegalStateException("Failed to get configuration map: " + mCameraId); } mPreviewSizes.clear(); for (android.util.Size size : map.getOutputSizes(mPreview.getOutputClass())) { mPreviewSizes.add(new Size(size.getWidth(), size.getHeight())); } mPictureSizes.clear(); collectPictureSizes(mPictureSizes, map); if (!mPreviewSizes.ratios().contains(mAspectRatio)) { mAspectRatio = mPreviewSizes.ratios().iterator().next(); } }
Example #16
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしているプレビューサイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしているプレビューサイズのリスト */ @NonNull public static List<Size> getSupportedPreviewSizes(final CameraManager cameraManager, final String cameraId) { List<Size> previewSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map != null) { previewSizes = Arrays.asList(map.getOutputSizes(SurfaceTexture.class)); Collections.sort(previewSizes, SizeComparator); } } catch (CameraAccessException e) { // ignore. } return previewSizes; }
Example #17
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしている写真サイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしている写真サイズのリスト */ @NonNull public static List<Size> getSupportedPictureSizes(final CameraManager cameraManager, final String cameraId) { List<Size> pictureSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if(map != null) { pictureSizes = Arrays.asList(map.getOutputSizes(ImageFormat.YUV_420_888)); Collections.sort(pictureSizes, SizeComparator); } } catch (CameraAccessException e) { // ignore. } return pictureSizes; }
Example #18
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしているプレビューサイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしているプレビューサイズのリスト */ @NonNull static List<Size> getSupportedPreviewSizes(final CameraManager cameraManager, final String cameraId) { List<Size> previewSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map != null) { previewSizes = Arrays.asList(map.getOutputSizes(SurfaceTexture.class)); Collections.sort(previewSizes, SizeComparator); } } catch (CameraAccessException e) { // ignore. } return previewSizes; }
Example #19
Source File: Camera2ApiManager.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
public Size[] getCameraResolutions(Facing facing) { try { CameraCharacteristics characteristics = getCharacteristicsForFacing(cameraManager, facing); if (characteristics == null) { return new Size[0]; } StreamConfigurationMap streamConfigurationMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); Size[] outputSizes = streamConfigurationMap.getOutputSizes(SurfaceTexture.class); return outputSizes != null ? outputSizes : new Size[0]; } catch (CameraAccessException | NullPointerException e) { Log.e(TAG, "Error", e); return new Size[0]; } }
Example #20
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしている写真サイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしている写真サイズのリスト */ @NonNull static List<Size> getSupportedPictureSizes(final CameraManager cameraManager, final String cameraId) { List<Size> pictureSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if(map != null) { pictureSizes = Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)); Collections.sort(pictureSizes, SizeComparator); } } catch (CameraAccessException e) { // ignore. } return pictureSizes; }
Example #21
Source File: SettingsPreferenceActivity.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしているプレビューサイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしているプレビューサイズのリスト */ @NonNull private static List<Size> getSupportedPreviewSizes(final CameraManager cameraManager, final String cameraId) { List<Size> previewSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map != null) { previewSizes = Arrays.asList(map.getOutputSizes(SurfaceTexture.class)); Collections.sort(previewSizes, SIZE_COMPARATOR); } } catch (CameraAccessException e) { // ignore. } return previewSizes; }
Example #22
Source File: Camera2Helper.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラID に対応したカメラデバイスがサポートしているプレビューサイズのリストを取得します. * * @param cameraManager カメラマネージャ * @param cameraId カメラID * @return サポートしているプレビューサイズのリスト */ @NonNull static List<Size> getSupportedPreviewSizes(final CameraManager cameraManager, final String cameraId) { List<Size> previewSizes = new ArrayList<>(); try { CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map != null) { previewSizes = Arrays.asList(map.getOutputSizes(SurfaceTexture.class)); Collections.sort(previewSizes, SIZE_COMPARATOR); } } catch (CameraAccessException e) { // ignore. } return previewSizes; }
Example #23
Source File: CameraActivity.java From next18-ai-in-motion with Apache License 2.0 | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); return cameraId; } } catch (CameraAccessException e) { Log.e("CameraAccessException", "Not allowed to access camera" + e.toString()); } return null; }
Example #24
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing != cameraFacingDirection) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); Log.i(TAG, "Camera API lv2?: " + useCamera2API); return cameraId; } } catch (CameraAccessException e) { Log.e(TAG, "Not allowed to access camera: " + e); } return null; }
Example #25
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); Log.i(TAG, "Camera API lv2?: " + useCamera2API); return cameraId; } } catch (CameraAccessException e) { Log.e(TAG, "Not allowed to access camera: " + e); } return null; }
Example #26
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); Log.i(TAG, "Camera API lv2?: " + useCamera2API); return cameraId; } } catch (CameraAccessException e) { Log.e(TAG, "Not allowed to access camera: " + e); } return null; }
Example #27
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); Log.i(TAG, "Camera API lv2?: " + useCamera2API); return cameraId; } } catch (CameraAccessException e) { Log.e(TAG, "Not allowed to access camera: " + e); } return null; }
Example #28
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); Log.i(TAG, "Camera API lv2?: " + useCamera2API); return cameraId; } } catch (CameraAccessException e) { Log.e(TAG, "Not allowed to access camera: " + e); } return null; }
Example #29
Source File: CameraConfig.java From AndroidDemo with MIT License | 5 votes |
private Size calculationSize(StreamConfigurationMap map) { if (map != null) { return Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new Comparator<Size>() { @Override public int compare(Size lhs, Size rhs) { // return Long.signum((long) rhs.getWidth() * rhs.getHeight() - // (long) lhs.getWidth() * lhs.getHeight()); return Long.signum((long) lhs.getWidth() * lhs.getHeight() - (long) rhs.getWidth() * rhs.getHeight()); } }); } return null; }
Example #30
Source File: BaseCameraActivity.java From fritz-examples with MIT License | 5 votes |
private String chooseCamera() { final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); try { for (final String cameraId : manager.getCameraIdList()) { final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); // We don't use a front facing camera in this sample. final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing != cameraFacingDirection) { continue; } final StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { continue; } // Fallback to camera1 API for internal cameras that don't have full support. // This should help with legacy situations where using the camera2 API causes // distorted or otherwise broken previews. useCamera2API = (facing == CameraCharacteristics.LENS_FACING_EXTERNAL) || isHardwareLevelSupported(characteristics, CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL); Log.i(TAG, "Camera API lv2?: " + useCamera2API); return cameraId; } } catch (CameraAccessException e) { Log.e(TAG, "Not allowed to access camera: " + e); } return null; }