Java Code Examples for android.hardware.camera2.CameraCharacteristics#LENS_FACING_EXTERNAL
The following examples show how to use
android.hardware.camera2.CameraCharacteristics#LENS_FACING_EXTERNAL .
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: Camera2Recorder.java From DeviceConnect-Android with MIT License | 6 votes |
/** * カメラの位置を判定する. * @return カメラの位置 */ private CameraFacing detectFacing() { try { int facing = Camera2Helper.getFacing(mCameraManager, mCameraId); switch (facing) { case CameraCharacteristics.LENS_FACING_BACK: return CameraFacing.BACK; case CameraCharacteristics.LENS_FACING_FRONT: return CameraFacing.FRONT; case CameraCharacteristics.LENS_FACING_EXTERNAL: return CameraFacing.EXTERNAL; default: return CameraFacing.UNKNOWN; } } catch (CameraAccessException e) { return CameraFacing.UNKNOWN; } }
Example 2
Source File: CameraInfo.java From MobileInfo with Apache License 2.0 | 5 votes |
private static String getFacing(Integer facing) { if (facing == null) { return UNKNOWN; } switch (facing) { case CameraCharacteristics.LENS_FACING_FRONT: return "FRONT"; case CameraCharacteristics.LENS_FACING_BACK: return "BACK"; case CameraCharacteristics.LENS_FACING_EXTERNAL: return "EXTERNAL"; default: return UNKNOWN + "-" + facing; } }
Example 3
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 4
Source File: CameraActivity.java From dbclf with Apache License 2.0 | 5 votes |
protected 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 ignored) { } return null; }
Example 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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 15
Source File: CameraUtils.java From SimpleSmsRemote with MIT License | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public static MyCameraInfo CreateFromCameraCharacteristics(String cameraId, CameraCharacteristics characteristics) { StreamConfigurationMap configMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); Size[] outputSizes = configMap.getOutputSizes(ImageFormat.JPEG); List<int[]> outputResolutions = new ArrayList<>(); for (Size outputSize : outputSizes) { outputResolutions.add(new int[]{outputSize.getWidth(), outputSize.getHeight()}); } MyCameraInfo cameraInfo = new MyCameraInfo(cameraId, outputResolutions); // supported functionality depends on the supported hardware level switch (characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)) { case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3: case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL: case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED: cameraInfo.setAutofocusSupport(true); case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY: // only supports camera 1 api features break; } int[] ints = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES); if (characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE)) cameraInfo.setFlashlightSupport(true); Integer lensFacing = characteristics.get(CameraCharacteristics.LENS_FACING); if (lensFacing != null) { if (lensFacing == CameraCharacteristics.LENS_FACING_BACK) cameraInfo.setLensFacing(LensFacing.BACK); else if (lensFacing == CameraCharacteristics.LENS_FACING_FRONT) cameraInfo.setLensFacing(LensFacing.FRONT); else if (lensFacing == CameraCharacteristics.LENS_FACING_EXTERNAL) cameraInfo.setLensFacing(LensFacing.EXTERNAL); } /* jpeg is always supported boolean isSupported = configMap.isOutputSupportedFor(0x100); */ //TODO add more info return cameraInfo; }