do not rotate the preview at front camera, always use sensor orientation
This commit is contained in:
parent
c0d0a06dfe
commit
8ae53e4f2f
|
@ -275,20 +275,11 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
||||||
val buffer = reader.acquireNextImage().planes.first().buffer
|
val buffer = reader.acquireNextImage().planes.first().buffer
|
||||||
val bytes = ByteArray(buffer.remaining())
|
val bytes = ByteArray(buffer.remaining())
|
||||||
buffer.get(bytes)
|
buffer.get(bytes)
|
||||||
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes)
|
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, mSensorOrientation, mUseFrontCamera).execute(bytes)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getJPEGOrientation(): Int {
|
|
||||||
var orientation = mSensorOrientation
|
|
||||||
if (mUseFrontCamera) {
|
|
||||||
orientation += 180
|
|
||||||
}
|
|
||||||
|
|
||||||
return orientation % 360
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCurrentResolution(): MySize {
|
private fun getCurrentResolution(): MySize {
|
||||||
val configMap = getCameraCharacteristics().get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
|
val configMap = getCameraCharacteristics().get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
|
||||||
val resIndex = if (mUseFrontCamera) {
|
val resIndex = if (mUseFrontCamera) {
|
||||||
|
@ -562,7 +553,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
||||||
addTarget(mImageReader!!.surface)
|
addTarget(mImageReader!!.surface)
|
||||||
setFlashAndExposure(this)
|
setFlashAndExposure(this)
|
||||||
set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
|
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.SCALER_CROP_REGION, mZoomRect)
|
||||||
set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE)
|
set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue