react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

✨ Add `focusCompleted` callback to `focus()`

Open sandlands opened this issue 3 years ago • 3 comments

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

sandlands avatar Dec 28 '21 12:12 sandlands

Hey! Good question, I think there is no callback to find out when focussing has been successful, but I'll take a look soon!

mrousavy avatar Dec 30 '21 09:12 mrousavy

It looks like on Android the promise is only resolved when focussing has finished. On iOS, it's immediately resolved.

sandlands avatar Jan 10 '22 15:01 sandlands

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.

nishain-de-silva avatar May 14 '23 18:05 nishain-de-silva

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.

mrousavy avatar Apr 22 '24 11:04 mrousavy