do not rotate the preview at front camera, always use sensor orientation

This commit is contained in:
tibbi 2018-06-11 14:10:59 +02:00
parent c0d0a06dfe
commit 8ae53e4f2f
1 changed files with 2 additions and 11 deletions

View File

@ -275,20 +275,11 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
val buffer = reader.acquireNextImage().planes.first().buffer
val bytes = ByteArray(buffer.remaining())
buffer.get(bytes)
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes)
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, mSensorOrientation, mUseFrontCamera).execute(bytes)
} catch (e: Exception) {
}
}
private fun getJPEGOrientation(): Int {
var orientation = mSensorOrientation
if (mUseFrontCamera) {
orientation += 180
}
return orientation % 360
}
private fun getCurrentResolution(): MySize {
val configMap = getCameraCharacteristics().get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
val resIndex = if (mUseFrontCamera) {
@ -562,7 +553,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
addTarget(mImageReader!!.surface)
setFlashAndExposure(this)
set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
set(CaptureRequest.JPEG_ORIENTATION, getJPEGOrientation())
set(CaptureRequest.JPEG_ORIENTATION, mSensorOrientation)
set(CaptureRequest.SCALER_CROP_REGION, mZoomRect)
set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE)
}