From 60796a9117110279bbd9450fa12a6784f646a322 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 30 Oct 2020 07:32:35 -0400 Subject: [PATCH] improve demo line continous draws --- demo/draw.js | 16 +++++++++++----- dist/human.esm-nobundle.js | 2 +- dist/human.esm-nobundle.json | 6 +++--- dist/human.esm.js | 2 +- dist/human.esm.json | 6 +++--- dist/human.js | 2 +- dist/human.json | 6 +++--- dist/human.node-nobundle.js | 2 +- dist/human.node.js | 2 +- dist/human.node.json | 6 +++--- package.json | 2 +- 11 files changed, 29 insertions(+), 23 deletions(-) diff --git a/demo/draw.js b/demo/draw.js index f63dc697..fa491197 100644 --- a/demo/draw.js +++ b/demo/draw.js @@ -57,6 +57,7 @@ async function drawFace(result, canvas, ui, triangulation) { async function drawBody(result, canvas, ui) { if (!result) return; const ctx = canvas.getContext('2d'); + ctx.lineJoin = 'round'; for (const pose of result) { ctx.fillStyle = ui.baseColor; ctx.strokeStyle = ui.baseColor; @@ -97,15 +98,19 @@ async function drawBody(result, canvas, ui) { part = pose.keypoints.find((a) => a.part === 'rightAnkle'); path.lineTo(part.position.x, part.position.y); // arms - part = pose.keypoints.find((a) => a.part === 'leftShoulder'); + part = pose.keypoints.find((a) => a.part === 'rightShoulder'); path.moveTo(part.position.x, part.position.y); + part = pose.keypoints.find((a) => a.part === 'leftShoulder'); + path.lineTo(part.position.x, part.position.y); part = pose.keypoints.find((a) => a.part === 'leftElbow'); path.lineTo(part.position.x, part.position.y); part = pose.keypoints.find((a) => a.part === 'leftWrist'); path.lineTo(part.position.x, part.position.y); // arms - part = pose.keypoints.find((a) => a.part === 'rightShoulder'); + part = pose.keypoints.find((a) => a.part === 'leftShoulder'); path.moveTo(part.position.x, part.position.y); + part = pose.keypoints.find((a) => a.part === 'rightShoulder'); + path.lineTo(part.position.x, part.position.y); part = pose.keypoints.find((a) => a.part === 'rightElbow'); path.lineTo(part.position.x, part.position.y); part = pose.keypoints.find((a) => a.part === 'rightWrist'); @@ -119,6 +124,7 @@ async function drawBody(result, canvas, ui) { async function drawHand(result, canvas, ui) { if (!result) return; const ctx = canvas.getContext('2d'); + ctx.lineJoin = 'round'; for (const hand of result) { ctx.font = ui.baseFont; ctx.lineWidth = ui.baseLineWidth; @@ -142,11 +148,11 @@ async function drawHand(result, canvas, ui) { } if (ui.drawPolygons) { const addPart = (part) => { - for (let i = 1; i < part.length; i++) { + for (let i = 0; i < part.length; i++) { ctx.lineWidth = ui.baseLineWidth; ctx.beginPath(); ctx.strokeStyle = ui.useDepth ? `rgba(${127.5 + (2 * part[i][2])}, ${127.5 - (2 * part[i][2])}, 255, 0.5)` : ui.baseColor; - ctx.moveTo(part[i - 1][0], part[i - 1][1]); + ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]); ctx.lineTo(part[i][0], part[i][1]); ctx.stroke(); } @@ -156,7 +162,7 @@ async function drawHand(result, canvas, ui) { addPart(hand.annotations.ringFinger); addPart(hand.annotations.pinky); addPart(hand.annotations.thumb); - addPart(hand.annotations.palmBase); + // addPart(hand.annotations.palmBase); } } } diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index a17ec2bb..2f497ae5 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -5777,7 +5777,7 @@ var require_config = __commonJS((exports) => { var require_package = __commonJS((exports, module) => { module.exports = { name: "@vladmandic/human", - version: "0.4.9", + version: "0.4.10", description: "human: 3D Face Detection, Iris Tracking and Age & Gender Prediction", sideEffects: false, main: "dist/human.node.js", diff --git a/dist/human.esm-nobundle.json b/dist/human.esm-nobundle.json index 1c337331..d28afba0 100644 --- a/dist/human.esm-nobundle.json +++ b/dist/human.esm-nobundle.json @@ -5,7 +5,7 @@ "imports": [] }, "package.json": { - "bytes": 2870, + "bytes": 2871, "imports": [] }, "src/emotion/emotion.js": { @@ -353,7 +353,7 @@ "bytesInOutput": 2230 }, "package.json": { - "bytesInOutput": 3012 + "bytesInOutput": 3013 }, "src/human.js": { "bytesInOutput": 10775 @@ -362,7 +362,7 @@ "bytesInOutput": 0 } }, - "bytes": 155238 + "bytes": 155239 } } } diff --git a/dist/human.esm.js b/dist/human.esm.js index 1de8ff7a..346b7ac0 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -72826,7 +72826,7 @@ var require_config = __commonJS((exports) => { var require_package = __commonJS((exports, module) => { module.exports = { name: "@vladmandic/human", - version: "0.4.9", + version: "0.4.10", description: "human: 3D Face Detection, Iris Tracking and Age & Gender Prediction", sideEffects: false, main: "dist/human.node.js", diff --git a/dist/human.esm.json b/dist/human.esm.json index bd745a24..eedfb679 100644 --- a/dist/human.esm.json +++ b/dist/human.esm.json @@ -149,7 +149,7 @@ ] }, "package.json": { - "bytes": 2870, + "bytes": 2871, "imports": [] }, "src/emotion/emotion.js": { @@ -618,7 +618,7 @@ "bytesInOutput": 2230 }, "package.json": { - "bytesInOutput": 3012 + "bytesInOutput": 3013 }, "src/human.js": { "bytesInOutput": 10765 @@ -627,7 +627,7 @@ "bytesInOutput": 0 } }, - "bytes": 2924202 + "bytes": 2924203 } } } diff --git a/dist/human.js b/dist/human.js index 1ab93638..a0f24129 100644 --- a/dist/human.js +++ b/dist/human.js @@ -72827,7 +72827,7 @@ var Human = (() => { var require_package = __commonJS((exports, module) => { module.exports = { name: "@vladmandic/human", - version: "0.4.9", + version: "0.4.10", description: "human: 3D Face Detection, Iris Tracking and Age & Gender Prediction", sideEffects: false, main: "dist/human.node.js", diff --git a/dist/human.json b/dist/human.json index b0db85d9..32a57172 100644 --- a/dist/human.json +++ b/dist/human.json @@ -149,7 +149,7 @@ ] }, "package.json": { - "bytes": 2870, + "bytes": 2871, "imports": [] }, "src/emotion/emotion.js": { @@ -618,13 +618,13 @@ "bytesInOutput": 2424 }, "package.json": { - "bytesInOutput": 3144 + "bytesInOutput": 3145 }, "src/human.js": { "bytesInOutput": 11994 } }, - "bytes": 3070079 + "bytes": 3070080 } } } diff --git a/dist/human.node-nobundle.js b/dist/human.node-nobundle.js index 54296be8..f7dca613 100644 --- a/dist/human.node-nobundle.js +++ b/dist/human.node-nobundle.js @@ -5777,7 +5777,7 @@ var require_config = __commonJS((exports2) => { var require_package = __commonJS((exports2, module2) => { module2.exports = { name: "@vladmandic/human", - version: "0.4.9", + version: "0.4.10", description: "human: 3D Face Detection, Iris Tracking and Age & Gender Prediction", sideEffects: false, main: "dist/human.node.js", diff --git a/dist/human.node.js b/dist/human.node.js index 6096b2b4..c89af575 100644 --- a/dist/human.node.js +++ b/dist/human.node.js @@ -73868,7 +73868,7 @@ var require_config = __commonJS((exports2) => { var require_package = __commonJS((exports2, module2) => { module2.exports = { name: "@vladmandic/human", - version: "0.4.9", + version: "0.4.10", description: "human: 3D Face Detection, Iris Tracking and Age & Gender Prediction", sideEffects: false, main: "dist/human.node.js", diff --git a/dist/human.node.json b/dist/human.node.json index 3ca58be3..32d3ceb4 100644 --- a/dist/human.node.json +++ b/dist/human.node.json @@ -5,7 +5,7 @@ "imports": [] }, "package.json": { - "bytes": 2870, + "bytes": 2871, "imports": [] }, "src/emotion/emotion.js": { @@ -353,7 +353,7 @@ "bytesInOutput": 2232 }, "package.json": { - "bytesInOutput": 3015 + "bytesInOutput": 3016 }, "src/human.js": { "bytesInOutput": 47 @@ -362,7 +362,7 @@ "bytesInOutput": 10775 } }, - "bytes": 155392 + "bytes": 155393 } } } diff --git a/package.json b/package.json index b6c65efd..815d23d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vladmandic/human", - "version": "0.4.10", + "version": "0.5.0", "description": "human: 3D Face Detection, Iris Tracking and Age & Gender Prediction", "sideEffects": false, "main": "dist/human.node.js",