Hi Christian,
Thanks for the question. The supported sizes retrieved from StreamConfigurationMap might be in different directions against the device's orientation. Those sizes need to be calibrated to the app's coordinate frame by the sensor orientation (retrieved from CameraCharacteristics with CameraCharacteristics.SENSOR_ORIENTATION). This is usually too complex to some camera app developers who are not so familiar with such kinds of details. Therefore, current CameraX's setTargetResolution API design ask the developers to input the resolution, which is in the coordinate frame after rotating the supported sizes by the target rotation. By this approach, developers don't need to know the sensor orientation information and related knowledge. CameraX will internally calibrate the size according to the sensor orientation. The related information has been included in the javadocs of each use case builder's setTargetResolution API. Please refer to the following description extracted from
ImageCapture.Builder#setTargetResolution():
"The resolution Size should be expressed in the coordinate frame after rotating the supported sizes by the 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."
Therefore, when you select a target resolution from the supported output sizes of StreamConfigurationMap, you will also need to retrieve the sensor orientation value and calibrate the target resolution into your app's coordinate frame.