MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / detectFaces

Function detectFaces

assets/js/face_detector.js:15–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15const detectFaces = async () => {
16 const prediction = await model.estimateFaces(video, false);
17 ctx.drawImage(video, 0, 0, 600, 400)
18 prediction.forEach((e) => {
19 ctx.beginPath();
20 ctx.lineWidth = "4";
21 ctx.strokeStyle = "purple"
22 ctx.rect(
23 e.topLeft[0],
24 e.topLeft[1],
25 e.bottomRight[0] - e.topLeft[0],
26 e.bottomRight[1] - e.topLeft[1]
27
28 );
29 ctx.stroke();
30 ctx.fillStyle = "#d24";
31 e.landmarks.forEach((landmark) => {
32 ctx.fillRect(landmark[0], landmark[1], 5, 5);
33 }
34 );
35 })
36}
37document.getElementById("btn").addEventListener("click", () => {
38 if (document.getElementById("btn").innerHTML == "Close Webcam") {
39 canvas.style.display = "none";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected