CameraX로 Preview와 VideoCapture를 구현하고 Mlkit 얼굴인식을 사용하고 있습니다.
analysisUseCase?.setAnalyzer(
// imageProcessor.processImageProxy will use another thread to run the detection underneath,
// thus we can just runs the analyzer itself on main thread.
ContextCompat.getMainExecutor(this.context),
ImageAnalysis.Analyzer { imageProxy: ImageProxy ->
if (needUpdateGraphicOverlayImageSourceInfo) {
Log.d(TAG,"이미지 분석")
val isImageFlipped = lensFacing == CameraSelector.LENS_FACING_FRONT
val rotationDegrees = imageProxy.imageInfo.rotationDegrees
if (rotationDegrees == 0 || rotationDegrees == 180) {
graphicOverlay!!.setImageSourceInfo(imageProxy.width, imageProxy.height, isImageFlipped)
} else {
graphicOverlay!!.setImageSourceInfo(imageProxy.height, imageProxy.width, isImageFlipped)
}
needUpdateGraphicOverlayImageSourceInfo = false
}
try {
imageProcessor!!.processImageProxy(imageProxy, graphicOverlay)
} catch (e: MlKitException) {
Log.e(TAG, "Failed to process image. Error: " + e.localizedMessage)
}
}
)
그런데 위와 같이 얼굴인식을 위해 위 코드를 추가하니 Preview화면이 회전된 상태로 보이고 녹화 후 갤러리에 저장된 영상을 보면 몇 초 밖에 촬영을 안했는데 50분 이상의 길이로 저장이 되어있습니다. 녹화된 영상에는 회전된 상태로 녹화되지는 않고 정상적인 방향으로 저장되었습니다.
어떤 부분에서 이런 오류가 발생하는지 알려주시면 감사드리겠습니다.