Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Obtenga la distancia entre dos dedos en mediapipe usando javascript en relación con la posición z

Estoy tratando de detectar si la punta del pulgar y el dedo índice se han tocado. Pero no estoy seguro si estoy haciendo esto correctamente.

 const hand = result.multiHandLandmarks[0]; //Returns {x,y,z} of each landmark. //hand[4] is the tip of the thumb - Returns {x,y,z} of the tip of thumb. //hand[8] is the tip of the index finger - Returns {x,y,z} of the tip of index finger. //I don't know exactly if I am doing this right to get the distance between two tip of fingers. const x = hand[4].x - hand[8].x; const y = hand[4].y - hand[8].y; const z = hand[8].z; const distance = Math.sqrt(x * x + y * y); const element = document.getElementById("card") //--Here I want to check if the user's index and thumb finger is touching each other. //if it is, then move the element based on the position of index finger.

He intentado hacerlo de esta manera, pero parece que no es la mejor manera de hacerlo.

 //I'm not sure about 0.045, if it's enough distance to detect a touch between two finger. if (distance <= 0.045) { element.style.left = `${indexFinger.x - element.offsetWidth / 2}px`; element.style.top = `${indexFinger.y - element.offsetHeight / 2}px`; console.log("grabbing"); } else { console.log("NOT Grabbing", distance, z); }

También quiero considerar la posición Z del dedo índice, si la mano está demasiado cerca de la cámara, entonces quiero que aparezca una alerta emergente para notificar al usuario que aleje su mano en una posición perfecta. Porque creo que X e Y dependen de la posición Z. Si una mano está demasiado cerca de la cámara, x e y devuelven un número más alto.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Pruebe este concepto.

1.Obtenga las coordenadas (X1 e Y1) del primer dedo y haga lo mismo con el segundo dedo (X2 e Y2).

2.Ahora inserte los valores en este formulario.

 Distance = int(sqrt(((X2 - X1) * (X2 - X1)) + ((Y2 - Y1) * (Y2 - Y1))))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!