✨ Support Camera2 native face detection on Android
Author: mrousavyCreated Aug 25, 2026Updated Aug 25, 2026
Labels🤖 android✨ feature
Prerequisites
- I have searched existing issues for a similar request.
What problem are you trying to solve?
Android face detection currently needs ML Kit and a pixel stream even though Camera2 can return native face metadata with each capture result.
Proposed API / solution
Keep the existing ObjectOutput API:
const faces = useObjectOutput({
types: ['face'],
onObjectsScanned,
})
<Camera outputs={[faces]} {...props} />Internally, allow a metadata output to contribute session configuration without owning a CameraX UseCase. CameraX 1.7 can configure the shared session:
SessionConfig.Builder(useCases)
.camera2Interop {
setCaptureRequestOption(
CaptureRequest.STATISTICS_FACE_DETECT_MODE,
bestSupportedMode,
)
setRepeatingCaptureCallback(
executor,
object : CameraCaptureSession.CaptureCallback() {
override fun onCaptureCompleted(
session: CameraCaptureSession,
request: CaptureRequest,
result: TotalCaptureResult,
) {
emit(result[CaptureResult.STATISTICS_FACES].orEmpty())
}
},
)
}
.build()Prefer FULL, fall back to SIMPLE, and disable it when only OFF is available.
Alternatives considered
ML Kit via a FrameOutput. It is more capable, but needs another stream and app-side inference.
Platforms this should target
Android
Would you be willing to contribute this?
Yes - I'd like to open a PR.
Additional context
STATISTICS_FACE_DETECT_MODE,STATISTICS_FACES, andFace- API 21+, but support is per camera. Only
OFFis guaranteed. Android 17 performance-class 34/35/37 primary cameras must exposeSIMPLEorFULL. SIMPLEgives bounds and score.FULLadds an ID and optional eye/mouth points. Camera2 has no yaw/roll, so usefaceID = -1where unsupported and set the angle flags to false.- Bounds are sensor active-array coordinates. Normalize crop, zoom, rotation, and mirroring into VisionCamera camera-space;
PreviewView.getSensorToViewTransform()handles view mapping. - ML Kit documents about 60 ms on Pixel 3 in FAST mode. There is no comparable Camera2 latency or power figure. Avoiding ImageAnalysis, YUV delivery, and app-side inference should reduce app CPU and memory bandwidth, but needs device benchmarks.
Submission
- I described the problem, not just the solution.
- I wrote this request in my own words. I did not paste AI-generated proposals.
Source: mrousavy/react-native-vision-camera