Hi, I have been trying to follow the mediapipe documentation and associated tutorial to check if the handpose estimation is working. I seem to get into the following error . I am unable to understand what is the reason for the error ? I am trying to run the script in p5jsweb editor
Is it that the webgl backend is not setup in time ?
The link to the API is as follows : Media Pipe Hand Js API.
Error log
RuntimeError: abort(undefined) at Error
at jsStackTrace (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:69361)
at stackTrace (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:69537)
at abort (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:43094)
at _abort (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:180746)
at https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[7269]:0x4ff31e
at https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[7267]:0x4ff1c3
at https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[7271]:0x4ff337
at https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[222]:0x19c2c
at https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[192]:0x14cd2
at SolutionWasm$send [as send] (eval at new_ (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:161520), <anonymous>:9:1)
at jsStackTrace (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:69361)
at stackTrace (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:69537)
at abort (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:43094)
at _abort (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.js:9:180746)
at (anonymous function) (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[7269]:0x4ff31e)
at (anonymous function) (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[7267]:0x4ff1c3)
at (anonymous function) (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[7271]:0x4ff337)
at (anonymous function) (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[222]:0x19c2c)
at (anonymous function) (https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands_solution_simd_wasm_bin.wasm:wasm-function[192]:0x14cd2)
at SolutionWasm$send [as send]
I have four files index.html, sketch.js, detection.js. style.css
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/control_utils/control_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/p5.js"></script>
<script defer language="javascript" type="text/javascript" src="detection.js"></script>
<script defer language="javascript" type="text/javascript" src="sketch.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<video id="video" width="640" height="480"></video>
</body>
</html>
<body>
<div class="container">
<video class="input_video"></video>
<canvas class="output_canvas" width="640px" height="480px"></canvas>
</div>
</body>
</html>
sketch.js
let canvas;
let sketch = function(p){
p.setup = function(){
canvas = p.createCanvas(640, 480);
canvas.id("canvas");
p.colorMode(p.HSB);
}
p.draw = function(){
p.clear();
if(detections != undefined){
if(detections.multiHandLandmarks != undefined){
//p.drawHands();
// p.drawParts();
p.drawLines([0, 5, 9, 13, 17, 0]);//palm
p.drawLines([0, 1, 2, 3 ,4]);//thumb
p.drawLines([5, 6, 7, 8]);//index finger
p.drawLines([9, 10, 11, 12]);//middle finger
p.drawLines([13, 14, 15, 16]);//ring finger
p.drawLines([17, 18, 19, 20]);//pinky
p.drawLandmarks([0, 1], 0);//palm base
p.drawLandmarks([1, 5], 60);//thumb
p.drawLandmarks([5, 9], 120);//index finger
p.drawLandmarks([9, 13], 180);//middle finger
p.drawLandmarks([13, 17], 240);//ring finger
p.drawLandmarks([17, 21], 300);//pinky
}
}
}
p.drawHands = function(){
for(let i=0; i<detections.multiHandLandmarks.length; i++){
for(let j=0; j<detections.multiHandLandmarks[i].length; j++){
let x = detections.multiHandLandmarks[i][j].x * p.width;
let y = detections.multiHandLandmarks[i][j].y * p.height;
let z = detections.multiHandLandmarks[i][j].z;
// p.strokeWeight(0);
// p.textFont('Helvetica Neue');
// p.text(j, x, y);
p.stroke(255);
p.strokeWeight(10);
p.point(x, y);
}
}
}
p.drawLandmarks = function(indexArray, hue){
p.noFill();
p.strokeWeight(8);
for(let i=0; i<detections.multiHandLandmarks.length; i++){
for(let j=indexArray[0]; j<indexArray[1]; j++){
let x = detections.multiHandLandmarks[i][j].x * p.width;
let y = detections.multiHandLandmarks[i][j].y * p.height;
// let z = detections.multiHandLandmarks[i][j].z;
p.stroke(hue, 40, 255);
p.point(x, y);
}
}
}
p.drawLines = function(index){
p.stroke(0, 0, 255);
p.strokeWeight(3);
for(let i=0; i<detections.multiHandLandmarks.length; i++){
for(let j=0; j<index.length-1; j++){
let x = detections.multiHandLandmarks[i][index[j]].x * p.width;
let y = detections.multiHandLandmarks[i][index[j]].y * p.height;
// let z = detections.multiHandLandmarks[i][index[j]].z;
let _x = detections.multiHandLandmarks[i][index[j+1]].x * p.width;
let _y = detections.multiHandLandmarks[i][index[j+1]].y * p.height;
// let _z = detections.multiHandLandmarks[i][index[j+1]].z;
p.line(x, y, _x, _y);
}
}
}
}
let myp5 = new p5(sketch);
detection.js
let detections = {};
const videoElement = document.getElementById('video');
const hands = new Hands({locateFile: (file) => {
return `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`;
}});
hands.setOptions({
maxNumHands: 4,
minDetectionConfidence: 0.8,
minTrackingConfidence: 0.5
});
hands.onResults(gotHands);
function gotHands(results) {
detections = results;
console.log(detections);
}
const camera = new Camera(videoElement, {
onFrame: async () => {
await hands.send({image: videoElement});
},
width: 640,
height: 480
});
camera.start(); ```