[camera] Limit camera preview size to take high quality picture with startImageStream#3843
[camera] Limit camera preview size to take high quality picture with startImageStream#3843comlhj1114 wants to merge 1 commit intoflutter:masterfrom
Conversation
…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.
|
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. ℹ️ Googlers: Go here for more info. |
|
@googlebot I fixed it. |
|
Thanks for the contribution!
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? |
|
@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. |
|
And I just found that this modification changes the shape of the preview not actual resolution of the preview. |
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
dart format. See plugin_tool format)[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.