From 8d11dde881a9fea65eb706d3b30309a9667f79e1 Mon Sep 17 00:00:00 2001 From: Mati-AAU <74661610+Mati-AAU@users.noreply.github.com> Date: Thu, 4 May 2023 10:54:03 +0200 Subject: [PATCH] Disable white balancing --- .../pipeline/stages/input_stages/CameraXStage.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/dk/scuffed/whiteboardapp/pipeline/stages/input_stages/CameraXStage.kt b/app/src/main/java/dk/scuffed/whiteboardapp/pipeline/stages/input_stages/CameraXStage.kt index 3b8a3652..b1162f1b 100644 --- a/app/src/main/java/dk/scuffed/whiteboardapp/pipeline/stages/input_stages/CameraXStage.kt +++ b/app/src/main/java/dk/scuffed/whiteboardapp/pipeline/stages/input_stages/CameraXStage.kt @@ -1,12 +1,16 @@ package dk.scuffed.whiteboardapp.pipeline.stages.input_stages +import android.annotation.SuppressLint import android.content.Context import android.graphics.SurfaceTexture +import android.hardware.camera2.CameraMetadata +import android.hardware.camera2.CaptureRequest import android.opengl.GLES11Ext import android.opengl.GLES20 import android.os.Handler import android.util.Size import android.view.Surface +import androidx.camera.camera2.interop.Camera2Interop import androidx.camera.core.AspectRatio.RATIO_16_9 import androidx.camera.core.CameraSelector import androidx.camera.core.CameraSelector.LENS_FACING_BACK @@ -26,6 +30,7 @@ import java.util.concurrent.CompletableFuture /** * Outputs the camera onto a OpenGL framebuffer */ +@SuppressLint("UnsafeOptInUsageError") internal class CameraXStage( context: Context, pipeline: IPipeline, @@ -55,9 +60,14 @@ internal class CameraXStage( mainThreadHandler.post { run { - val preview = Preview.Builder() + val previewBuilder = Preview.Builder() .setTargetAspectRatio(RATIO_16_9) - .build() + + + val camera2InterOp = Camera2Interop.Extender(previewBuilder) + camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_SHADE) + + val preview = previewBuilder.build() preview.setSurfaceProvider { request -> val surface = Surface(cameraSurfaceTexture)