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] android-rework part 3: Android exposure related features #3797
Merged
stuartmorgan-g
merged 13 commits into
flutter:master
from
Baseflow:camera-android/exposure_features
May 27, 2021
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2b7aa9b
Base classes to support Android camera features
mvanbeusekom f780742
Fixed formatting
mvanbeusekom 76bc5bd
Applied feedback from PR
mvanbeusekom 461309a
Added Android exposure related features
mvanbeusekom 058805b
Merge remote-tracking branch 'upstream/master' into camera-android/ex…
mvanbeusekom 7052b45
Added partial feedback from PR
mvanbeusekom 8985a9c
Merge remote-tracking branch 'upstream/master' into camera-android/ex…
mvanbeusekom 7a0b41e
Updated feedback from PR
mvanbeusekom 6a50e99
Fix formatting
mvanbeusekom a3a4ee1
Merge remote-tracking branch 'upstream/master' into camera-android/ex…
mvanbeusekom 989ecfa
Apply feedback from PR
mvanbeusekom ebae3de
Correct documentation of min and max exposure offset
mvanbeusekom 81dafb3
Fix formatting
mvanbeusekom 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
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
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 |
|---|---|---|
|
|
@@ -6,23 +6,22 @@ | |
|
|
||
| import android.hardware.camera2.CaptureRequest; | ||
| import android.util.Range; | ||
| import androidx.annotation.NonNull; | ||
| import io.flutter.plugins.camera.CameraProperties; | ||
| import io.flutter.plugins.camera.features.CameraFeature; | ||
|
|
||
| /** Exposure offset makes the image brighter or darker. */ | ||
| public class ExposureOffsetFeature extends CameraFeature<ExposureOffsetValue> { | ||
| private ExposureOffsetValue currentSetting; | ||
| private final double min; | ||
| private final double max; | ||
| /** Controls the exposure offset making the resulting image brighter or darker. */ | ||
| public class ExposureOffsetFeature extends CameraFeature<Double> { | ||
|
|
||
| private double currentSetting = 0; | ||
|
|
||
| /** | ||
| * Creates a new instance of the {@link ExposureOffsetFeature}. | ||
| * | ||
| * @param cameraProperties Collection of the characteristics for the current camera device. | ||
| */ | ||
| public ExposureOffsetFeature(CameraProperties cameraProperties) { | ||
| super(cameraProperties); | ||
|
|
||
| this.min = getMinExposureOffset(); | ||
| this.max = getMaxExposureOffset(); | ||
|
|
||
| // Initial offset of 0 | ||
| this.currentSetting = new ExposureOffsetValue(this.min, this.max, 0); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -31,14 +30,14 @@ public String getDebugName() { | |
| } | ||
|
|
||
| @Override | ||
| public ExposureOffsetValue getValue() { | ||
| public Double getValue() { | ||
| return currentSetting; | ||
| } | ||
|
|
||
| @Override | ||
| public void setValue(ExposureOffsetValue value) { | ||
| public void setValue(@NonNull Double value) { | ||
| double stepSize = getExposureOffsetStepSize(); | ||
| this.currentSetting = new ExposureOffsetValue(min, max, (value.value / stepSize)); | ||
| this.currentSetting = value / stepSize; | ||
| } | ||
|
|
||
| // Available on all devices. | ||
|
|
@@ -53,41 +52,41 @@ public void updateBuilder(CaptureRequest.Builder requestBuilder) { | |
| return; | ||
| } | ||
|
|
||
| requestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, (int) currentSetting.value); | ||
| requestBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, (int) currentSetting); | ||
| } | ||
|
|
||
| /** | ||
| * Return the minimum exposure offset double value. | ||
| * Returns the minimum exposure offset value, in counts of {@link #getExposureOffsetStepSize}. | ||
| * | ||
| * @return | ||
| * @return double Minimum exposure offset value. | ||
| */ | ||
| private double getMinExposureOffset() { | ||
| public double getMinExposureOffset() { | ||
| Range<Integer> range = cameraProperties.getControlAutoExposureCompensationRange(); | ||
| double minStepped = range == null ? 0 : range.getLower(); | ||
| double stepSize = getExposureOffsetStepSize(); | ||
| return minStepped * stepSize; | ||
| } | ||
|
|
||
| /** | ||
| * Return the max exposure offset double value. | ||
| * Returns the maximum exposure offset value, in counts of {@link #getExposureOffsetStepSize}. | ||
|
||
| * | ||
| * @return | ||
| * @return double Maximum exposure offset value. | ||
| */ | ||
| private double getMaxExposureOffset() { | ||
| public double getMaxExposureOffset() { | ||
| Range<Integer> range = cameraProperties.getControlAutoExposureCompensationRange(); | ||
| double maxStepped = range == null ? 0 : range.getUpper(); | ||
| double stepSize = getExposureOffsetStepSize(); | ||
| return maxStepped * stepSize; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the exposure offset step size. This is the smallest amount which the exposure offset | ||
| * can be changed. | ||
| * Returns the smallest step by which the exposure compensation can be changed. | ||
| * | ||
| * <p>Example: if this has a value of 0.5, then an aeExposureCompensation setting of -2 means that | ||
| * the actual AE offset is -1. | ||
| * the actual AE offset is -1. More details can be found in the official Android documentation: | ||
| * https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#CONTROL_AE_COMPENSATION_STEP | ||
| * | ||
| * @return | ||
| * @return double Smallest step by which the exposure compensation can be changed. | ||
| */ | ||
| public double getExposureOffsetStepSize() { | ||
| return cameraProperties.getControlAutoExposureCompensationStep(); | ||
|
|
||
25 changes: 0 additions & 25 deletions
25
.../src/main/java/io/flutter/plugins/camera/features/exposureoffset/ExposureOffsetValue.java
This file was deleted.
Oops, something went wrong.
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
77 changes: 0 additions & 77 deletions
77
...roid/src/main/java/io/flutter/plugins/camera/features/regionboundaries/CameraRegions.java
This file was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value is multiplied by
stepSize, so this seems wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was strongly influenced by the documentation from the Android Camera2 API when I documented this method.
Here this mention:
I am not saying this would be necessarily correct or the best, just wanted to quickly verify with you before I update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. You're pointing to the documentation for the exposure range, which is line 64 here. This method doesn't return that, it returns that multiplied by the step size (line 67). If you take step counts, and multiply by step sizes, you don't have step counts any more. You have the actual exposure value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right, I completely read the Android documentation wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed