use of android.hardware.camera2.CameraCharacteristics in project android_packages_apps_Dialer by LineageOS.
the class InCallCameraManager method maybeInitializeCameraList.
/**
* Get the list of cameras available for use.
*
* @param context The context.
*/
private void maybeInitializeCameraList(Context context) {
if (mIsInitialized || context == null) {
return;
}
Log.v(this, "initializeCameraList");
CameraManager cameraManager = null;
try {
cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
} catch (Exception e) {
Log.e(this, "Could not get camera service.");
return;
}
if (cameraManager == null) {
return;
}
String[] cameraIds = {};
try {
cameraIds = cameraManager.getCameraIdList();
} catch (CameraAccessException e) {
Log.d(this, "Could not access camera: " + e);
// Camera disabled by device policy.
return;
}
for (int i = 0; i < cameraIds.length; i++) {
CameraCharacteristics c = null;
try {
c = cameraManager.getCameraCharacteristics(cameraIds[i]);
} catch (IllegalArgumentException e) {
// Device Id is unknown.
} catch (CameraAccessException e) {
// Camera disabled by device policy.
}
if (c != null) {
int facingCharacteristic = c.get(CameraCharacteristics.LENS_FACING);
if (facingCharacteristic == CameraCharacteristics.LENS_FACING_FRONT) {
mFrontFacingCameraId = cameraIds[i];
} else if (facingCharacteristic == CameraCharacteristics.LENS_FACING_BACK) {
mRearFacingCameraId = cameraIds[i];
}
}
}
mIsInitialized = true;
Log.v(this, "initializeCameraList : done");
}
use of android.hardware.camera2.CameraCharacteristics in project android_packages_apps_Snap by LineageOS.
the class ClearSightImageProcessor method init.
public void init(StreamConfigurationMap map, int width, int height, Context context, OnMediaSavedListener mediaListener) {
Log.d(TAG, "init() start");
mIsClosing = false;
mImageProcessThread = new HandlerThread("CameraImageProcess");
mImageProcessThread.start();
mClearsightRegisterThread = new HandlerThread("ClearsightRegister");
mClearsightRegisterThread.start();
mClearsightProcessThread = new HandlerThread("ClearsightProcess");
mClearsightProcessThread.start();
mImageEncodeThread = new HandlerThread("CameraImageEncode");
mImageEncodeThread.start();
mDepthProcessThread = new HandlerThread("DepthProcess");
mDepthProcessThread.start();
mImageProcessHandler = new ImageProcessHandler(mImageProcessThread.getLooper());
mClearsightRegisterHandler = new ClearsightRegisterHandler(mClearsightRegisterThread.getLooper());
mClearsightProcessHandler = new ClearsightProcessHandler(mClearsightProcessThread.getLooper());
mImageEncodeHandler = new ImageEncodeHandler(mImageEncodeThread.getLooper());
mDepthProcessHandler = new DepthProcessHandler(mImageEncodeThread.getLooper());
mFinalPictureSize = new Size(width, height);
mFinalPictureRatio = (float) width / (float) height;
mFinalMonoSize = getFinalMonoSize();
Size maxSize = findMaxOutputSize(map);
int maxWidth = maxSize.getWidth();
int maxHeight = maxSize.getHeight();
mImageReader[CAM_TYPE_BAYER] = createImageReader(CAM_TYPE_BAYER, maxWidth, maxHeight);
mImageReader[CAM_TYPE_MONO] = createImageReader(CAM_TYPE_MONO, maxWidth, maxHeight);
mEncodeImageReader[CAM_TYPE_BAYER] = createEncodeImageReader(CAM_TYPE_BAYER, maxWidth, maxHeight);
mEncodeImageReader[CAM_TYPE_MONO] = createEncodeImageReader(CAM_TYPE_MONO, maxWidth, maxHeight);
mMediaSavedListener = mediaListener;
CameraManager cm = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
try {
CameraCharacteristics cc = cm.getCameraCharacteristics("0");
byte[] blob = cc.get(OTP_CALIB_BLOB);
CamSystemCalibrationData calibrationData = CamSystemCalibrationData.createFromBytes(blob);
ClearSightNativeEngine.getInstance().init(mNumFrameCount * 2, maxWidth, maxHeight, calibrationData);
mDepthProcessHandler.obtainMessage(MSG_CALIBRATION_DATA, 0, 0, calibrationData).sendToTarget();
} catch (CameraAccessException e) {
e.printStackTrace();
}
Log.d(TAG, "init() done");
}
use of android.hardware.camera2.CameraCharacteristics in project android_packages_apps_Dialer by MoKee.
the class InCallCameraManager method maybeInitializeCameraList.
/**
* Get the list of cameras available for use.
*
* @param context The context.
*/
private void maybeInitializeCameraList(Context context) {
if (mIsInitialized || context == null) {
return;
}
Log.v(this, "initializeCameraList");
CameraManager cameraManager = null;
try {
cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
} catch (Exception e) {
Log.e(this, "Could not get camera service.");
return;
}
if (cameraManager == null) {
return;
}
String[] cameraIds = {};
try {
cameraIds = cameraManager.getCameraIdList();
} catch (CameraAccessException e) {
Log.d(this, "Could not access camera: " + e);
// Camera disabled by device policy.
return;
}
for (int i = 0; i < cameraIds.length; i++) {
CameraCharacteristics c = null;
try {
c = cameraManager.getCameraCharacteristics(cameraIds[i]);
} catch (IllegalArgumentException e) {
// Device Id is unknown.
} catch (CameraAccessException e) {
// Camera disabled by device policy.
}
if (c != null) {
int facingCharacteristic = c.get(CameraCharacteristics.LENS_FACING);
if (facingCharacteristic == CameraCharacteristics.LENS_FACING_FRONT) {
mFrontFacingCameraId = cameraIds[i];
} else if (facingCharacteristic == CameraCharacteristics.LENS_FACING_BACK) {
mRearFacingCameraId = cameraIds[i];
}
}
}
mIsInitialized = true;
Log.v(this, "initializeCameraList : done");
}
use of android.hardware.camera2.CameraCharacteristics in project android_packages_apps_Dialer by MoKee.
the class InCallZoomController method isCameraZoomSupported.
/**
* Queries the camera characteristics to figure out if zoom is supported or not
*/
private boolean isCameraZoomSupported() {
try {
final InCallCameraManager inCallCameraManager = mInCallPresenter.getInCallCameraManager();
final float CAMERA_ZOOM_NOT_SUPPORTED = 1.0f;
CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(inCallCameraManager.getActiveCameraId());
return (characteristics != null) && (characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) > CAMERA_ZOOM_NOT_SUPPORTED);
} catch (Exception e) {
Log.e(this, "isCameraZoomSupported: Failed to retrieve Max Zoom, " + e);
return false;
}
}
use of android.hardware.camera2.CameraCharacteristics in project OpenCamera by ageback.
the class CameraControllerManager2 method isFrontFacing.
@Override
public boolean isFrontFacing(int cameraId) {
CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
try {
String cameraIdS = manager.getCameraIdList()[cameraId];
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraIdS);
return characteristics.get(CameraCharacteristics.LENS_FACING) == CameraMetadata.LENS_FACING_FRONT;
} catch (Throwable e) {
// back to old camera API.
if (MyDebug.LOG)
Log.e(TAG, "exception trying to get camera characteristics");
e.printStackTrace();
}
return false;
}
Aggregations