react-native-vision-camera
react-native-vision-camera copied to clipboard
✨ Add `focusCompleted` callback to `focus()`
Question
In the API I see there is a focus method, which focuses the camera to a certain point. It returns a promise, but it looks like the promise is resolved before the focus procedure has finished. Is that true? Is there any way to know when focusing has finished (with a callback for example)?
It looks like the focus procedure duration is different on different phones (and probably in different scenes as well), so it would be nice to know when the lens has focused and is ready to take a (sharp) picture.
Thanks in advance!
What I tried
No response
VisionCamera Version
2.9.4
Additional information
- [X] I am using Expo
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar questions in the issues page as well as in the discussions page and found none.
Hey! Good question, I think there is no callback to find out when focussing has been successful, but I'll take a look soon!
It looks like on Android the promise is only resolved when focussing has finished. On iOS, it's immediately resolved.
Hi I checked the direct source code after some I realized that in IOS focusing occur in continuous auto focus mode so focusing is never end on IOS so it make sense why promise is resolved immediately in IOS because there is no end for focusing after all. I suppose you can capture the image after 2 - 3 seconds. But in android auto focus happens once and promise is resolved afterwards.
Hey - so the focus()
function will now only resolve once focus has happened. It can also reject/throw if focus was canelled. So this is now implemented in V4.