-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
[camerax] Implement focus mode configuration #120467
Comments
Hello, is there an update on this issue? My company is unable to use this plugin until the issue is resolved. |
I have just begun working on this feature; will update here when a PR is submitted for review. |
…ing focus & exposure points and offset (#5659) Wraps CameraX APIs needed to at least implement setting focus and exposure points and offset (`setFocusPoint`,`setExposurePoint`, `setExposureOffset`). Listed by class: `CameraControl` - [`startFocusAndMetering`](https://developer.android.com/reference/androidx/camera/core/CameraControl#startFocusAndMetering(androidx.camera.core.FocusMeteringAction)) - [`cancelFocusAndMetering`](https://developer.android.com/reference/androidx/camera/core/CameraControl#cancelFocusAndMetering()) - [`setExposureCompensationIndex`](https://developer.android.com/reference/androidx/camera/core/CameraControl#setExposureCompensationIndex(int)) `FocusMeteringAction` - `create` method for [this class](https://developer.android.com/reference/androidx/camera/core/FocusMeteringAction.Builder#Builder(androidx.camera.core.MeteringPoint,int)) `FocusMeteringResult` - `create` method for [this class](https://developer.android.com/reference/androidx/camera/core/FocusMeteringResult) - [`isFocusSuccessful`](https://developer.android.com/reference/kotlin/androidx/camera/core/FocusMeteringResult#isFocusSuccessful()) `MeteringPoint` - `create` method for the points that [`SurfaceOrientedMeteringPointFactory`](https://developer.android.com/reference/androidx/camera/core/SurfaceOrientedMeteringPointFactory) creates - [`getDefaultPointSize`](https://developer.android.com/reference/androidx/camera/core/MeteringPointFactory#getDefaultPointSize()) Part of flutter/flutter#120468 and flutter/flutter#120467.
Looking into how we may be able to replicate auto/locked Flutter-defined focus modes and found some helpful discussion sthat I likely will need to implement this: https://groups.google.com/a/android.com/g/camerax-developers/c/VRsER_nHeHM?pli=1, https://groups.google.com/a/android.com/g/camerax-developers/c/h0Q4Al8TXmc?pli=1 |
Working on implementing Locked mode: // When locking the auto-focus the camera device should do a one-time focus and afterwards
// set the auto-focus to idle. This is accomplished by setting the CONTROL_AF_MODE to
// CONTROL_AF_MODE_AUTO.
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
captureSession.capture(captureRequestBuilder.build(), null, backgroundHandler);
captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_IDLE);
captureSession.setRepeatingRequest(
captureRequestBuilder.build(), null, backgroundHandler); It's my understanding that this is what is going on under the hood in CameraX when we set an AF Auto mode: captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_MODE,
recordingVideo
? CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO
: CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
// Cancel existing AF state.
captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
captureSession.capture(captureRequestBuilder.build(), null, backgroundHandler);
// Set AF state to idle again.
captureRequestBuilder.set(
CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_IDLE);
captureSession.capture(captureRequestBuilder.build(), null, backgroundHandler); To implement this with CameraX, I believe we will need to remove any AF |
It turns out that CameraX always uses auto focus mode, preferring To work around this, I'm going to (1) try implementing locked focus mode with Camera2 interop, and depending on the results of that and digging deeper into the philosophy of CameraX only using autofocus mode, (2) consider the pros/cons of not implementing locked focus mode. |
I just tried using Attempt 1 (fail): Attempt 2 (success?): |
…eOffset` (#6059) This PR implements `setFocusPoint`, `setExposurePoint`, `setExposureOffset` and makes some small fixes here and there, each of which I have left a comment about for context. Part of flutter/flutter#120468 & flutter/flutter#120467. ~NOTE: Should land after #6068 done :)
Implements `setFocusMode` (also adds support for disabling auto-cancel to `FocusMeteringAction` host API implementation to accomplish this) + some minor documentation improvements based on discoveries I made while working on this :) Fixes flutter/flutter#120467. ~To be landed after: #6110 Done :)
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
In the camera plugin API, there are two methods related to the configuration of the focus mode. These should be implemented in the CameraX plugin:
setFocusMode(....)
setFocusPoint(..)
The text was updated successfully, but these errors were encountered: