Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[camera] Limit camera preview size to take high quality picture with startImageStream #3843

Closed

Conversation

comlhj1114
Copy link

@comlhj1114 comlhj1114 commented May 4, 2021

This is related to the issue, flutter/flutter#46082.
This is an important issue to enable real-time image analysis and take a picture in a Flutter app.

In iOS, I tried to apply head pose estimation and taking a picture in a proper pose automatically, however, when I tried CameraController.startImageStream with ResolutionPreset.max for capture high quality picture, the app crashed unexpectedly. To resolve the problem, I should limit the resolution to ResolutionPreset.high, but in this case, generated pictures also have low resolution (which is 1280x720).

In Android, the preview resolution is limited to 1280x720 (resolutionPreset.high) in the function computeBestPreviewSize in CameraUtils.java. Like this, I can resolve the problem by limiting _previewSize in iOS. So, I propose this PR.

In the future, I recommend to set different resolution for preview and taking a picture by getting some arguments for flexibilities of the camera package.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format. See plugin_tool format)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

…ter#46082. This is an important issue to enable real-time image analysis and take a picture in a Flutter app. In my case, I tried to apply head pose estimation and taking a picture in a proper pose automatically, however, when I tried CameraController.startImageStream with ResolutionPreset.max for capture high quality picture, the app crashed unexpectedly. To resolve the problem, I should limit the resolution to ResolutionPreset.high, but in this case, generated pictures also have low resolution (which is 1280x720). In Android, the preview resolution is limited to 1280x720 (resolutionPreset.high) in the function computeBestPreviewSize in CameraUtils.java. Like this, I can resolve the problem by limiting _previewSize in iOS. So, I propose this PR. In the future, I recommend to separately set preview resolution and capture resolution by getting some arguments for flexibilities of the camera package.
@comlhj1114 comlhj1114 requested a review from bparrishMines as a code owner May 4, 2021 12:15
@google-cla
Copy link

google-cla bot commented May 4, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@comlhj1114
Copy link
Author

@googlebot I fixed it.

@google-cla google-cla bot added cla: yes and removed cla: no labels May 4, 2021
@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution!

  • All existing and new tests are passing.

This does not appear to be the case; please ensure that all tests pass. This will also need tests covering the change, per Flutter policy.

Based on discussion at #1952 (comment) it appears that the Android limit you are referring to is controversial, so it seems likely that some users would consider this change a regression. Is there a reason not to go directly to providing preview resolution control?

@comlhj1114
Copy link
Author

comlhj1114 commented May 5, 2021

@stuartmorgan Thank you for your comment. I didn't know that discussion. I totally agree with them that someone might need high resolution preview. So, like your opinion, I agree that it is better to go directly to providing preview resolution control.
I will make new PR in near future

@comlhj1114
Copy link
Author

And I just found that this modification changes the shape of the preview not actual resolution of the preview.
So, this PR is wrong.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants