Hi,
I guess flipping the target resolution (new Size(720, 1200)) can resolve the problem. When using the legacy setTargetResolution() API, you might need to flip the size according to the target rotation value. Please see the following javadoc:
- 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.
To avoid the same problem as this, we have introduced a new
ResolutionSelector API and deprecated the original setTargetResolution and setTargetAspectRatio API. All settings for the new
ResolutionSelector API refer to the sizes in the camera sensor coordinate which are exactly the same as what retrieved by StreamConfigurationMap#getOutputSizes() or the size that the ImageAnalysis's Analyzer will receive. It can also provide more settings to select the best resolution for your requirements. If possible, please have a try to the new
ResolutionSelector API. The code might look like the following:
ImageAnalysis imageAnalysis = new ImageAnalysis.Builder()
.setResolutionSelector(
new ResolutionSelector.Builder()
.setResolutionStrategy(
new ResolutionStrategy(new Size(1200, 720), ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER)
).build())
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888)
.setTargetRotation(rotation)
.build();