Focusing
To focus the camera to a specific point, simply use the Camera's focus(...)
function:
await camera.current.focus({ x: tapEvent.x, y: tapEvent.y })
The focus function expects a Point
parameter which represents the location relative to the Camera view where you want to focus the Camera to (in points). If you use react-native-gesture-handler, this will consist of the x
and y
properties of the tap event payload.
So for example, { x: 0, y: 0 }
will focus to the upper left corner, while { x: VIEW_WIDTH, y: VIEW_HEIGHT }
will focus to the bottom right corner.
Focussing adjusts auto-focus (AF) and auto-exposure (AE).
note
focus(...)
will fail if the selected Camera device does not support focusing (see CameraDevice.supportsFocus
)