Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better control over camera resolution #217

Open
apalala-dev opened this issue Jan 24, 2023 · 4 comments
Open

Better control over camera resolution #217

apalala-dev opened this issue Jan 24, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@apalala-dev
Copy link
Contributor

Proposal

With the release of CamerAwesome 1.0.0, we lost the ability to know and choose the resolution we want to take pictures with.

Instead, we can set an aspect ratio that is respected both on the preview and on the image captured with the best resolution available.
Some use cases need to set a lower resolution and to know what resolution it will be.

Android side

We are now using CameraX instead of Camera2, which comes with its pros and cons.
When asking to take a picture, we can set either a target aspect ratio OR a target resolution.
The targeted aspect ratio should be respected but the target resolution can vary for several reasons:

  • the resolution doesn't exist for this camera, so it chooses a better one with a possible different aspect ratio
  • it there is no better resolution than target resolution, it will choose the closest below target resolution with a possible different aspect ratio

Having a different aspect ratio than the preview seems wrong. One solution is to scale/crop the picture taken to better match the preview but it won't have the exact same resolution as we've set in target resolution.

Additionally, getting the list of camera resolutions is not as easy as it seems since the camera used can vary depending on settings such as the zoom ratio. On a Pixel 7 Pro for instance, there are several lenses with different zoom levels and with different resolutions available. Depending on the current zoom, CameraX will take the picture with one or the other lens resulting in a varying resolution.

Here is the list of possibilities we have in mind

1. Only let users set aspect ratio (current solution)

When setting an aspect ratio, target resolution is the best possible available. It's up to the user to resize it afterwards if they need it at a lower resolution.

2. Let users set target resolution OR target aspect ratio

Similar to CameraX, the user could set either a target resolution OR an aspect ratio but not both at the same time.

When setting a target resolution, images taken might have a different resolution than the target resolution, but should be close. Aspect ratio might not be the same.

When setting an aspect ratio, target resolution would be the best possible available (like now). It's up to the user to resize it afterwards if they need it at a lower resolution.

3. Set target resolution AND aspect ratio

Let the user set a target resolution and a target aspect ratio.

a. Aspect ratio priority

Set only the target aspect ratio to CameraX to ensure we get the same aspect ratio.
Resize the image captured to match the target resolution.

b. Target resolution priority

Set only the target resolution to CameraX to ensure we get a close resolution.
Scale / crop the image captured to match the target aspect ratio.

Other possible improvement

  • Add the size of the picture taken to MediaCapture

iOS side

To be completed.

@g-apparence g-apparence added the enhancement New feature or request label Jan 25, 2023
@g-apparence g-apparence pinned this issue Jan 25, 2023
@J-apparence J-apparence unpinned this issue Mar 6, 2023
@istornz istornz pinned this issue Mar 16, 2023
@EggsAreUs
Copy link

Hi Team,
Thank you for a great plugin.
Understand about the aspect ratio/resolution dilemma but having a photo that has a degree of resolution control would be of a great benefit (to us).

Our app is looking to allow the user to take several photos manually in succession, with the camera remaining open, producing low-medium resolution images (as they need to uploaded and stored on a server with a reasonable limit on storage for each user).
Resizing large resolution images (possibly about 16x the required final size or more with no compression) is quite slow and does interfere with capturing the photos.

From our perspective, it would be useful to set/limit resolution in one dimension bringing it approximately into the ball-park of desired file-size.
Agreed that aspect ratio shouldn't actually crop part of the preview but if it makes the final image wider in one dimension, it's not too much of an issue, generally (I think), as it could be cropped later. (Perhaps the preview could be partly cropped in the narrower side for a degree of safety?).
Cropping a slightly larger image would take a fraction of the time of cropping a very large one.

Hope that I haven't missed the point entirely.

@rubenferreira97
Copy link

rubenferreira97 commented May 5, 2023

@apalala-dev
CameraX 1.3.0-alpha06 was released on April 19, 2023 and defines a new API ResolutionSelector which allows to specify aspect ratio and resolution strategies with fallback rules or a custom resolution filter to get the desired results on Android. Maybe use this new API to solve this issue?


Not related to this issue but 1.3.0-alpha06 also brings a new feature called Concurrent Camera which supports simultaneous streaming of camera devices (allows a device to have both the front and back cameras operating at the same time). CamerAwesome already has a beta multi camera support in iOS with #303 and on Android with c694074. Does c694074 uses this API?

@apalala-dev
Copy link
Contributor Author

@apalala-dev CameraX 1.3.0-alpha06 was released on April 19, 2023 and defines a new API ResolutionSelector which allows to specify aspect ratio and resolution strategies with fallback rules or a custom resolution filter to get the desired results on Android. Maybe use this new API to solve this issue?

I saw they added this along with other interesting features.
There are several things to stabilize first but that's definitively something I'd like to explore, given the opportunity.
It should come after the 2.0 release.


Not related to this issue but 1.3.0-alpha06 also brings a new feature called Concurrent Camera which supports simultaneous streaming of camera devices (allows a device to have both the front and back cameras operating at the same time). CamerAwesome already has a beta multi camera support in iOS with #303 and on Android with c694074. Does c694074 uses this API?

That's what we're using for Android 👍 It's still in beta but feel free to share any feedback on the feature :)
If you try it and find a bug, don't forget to specify on which platform. 🙏

@tomasweigenast
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants