luicfrr / react-native-vision-camera-face-detector

Vision Camera Frame Processor Plugin to detect faces using MLKit Face Detector
https://www.npmjs.com/package/react-native-vision-camera-face-detector
MIT License
75 stars 16 forks source link

[BUG 🐛] IOS inconsistent face detection #56

Closed luicfrr closed 2 months ago

luicfrr commented 2 months ago

Describe the bug:

Faces detection are inconsistent on IOS: detections logs changes from 0 to 1 then 0 again. Sometimes 2 faces are detected but with only one person in front of device's camera.

Minimum reproducible example:

Doesn't need - I'm using example app

Expected behavior:

Face detection should be consistent

I have tryed:

https://github.com/luicfrr/react-native-vision-camera-face-detector/blob/bbfea361e97db52990080c1b0245e78d10339a6e/ios/VisionCameraFaceDetector.swift#L241

Replacing image.orientation = getFrameRotation(orientation: frame.orientation) with image.orientation = frame.orientation seems to fix the issue. (It was already fixed on 1.6.0 version).

Logs and Screenshots

running in expo dev mode (npx expo run:ios -d):

 LOG  faces 1 frame 1080 x 1920 yuv Frame
 LOG  faces 1 frame 1080 x 1920 yuv Frame
 LOG  faces 0 frame 1080 x 1920 yuv Frame
 LOG  faces 0 frame 1080 x 1920 yuv Frame
 LOG  faces 0 frame 1080 x 1920 yuv Frame
 LOG  faces 1 frame 1080 x 1920 yuv Frame
 LOG  faces 1 frame 1080 x 1920 yuv Frame
 LOG  faces 1 frame 1080 x 1920 yuv Frame
 LOG  faces 2 frame 1080 x 1920 yuv Frame
 LOG  faces 2 frame 1080 x 1920 yuv Frame
 LOG  faces 0 frame 1080 x 1920 yuv Frame
 LOG  faces 0 frame 1080 x 1920 yuv Frame
 ... they keep this exactly way floating fro 0 to 1 or 2

Device:

package.json file:

Doesn't need - I'm using example app