MediaPipe Hands Throws Error (Need Done ASAP)

this is my current code

const input = document.getElementById("input");

var handOpen = false;
var handXPos = window.innerWidth / 2;

function onHandResults(results) {
    if (results.multiHandLandmarks) {
        for (const landmarks of results.multiHandLandmarks) {
            const wrist = landmarks[0];
            const thumbTip = landmarks[4];
            const indexFingerTip = landmarks[8];

            if (thumbTip.y < indexFingerTip.y) {
                handOpen = true;
            } else {
                handOpen = false;
            }

            handXPos = wrist.x * window.innerWidth;

            console.log(handOpen)
        }
    }
}

const hands = new Hands({
    locateFile: (file) => {
        console.log(file)
        return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`;
    }
});

hands.setOptions({
    maxNumHands: 1,
    minDetectionConfidence: 0.5,
    minTrackingConfidence: 0.3,
});

hands.onResults(onHandResults);

const camera = new Camera(input, {
    onFrame: async () => {
        await hands.send({image: input});
    },
    width: window.innerWidth,
    height: window.innerHeight,
});

camera.start();

but it keeps returning the following error

RuntimeError: Aborted(native code called abort())
2 Likes

This error might be caused by:

  1. The external library you are using (@mediapipe/hands)
  2. Maybe the library isnt working with your browser.

If the library is the problem then maybe reach out to the maintainers of the library and ask them about it so they can fix it on their end. I have never seen this error before so I cant help you, but I hope you manage to solve your problem.