Hello.
I use 1.0.0-alpha09 version of camera-core library.
I have activity with locked orientation:
<activity
android:name=".camera.camerax.CameraActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
I use android.view.OrientationEventListener to set the target rotation (as ImageCapture.setTargetRotation method's doc proposes).
Here is how I create a capture use case:
private fun createCaptureUseCase(): ImageCapture {
return ImageCapture.Builder()
.setTargetName("Capture")
.setTargetResolution(Size(1080, 1920))
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
.build()
}
In this way I get photos with correct rotation, but with wrong resolution. If device is in natural portrait orientation then the photo resolution is 1080x1920 as expected. But if the device is rotated into landscape orientation then the resolution is 608x1080, not 1920x1080 as I exepcted to get.
I've tried to comment setTargetRotation call, photo resolution was 1080x1920 regardless of device orientation, but photo rotation wasn't correct in landscape orientations.
I've also read ImageCapture.Builder.setTargetResolution docs (particularly the next statement):
The resolution Size should be expressed at the use cases's target rotation. For example, a device with portrait natural orientation in natural target rotation requesting a portrait image may specify 480x640, and the same device, rotated 90 degrees and targeting landscape orientation may specify 640x480.
but I can't change target resolution as capture usecase is already built and bound to camera at the moment when OrientationEventListener dispatches orientation updates and ImageCapture itself has no method for setting resolution.
Am I doing something wrong or there is a bug somewhere?
Thanks in advance.