This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Add iOS and Android implementations for managing auto exposure. #3346
Merged
mvanbeusekom
merged 13 commits into
flutter:master
from
Baseflow:feature/camera_exposure_auto
Dec 30, 2020
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c9f7e21
Added platform interface methods for setting auto exposure.
BeMacized 532b22f
Added platform interface methods for setting auto exposure.
BeMacized 1844b24
Remove workspace files
BeMacized fd8dd40
Added auto exposure implementations for Android and iOS
BeMacized 2b98bdd
iOS fix for setting the exposure point
BeMacized 06f436f
Removed unnecessary check
BeMacized 70804a0
Merge branch 'master' into feature/camera_exposure_auto
BeMacized 7b4445d
Merge branch 'master' into feature/camera_exposure_auto
BeMacized 14c6ab6
Update platform interface dependency
BeMacized a52f690
Implement PR feedback
BeMacized 1e6ed87
Merge branch 'master' into feature/camera_exposure_auto
BeMacized 9a88bca
Restore test
BeMacized 589f442
Small improvements for exposure point resetting
BeMacized File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/CameraRegions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package io.flutter.plugins.camera; | ||
|
|
||
| import android.hardware.camera2.params.MeteringRectangle; | ||
| import android.util.Size; | ||
|
|
||
| public final class CameraRegions { | ||
| private MeteringRectangle aeMeteringRectangle; | ||
| private Size maxBoundaries; | ||
|
|
||
| public CameraRegions(Size maxBoundaries) { | ||
| assert (maxBoundaries != null); | ||
| assert (maxBoundaries.getWidth() > 0); | ||
| assert (maxBoundaries.getHeight() > 0); | ||
| this.maxBoundaries = maxBoundaries; | ||
| setAutoExposureMeteringRectangleFromPoint(0.5, 0.5); | ||
| } | ||
|
|
||
| public MeteringRectangle getAEMeteringRectangle() { | ||
| return aeMeteringRectangle; | ||
| } | ||
|
|
||
| public Size getMaxBoundaries() { | ||
| return this.maxBoundaries; | ||
| } | ||
|
|
||
| public void setAutoExposureMeteringRectangleFromPoint(double x, double y) { | ||
| this.aeMeteringRectangle = getMeteringRectangleForPoint(maxBoundaries, x, y); | ||
| } | ||
|
|
||
| public MeteringRectangle getMeteringRectangleForPoint(Size maxBoundaries, double x, double y) { | ||
| assert (x >= 0 && x <= 1); | ||
| assert (y >= 0 && y <= 1); | ||
| assert (maxBoundaries != null); | ||
|
|
||
| // Interpolate the target coordinate | ||
| int targetX = (int) Math.round(x * ((double) (maxBoundaries.getWidth() - 1))); | ||
| int targetY = (int) Math.round(y * ((double) (maxBoundaries.getHeight() - 1))); | ||
| // Determine the dimensions of the metering triangle (10th of the viewport) | ||
| int targetWidth = (int) Math.round(((double) maxBoundaries.getWidth()) / 10d); | ||
| int targetHeight = (int) Math.round(((double) maxBoundaries.getHeight()) / 10d); | ||
| // Adjust target coordinate to represent top-left corner of metering rectangle | ||
| targetX -= targetWidth / 2; | ||
| targetY -= targetHeight / 2; | ||
| // Adjust target coordinate as to not fall out of bounds | ||
| if (targetX < 0) targetX = 0; | ||
| if (targetY < 0) targetY = 0; | ||
| int maxTargetX = maxBoundaries.getWidth() - 1 - targetWidth; | ||
| int maxTargetY = maxBoundaries.getHeight() - 1 - targetHeight; | ||
| if (targetX > maxTargetX) targetX = maxTargetX; | ||
| if (targetY > maxTargetY) targetY = maxTargetY; | ||
|
|
||
| // Build the metering rectangle | ||
| return new MeteringRectangle(targetX, targetY, targetWidth, targetHeight, 1); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.