Expo Camera Facedetector crashes on android app

SDK Version: 38.0.8 Platforms(Android/iOS/web/all): Android

Expo standalone android app crashes with face detector error: Illegal argument exception: Invalid image data size

The image shows the error I get once my app crashes.

<Camera
                style={styles.camera}
                type={this.state.type}
                ratio="16:9"
                pictureSize="16:9"
                flashMode={Camera.Constants.FlashMode.auto}
                onFacesDetected={this.handleFacesDetected}
                faceDetectorSettings={{
                  mode: FaceDetector.Constants.Mode.fast,
                  detectLandmarks: FaceDetector.Constants.Landmarks.all,
                  runClassifications:
                    FaceDetector.Constants.Classifications.all,
                  tracking: true,
                }}

How can I add some kind of error catching to the onFacesDetected function in the camera module.

try this, worked for me:

state = {
ready: false
}
<Camera
style={styles.camera}
type={this.state.type}
ratio=“16:9”
pictureSize=“16:9”
flashMode={Camera.Constants.FlashMode.auto}
onFacesDetected={this.state.ready? this.handleFacesDetected: null}
faceDetectorSettings={{
mode: FaceDetector.Constants.Mode.fast,
detectLandmarks: FaceDetector.Constants.Landmarks.all,
runClassifications:
FaceDetector.Constants.Classifications.all,
tracking: true,
}}
onCameraReady={()=>{this.setState(ready: true))}}

Hey, I’m afraid it’s not working for me. Is the problem that the facedetector is running when the camera preview hasn’t been loaded yet?

In that case could we run the the facedetector when onCameraReady? Because the current logic doesn’t stop the faces being detected before the camera is ready

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.