Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Fix poor CameraX resolution choice - #128

Merged
mzorz merged 5 commits into
demo1/1.0.0.10-feedbackfrom
try/fix-poor-resolution-camerax-choice
Sep 16, 2019
Merged

mzorz merged 5 commits into
demo1/1.0.0.10-feedbackfrom
try/fix-poor-resolution-camerax-choice

Conversation

@mzorz

@mzorz mzorz commented Sep 15, 2019

Copy link
Copy Markdown
Contributor

This PR fixes the following observed problems on the Samsung S8 handset with Android 9:

  • Preview screen is in low resolution
  • The aspect ratio is not correct, and objects on the screen look a bit stretched

The trick here was that we were passing a target aspect ratio to CameraX's PreviewConfig to request it to calculate it for us, but internally this would lead to a bad choice of the best available supported resolution match.
So we're now calculating the optimal size the same way we do on our Camera2 implementation, which is now added as an Utils class in CameraUtils.kt

@mzorz
mzorz requested a review from aforcier September 15, 2019 21:22
@mzorz

mzorz commented Sep 16, 2019

Copy link
Copy Markdown
Contributor Author

Going to merge and continue for the demo!

@mzorz mzorz closed this Sep 16, 2019
@mzorz
mzorz deleted the try/fix-poor-resolution-camerax-choice branch September 16, 2019 19:53
@mzorz
mzorz restored the try/fix-poor-resolution-camerax-choice branch September 16, 2019 19:53
@mzorz mzorz reopened this Sep 16, 2019
@mzorz
mzorz merged commit ac139f3 into demo1/1.0.0.10-feedback Sep 16, 2019
@mzorz
mzorz deleted the try/fix-poor-resolution-camerax-choice branch September 16, 2019 19:53
CompareSizesByArea()
)

// Danger, W.R.! Attempting to use too large a preview size could exceed the camera

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"W.R."?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 it actually comes from this line in the Camera2 sample app

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah 🤷‍♂ 👍

@aforcier aforcier added this to the Demo 2: Single Loop Creation milestone Sep 30, 2019
@aforcier aforcier self-assigned this Sep 30, 2019
@aforcier

Copy link
Copy Markdown
Collaborator

:shipit: looks good! Tested (that nothing changed) on:

Pixel 3, Android 10 (device)
Pixel 3XL, Android 8 (emulator)

@aforcier aforcier removed this from the Demo 2: Single Loop Creation milestone Oct 21, 2019
This was referenced Nov 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants