Hi guys, my first conversation in this group. I'm pretty happy with the CameraX library and I'm hoping I'm just missing something small.
private suspend fun bindCaptureUsecase() {
val cameraProvider = ProcessCameraProvider.getInstance(requireContext()).await()
val cameraSelector = getCameraSelector(0)
val preview = Preview.Builder()
.setTargetResolution(Size(1280,720))
.setTargetRotation(Surface.ROTATION_0)
.build().apply {
setSurfaceProvider(captureViewBinding.previewView.surfaceProvider)
}
val recorder = Recorder.Builder()
.build()
videoCapture = VideoCapture.withOutput(recorder)
try {
cameraProvider.unbindAll()
val camera = cameraProvider.bindToLifecycle(viewLifecycleOwner,cameraSelector,videoCapture,preview)
if (camera.cameraInfo.hasFlashUnit()) {
Log.d(TAG, "This device DOES have torch (flash) unit.")
try {
// This doesnt even seem to work...
camera.cameraControl.enableTorch(true)
Log.d(TAG, "Torch turned on successfully (forced on by default).")
} catch(exc: CameraControl.OperationCanceledException) {
Log.e(TAG, "Turning torch on ERROR: ", exc)
}
} else {
Log.e(TAG, "This device doesn't have torch (flash) unit.")
}
} catch (exc: Exception) {
// we are on main thread, let's reset the controls on the UI.
Log.e(TAG, "Use case binding failed", exc)
resetUIandState("bindToLifecycle failed: $exc")
}
enableUI(true)
}
Currently video is recording and the quality is high and most importantly the torch is automatically turned on when the recording begins (that specific function was required for my app).
My app is in a fixed landscape orientation. I have placed the landscape orientation in the AndroidManifest of both my plugin and the root project.
The problem is the video output is in portrait rotation, despite apparently having the correct resolution.
Hopefully this is enough information & someone can assist.
Thanks.