mirror of https://github.com/vladmandic/human
add hand labels in draw
parent
3de870633a
commit
4880048595
|
@ -9,7 +9,7 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
|||
|
||||
## Changelog
|
||||
|
||||
### **HEAD -> main** 2021/04/25 mandic00@live.com
|
||||
### **HEAD -> main** 2021/04/26 mandic00@live.com
|
||||
|
||||
- convert blazeface to module
|
||||
- version 1.8 release candidate
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -18713,12 +18713,24 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (localOptions.drawLabels) {
|
||||
const addHandLabel = (part, title) => {
|
||||
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * part[part.length - 1][2]}, ${127.5 - 2 * part[part.length - 1][2]}, 255, 0.5)` : localOptions.color;
|
||||
ctx.fillText(title, part[part.length - 1][0] + 4, part[part.length - 1][1] + 4);
|
||||
};
|
||||
ctx.font = localOptions.font;
|
||||
addHandLabel(h.annotations.indexFinger, "index");
|
||||
addHandLabel(h.annotations.middleFinger, "middle");
|
||||
addHandLabel(h.annotations.ringFinger, "ring");
|
||||
addHandLabel(h.annotations.pinky, "pinky");
|
||||
addHandLabel(h.annotations.thumb, "thumb");
|
||||
addHandLabel(h.annotations.palmBase, "palm");
|
||||
}
|
||||
if (localOptions.drawPolygons) {
|
||||
const addPart = (part) => {
|
||||
const addHandLine = (part) => {
|
||||
if (!part)
|
||||
return;
|
||||
for (let i = 0; i < part.length; i++) {
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * part[i][2]}, ${127.5 - 2 * part[i][2]}, 255, 0.5)` : localOptions.color;
|
||||
ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]);
|
||||
|
@ -18726,11 +18738,12 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
ctx.stroke();
|
||||
}
|
||||
};
|
||||
addPart(h.annotations.indexFinger);
|
||||
addPart(h.annotations.middleFinger);
|
||||
addPart(h.annotations.ringFinger);
|
||||
addPart(h.annotations.pinky);
|
||||
addPart(h.annotations.thumb);
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
addHandLine(h.annotations.indexFinger);
|
||||
addHandLine(h.annotations.middleFinger);
|
||||
addHandLine(h.annotations.ringFinger);
|
||||
addHandLine(h.annotations.pinky);
|
||||
addHandLine(h.annotations.thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18714,12 +18714,24 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (localOptions.drawLabels) {
|
||||
const addHandLabel = (part, title) => {
|
||||
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * part[part.length - 1][2]}, ${127.5 - 2 * part[part.length - 1][2]}, 255, 0.5)` : localOptions.color;
|
||||
ctx.fillText(title, part[part.length - 1][0] + 4, part[part.length - 1][1] + 4);
|
||||
};
|
||||
ctx.font = localOptions.font;
|
||||
addHandLabel(h.annotations.indexFinger, "index");
|
||||
addHandLabel(h.annotations.middleFinger, "middle");
|
||||
addHandLabel(h.annotations.ringFinger, "ring");
|
||||
addHandLabel(h.annotations.pinky, "pinky");
|
||||
addHandLabel(h.annotations.thumb, "thumb");
|
||||
addHandLabel(h.annotations.palmBase, "palm");
|
||||
}
|
||||
if (localOptions.drawPolygons) {
|
||||
const addPart = (part) => {
|
||||
const addHandLine = (part) => {
|
||||
if (!part)
|
||||
return;
|
||||
for (let i = 0; i < part.length; i++) {
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * part[i][2]}, ${127.5 - 2 * part[i][2]}, 255, 0.5)` : localOptions.color;
|
||||
ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]);
|
||||
|
@ -18727,11 +18739,12 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
ctx.stroke();
|
||||
}
|
||||
};
|
||||
addPart(h.annotations.indexFinger);
|
||||
addPart(h.annotations.middleFinger);
|
||||
addPart(h.annotations.ringFinger);
|
||||
addPart(h.annotations.pinky);
|
||||
addPart(h.annotations.thumb);
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
addHandLine(h.annotations.indexFinger);
|
||||
addHandLine(h.annotations.middleFinger);
|
||||
addHandLine(h.annotations.ringFinger);
|
||||
addHandLine(h.annotations.pinky);
|
||||
addHandLine(h.annotations.thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18713,12 +18713,24 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (localOptions.drawLabels) {
|
||||
const addHandLabel = (part, title) => {
|
||||
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * part[part.length - 1][2]}, ${127.5 - 2 * part[part.length - 1][2]}, 255, 0.5)` : localOptions.color;
|
||||
ctx.fillText(title, part[part.length - 1][0] + 4, part[part.length - 1][1] + 4);
|
||||
};
|
||||
ctx.font = localOptions.font;
|
||||
addHandLabel(h.annotations.indexFinger, "index");
|
||||
addHandLabel(h.annotations.middleFinger, "middle");
|
||||
addHandLabel(h.annotations.ringFinger, "ring");
|
||||
addHandLabel(h.annotations.pinky, "pinky");
|
||||
addHandLabel(h.annotations.thumb, "thumb");
|
||||
addHandLabel(h.annotations.palmBase, "palm");
|
||||
}
|
||||
if (localOptions.drawPolygons) {
|
||||
const addPart = (part) => {
|
||||
const addHandLine = (part) => {
|
||||
if (!part)
|
||||
return;
|
||||
for (let i = 0; i < part.length; i++) {
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = localOptions.useDepth ? `rgba(${127.5 + 2 * part[i][2]}, ${127.5 - 2 * part[i][2]}, 255, 0.5)` : localOptions.color;
|
||||
ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]);
|
||||
|
@ -18726,11 +18738,12 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
ctx.stroke();
|
||||
}
|
||||
};
|
||||
addPart(h.annotations.indexFinger);
|
||||
addPart(h.annotations.middleFinger);
|
||||
addPart(h.annotations.ringFinger);
|
||||
addPart(h.annotations.pinky);
|
||||
addPart(h.annotations.thumb);
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
addHandLine(h.annotations.indexFinger);
|
||||
addHandLine(h.annotations.middleFinger);
|
||||
addHandLine(h.annotations.ringFinger);
|
||||
addHandLine(h.annotations.pinky);
|
||||
addHandLine(h.annotations.thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,3 +372,20 @@
|
|||
2021-04-26 07:18:24 [36mINFO: [39m Generate types: ["src/human.ts"]
|
||||
2021-04-26 07:18:30 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||
2021-04-26 07:18:30 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
||||
2021-04-26 07:36:49 [36mINFO: [39m @vladmandic/human version 1.8.0
|
||||
2021-04-26 07:36:49 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.0.0
|
||||
2021-04-26 07:36:49 [36mINFO: [39m Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true}
|
||||
2021-04-26 07:36:49 [35mSTATE:[39m Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":696,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: node type: node: {"imports":35,"importBytes":415008,"outputBytes":374028,"outputFiles":"dist/human.node.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":700,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: nodeGPU type: node: {"imports":35,"importBytes":415012,"outputBytes":374032,"outputFiles":"dist/human.node-gpu.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":746,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: nodeWASM type: node: {"imports":35,"importBytes":415058,"outputBytes":374082,"outputFiles":"dist/human.node-wasm.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-26 07:36:50 [35mSTATE:[39m Build for: browserNoBundle type: esm: {"imports":35,"importBytes":415706,"outputBytes":230290,"outputFiles":"dist/human.esm-nobundle.js"}
|
||||
2021-04-26 07:36:51 [35mSTATE:[39m Build for: browserBundle type: tfjs: {"modules":1267,"moduleBytes":4085087,"imports":7,"importBytes":2488,"outputBytes":1101728,"outputFiles":"dist/tfjs.esm.js"}
|
||||
2021-04-26 07:36:51 [35mSTATE:[39m Build for: browserBundle type: iife: {"imports":35,"importBytes":1516040,"outputBytes":1328454,"outputFiles":"dist/human.js"}
|
||||
2021-04-26 07:36:52 [35mSTATE:[39m Build for: browserBundle type: esm: {"imports":35,"importBytes":1516040,"outputBytes":1328412,"outputFiles":"dist/human.esm.js"}
|
||||
2021-04-26 07:36:52 [36mINFO: [39m Generate types: ["src/human.ts"]
|
||||
2021-04-26 07:36:56 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||
2021-04-26 07:36:56 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
||||
|
|
|
@ -410,11 +410,23 @@ export async function hand(inCanvas: HTMLCanvasElement, result: Array<any>, draw
|
|||
}
|
||||
}
|
||||
}
|
||||
if (localOptions.drawLabels) {
|
||||
const addHandLabel = (part, title) => {
|
||||
ctx.fillStyle = localOptions.useDepth ? `rgba(${127.5 + (2 * part[part.length - 1][2])}, ${127.5 - (2 * part[part.length - 1][2])}, 255, 0.5)` : localOptions.color;
|
||||
ctx.fillText(title, part[part.length - 1][0] + 4, part[part.length - 1][1] + 4);
|
||||
};
|
||||
ctx.font = localOptions.font;
|
||||
addHandLabel(h.annotations.indexFinger, 'index');
|
||||
addHandLabel(h.annotations.middleFinger, 'middle');
|
||||
addHandLabel(h.annotations.ringFinger, 'ring');
|
||||
addHandLabel(h.annotations.pinky, 'pinky');
|
||||
addHandLabel(h.annotations.thumb, 'thumb');
|
||||
addHandLabel(h.annotations.palmBase, 'palm');
|
||||
}
|
||||
if (localOptions.drawPolygons) {
|
||||
const addPart = (part) => {
|
||||
const addHandLine = (part) => {
|
||||
if (!part) return;
|
||||
for (let i = 0; i < part.length; i++) {
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = localOptions.useDepth ? `rgba(${127.5 + (2 * part[i][2])}, ${127.5 - (2 * part[i][2])}, 255, 0.5)` : localOptions.color;
|
||||
ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]);
|
||||
|
@ -422,12 +434,13 @@ export async function hand(inCanvas: HTMLCanvasElement, result: Array<any>, draw
|
|||
ctx.stroke();
|
||||
}
|
||||
};
|
||||
addPart(h.annotations.indexFinger);
|
||||
addPart(h.annotations.middleFinger);
|
||||
addPart(h.annotations.ringFinger);
|
||||
addPart(h.annotations.pinky);
|
||||
addPart(h.annotations.thumb);
|
||||
// addPart(hand.annotations.palmBase);
|
||||
ctx.lineWidth = localOptions.lineWidth;
|
||||
addHandLine(h.annotations.indexFinger);
|
||||
addHandLine(h.annotations.middleFinger);
|
||||
addHandLine(h.annotations.ringFinger);
|
||||
addHandLine(h.annotations.pinky);
|
||||
addHandLine(h.annotations.thumb);
|
||||
// addPart(h.annotations.palmBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue