react-webcam not closed after component unmount in react-use-face-detection

245 Views Asked by At

I'm try to implement face recognition component using react-use-face-detection and @mediapipe library.When I unmount component react-webcam not closed successfully.How I fix that error?

const { webcamRef, boundingBox, isLoading, detected, facesDetected } = useFaceDetection({
    faceDetectionOptions : {
      model: 'short'
    },
    faceDetection: new FaceDetection.FaceDetection({
      locateFile: (file) => {
        return `/face_detection/${file}`
      },
    }),
    camera: ({ mediaSrc, onFrame, width, height }) =>
      new Camera(mediaSrc, {
        onFrame,
        width,
        height,
      }),
  });

How I fix this issue?

1

There are 1 best solutions below

0
NoNam4 On

I have rewrited this package you're using to fit some needs of my project but with this I've fixed this issue about camera not unmounting.

In this case I've removed boundingBox, isLoading, detected and facesDetected props from the return. If you doesn't need this you can try using it.

Here you can find it.