fix for human.draw labels and typedefs

pull/233/head
Vladimir Mandic 2021-10-21 10:54:51 -04:00
parent d4188518db
commit 669e6e7c00
32 changed files with 629 additions and 3215 deletions

View File

@ -9,8 +9,9 @@
## Changelog ## Changelog
### **HEAD -> main** 2021/10/19 mandic00@live.com ### **HEAD -> main** 2021/10/21 mandic00@live.com
- add human.custom.esm using custom tfjs build
### **2.3.5** 2021/10/19 mandic00@live.com ### **2.3.5** 2021/10/19 mandic00@live.com

View File

@ -63,6 +63,7 @@ const drawOptions = {
drawBoxes: true, drawBoxes: true,
drawGaze: true, drawGaze: true,
drawLabels: true, drawLabels: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawPoints: false, drawPoints: false,
fillPolygons: false, fillPolygons: false,

View File

@ -80930,6 +80930,7 @@ var options2 = {
drawPoints: false, drawPoints: false,
drawLabels: true, drawLabels: true,
drawBoxes: true, drawBoxes: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawGaze: true, drawGaze: true,
fillPolygons: false, fillPolygons: false,
@ -81034,24 +81035,26 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions); const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2) if (!result || !inCanvas2)
return; return;
const ctx = getCanvasContext(inCanvas2); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas2);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where2 = []; for (let j = 0; j < result.length; j++) {
let what = []; let where2 = [];
[where2, what] = Object.entries(result[j]); let what = [];
if (what.length > 1 && what[1].length > 0) { [where2, what] = Object.entries(result[j]);
const who = where2[1] > 0 ? `#${where2[1]}` : ""; if (what.length > 1 && what[1].length > 0) {
const label = `${where2[0]} ${who}: ${what[1]}`; const who = where2[1] > 0 ? `#${where2[1]}` : "";
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const label = `${where2[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
} }
} }
@ -81067,40 +81070,42 @@ async function face(inCanvas2, result, drawOptions) {
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) if (localOptions.drawBoxes)
rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
const labels2 = []; if (localOptions.drawLabels) {
labels2.push(`face: ${Math.trunc(100 * f.score)}%`); const labels2 = [];
if (f.genderScore) labels2.push(`face: ${Math.trunc(100 * f.score)}%`);
labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`); if (f.genderScore)
if (f.age) labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`);
labels2.push(`age: ${f.age || ""}`); if (f.age)
if (f.iris) labels2.push(`age: ${f.age || ""}`);
labels2.push(`distance: ${f.iris}`); if (f.iris)
if (f.real) labels2.push(`distance: ${f.iris}`);
labels2.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.real)
if (f.emotion && f.emotion.length > 0) { labels2.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion3.length > 3) const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
emotion3.length = 3; if (emotion3.length > 3)
labels2.push(emotion3.join(" ")); emotion3.length = 3;
} labels2.push(emotion3.join(" "));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) if (f.rotation && f.rotation.angle && f.rotation.gaze) {
labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`); if (f.rotation.angle.roll)
if (f.rotation.gaze.bearing) labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`);
labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`); if (f.rotation.gaze.bearing)
} labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`);
if (labels2.length === 0) }
labels2.push("face"); if (labels2.length === 0)
ctx.fillStyle = localOptions.color; labels2.push("face");
for (let i = labels2.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels2.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(labels2[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels2[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {
@ -81500,31 +81505,31 @@ var detectFace = async (parent, input2) => {
const rotation = calculateFaceAngle(faces[i], [input2.shape[2], input2.shape[1]]); const rotation = calculateFaceAngle(faces[i], [input2.shape[2], input2.shape[1]]);
parent.analyze("Start Emotion:"); parent.analyze("Start Emotion:");
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:emotion"; parent.state = "run:emotion";
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Emotion:"); parent.analyze("End Emotion:");
parent.analyze("Start AntiSpoof:"); parent.analyze("Start AntiSpoof:");
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:antispoof"; parent.state = "run:antispoof";
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze("End AntiSpoof:"); parent.analyze("End AntiSpoof:");
parent.analyze("Start Description:"); parent.analyze("Start Description:");
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:description"; parent.state = "run:description";
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Description:"); parent.analyze("End Description:");
@ -81544,10 +81549,10 @@ var detectFace = async (parent, input2) => {
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes == null ? void 0 : descRes.age,
gender: descRes.gender, gender: descRes == null ? void 0 : descRes.gender,
genderScore: descRes.genderScore, genderScore: descRes == null ? void 0 : descRes.genderScore,
embedding: descRes.descriptor, embedding: descRes == null ? void 0 : descRes.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

File diff suppressed because one or more lines are too long

View File

@ -10878,6 +10878,7 @@ var options2 = {
drawPoints: false, drawPoints: false,
drawLabels: true, drawLabels: true,
drawBoxes: true, drawBoxes: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawGaze: true, drawGaze: true,
fillPolygons: false, fillPolygons: false,
@ -10982,24 +10983,26 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions); const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2) if (!result || !inCanvas2)
return; return;
const ctx = getCanvasContext(inCanvas2); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas2);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where = []; for (let j = 0; j < result.length; j++) {
let what = []; let where = [];
[where, what] = Object.entries(result[j]); let what = [];
if (what.length > 1 && what[1].length > 0) { [where, what] = Object.entries(result[j]);
const who = where[1] > 0 ? `#${where[1]}` : ""; if (what.length > 1 && what[1].length > 0) {
const label = `${where[0]} ${who}: ${what[1]}`; const who = where[1] > 0 ? `#${where[1]}` : "";
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const label = `${where[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
} }
} }
@ -11015,40 +11018,42 @@ async function face(inCanvas2, result, drawOptions) {
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) if (localOptions.drawBoxes)
rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
const labels2 = []; if (localOptions.drawLabels) {
labels2.push(`face: ${Math.trunc(100 * f.score)}%`); const labels2 = [];
if (f.genderScore) labels2.push(`face: ${Math.trunc(100 * f.score)}%`);
labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`); if (f.genderScore)
if (f.age) labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`);
labels2.push(`age: ${f.age || ""}`); if (f.age)
if (f.iris) labels2.push(`age: ${f.age || ""}`);
labels2.push(`distance: ${f.iris}`); if (f.iris)
if (f.real) labels2.push(`distance: ${f.iris}`);
labels2.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.real)
if (f.emotion && f.emotion.length > 0) { labels2.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion3.length > 3) const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
emotion3.length = 3; if (emotion3.length > 3)
labels2.push(emotion3.join(" ")); emotion3.length = 3;
} labels2.push(emotion3.join(" "));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) if (f.rotation && f.rotation.angle && f.rotation.gaze) {
labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`); if (f.rotation.angle.roll)
if (f.rotation.gaze.bearing) labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`);
labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`); if (f.rotation.gaze.bearing)
} labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`);
if (labels2.length === 0) }
labels2.push("face"); if (labels2.length === 0)
ctx.fillStyle = localOptions.color; labels2.push("face");
for (let i = labels2.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels2.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(labels2[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels2[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {
@ -11448,31 +11453,31 @@ var detectFace = async (parent, input) => {
const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]); const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]);
parent.analyze("Start Emotion:"); parent.analyze("Start Emotion:");
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:emotion"; parent.state = "run:emotion";
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Emotion:"); parent.analyze("End Emotion:");
parent.analyze("Start AntiSpoof:"); parent.analyze("Start AntiSpoof:");
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:antispoof"; parent.state = "run:antispoof";
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze("End AntiSpoof:"); parent.analyze("End AntiSpoof:");
parent.analyze("Start Description:"); parent.analyze("Start Description:");
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:description"; parent.state = "run:description";
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tfjs_esm_exports.tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Description:"); parent.analyze("End Description:");
@ -11492,10 +11497,10 @@ var detectFace = async (parent, input) => {
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes == null ? void 0 : descRes.age,
gender: descRes.gender, gender: descRes == null ? void 0 : descRes.gender,
genderScore: descRes.genderScore, genderScore: descRes == null ? void 0 : descRes.genderScore,
embedding: descRes.descriptor, embedding: descRes == null ? void 0 : descRes.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

File diff suppressed because one or more lines are too long

125
dist/human.esm.js vendored
View File

@ -78360,6 +78360,7 @@ var options2 = {
drawPoints: false, drawPoints: false,
drawLabels: true, drawLabels: true,
drawBoxes: true, drawBoxes: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawGaze: true, drawGaze: true,
fillPolygons: false, fillPolygons: false,
@ -78464,24 +78465,26 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions); const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2) if (!result || !inCanvas2)
return; return;
const ctx = getCanvasContext(inCanvas2); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas2);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where2 = []; for (let j = 0; j < result.length; j++) {
let what = []; let where2 = [];
[where2, what] = Object.entries(result[j]); let what = [];
if (what.length > 1 && what[1].length > 0) { [where2, what] = Object.entries(result[j]);
const who = where2[1] > 0 ? `#${where2[1]}` : ""; if (what.length > 1 && what[1].length > 0) {
const label = `${where2[0]} ${who}: ${what[1]}`; const who = where2[1] > 0 ? `#${where2[1]}` : "";
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const label = `${where2[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
} }
} }
@ -78497,40 +78500,42 @@ async function face(inCanvas2, result, drawOptions) {
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) if (localOptions.drawBoxes)
rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
const labels2 = []; if (localOptions.drawLabels) {
labels2.push(`face: ${Math.trunc(100 * f.score)}%`); const labels2 = [];
if (f.genderScore) labels2.push(`face: ${Math.trunc(100 * f.score)}%`);
labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`); if (f.genderScore)
if (f.age) labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`);
labels2.push(`age: ${f.age || ""}`); if (f.age)
if (f.iris) labels2.push(`age: ${f.age || ""}`);
labels2.push(`distance: ${f.iris}`); if (f.iris)
if (f.real) labels2.push(`distance: ${f.iris}`);
labels2.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.real)
if (f.emotion && f.emotion.length > 0) { labels2.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion3.length > 3) const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
emotion3.length = 3; if (emotion3.length > 3)
labels2.push(emotion3.join(" ")); emotion3.length = 3;
} labels2.push(emotion3.join(" "));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) if (f.rotation && f.rotation.angle && f.rotation.gaze) {
labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`); if (f.rotation.angle.roll)
if (f.rotation.gaze.bearing) labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`);
labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`); if (f.rotation.gaze.bearing)
} labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`);
if (labels2.length === 0) }
labels2.push("face"); if (labels2.length === 0)
ctx.fillStyle = localOptions.color; labels2.push("face");
for (let i = labels2.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels2.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(labels2[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels2[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {
@ -78930,31 +78935,31 @@ var detectFace = async (parent, input2) => {
const rotation = calculateFaceAngle(faces[i], [input2.shape[2], input2.shape[1]]); const rotation = calculateFaceAngle(faces[i], [input2.shape[2], input2.shape[1]]);
parent.analyze("Start Emotion:"); parent.analyze("Start Emotion:");
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:emotion"; parent.state = "run:emotion";
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Emotion:"); parent.analyze("End Emotion:");
parent.analyze("Start AntiSpoof:"); parent.analyze("Start AntiSpoof:");
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:antispoof"; parent.state = "run:antispoof";
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze("End AntiSpoof:"); parent.analyze("End AntiSpoof:");
parent.analyze("Start Description:"); parent.analyze("Start Description:");
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:description"; parent.state = "run:description";
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Description:"); parent.analyze("End Description:");
@ -78974,10 +78979,10 @@ var detectFace = async (parent, input2) => {
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes == null ? void 0 : descRes.age,
gender: descRes.gender, gender: descRes == null ? void 0 : descRes.gender,
genderScore: descRes.genderScore, genderScore: descRes == null ? void 0 : descRes.genderScore,
embedding: descRes.descriptor, embedding: descRes == null ? void 0 : descRes.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

File diff suppressed because one or more lines are too long

14
dist/human.js vendored

File diff suppressed because one or more lines are too long

125
dist/human.node-gpu.js vendored
View File

@ -10937,6 +10937,7 @@ var options2 = {
drawPoints: false, drawPoints: false,
drawLabels: true, drawLabels: true,
drawBoxes: true, drawBoxes: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawGaze: true, drawGaze: true,
fillPolygons: false, fillPolygons: false,
@ -11041,24 +11042,26 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions); const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2) if (!result || !inCanvas2)
return; return;
const ctx = getCanvasContext(inCanvas2); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas2);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where = []; for (let j = 0; j < result.length; j++) {
let what = []; let where = [];
[where, what] = Object.entries(result[j]); let what = [];
if (what.length > 1 && what[1].length > 0) { [where, what] = Object.entries(result[j]);
const who = where[1] > 0 ? `#${where[1]}` : ""; if (what.length > 1 && what[1].length > 0) {
const label = `${where[0]} ${who}: ${what[1]}`; const who = where[1] > 0 ? `#${where[1]}` : "";
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const label = `${where[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
} }
} }
@ -11074,40 +11077,42 @@ async function face(inCanvas2, result, drawOptions) {
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) if (localOptions.drawBoxes)
rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
const labels2 = []; if (localOptions.drawLabels) {
labels2.push(`face: ${Math.trunc(100 * f.score)}%`); const labels2 = [];
if (f.genderScore) labels2.push(`face: ${Math.trunc(100 * f.score)}%`);
labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`); if (f.genderScore)
if (f.age) labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`);
labels2.push(`age: ${f.age || ""}`); if (f.age)
if (f.iris) labels2.push(`age: ${f.age || ""}`);
labels2.push(`distance: ${f.iris}`); if (f.iris)
if (f.real) labels2.push(`distance: ${f.iris}`);
labels2.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.real)
if (f.emotion && f.emotion.length > 0) { labels2.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion3.length > 3) const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
emotion3.length = 3; if (emotion3.length > 3)
labels2.push(emotion3.join(" ")); emotion3.length = 3;
} labels2.push(emotion3.join(" "));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) if (f.rotation && f.rotation.angle && f.rotation.gaze) {
labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`); if (f.rotation.angle.roll)
if (f.rotation.gaze.bearing) labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`);
labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`); if (f.rotation.gaze.bearing)
} labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`);
if (labels2.length === 0) }
labels2.push("face"); if (labels2.length === 0)
ctx.fillStyle = localOptions.color; labels2.push("face");
for (let i = labels2.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels2.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(labels2[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels2[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {
@ -11510,31 +11515,31 @@ var detectFace = async (parent, input) => {
const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]); const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]);
parent.analyze("Start Emotion:"); parent.analyze("Start Emotion:");
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:emotion"; parent.state = "run:emotion";
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Emotion:"); parent.analyze("End Emotion:");
parent.analyze("Start AntiSpoof:"); parent.analyze("Start AntiSpoof:");
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:antispoof"; parent.state = "run:antispoof";
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze("End AntiSpoof:"); parent.analyze("End AntiSpoof:");
parent.analyze("Start Description:"); parent.analyze("Start Description:");
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:description"; parent.state = "run:description";
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Description:"); parent.analyze("End Description:");
@ -11554,10 +11559,10 @@ var detectFace = async (parent, input) => {
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes == null ? void 0 : descRes.age,
gender: descRes.gender, gender: descRes == null ? void 0 : descRes.gender,
genderScore: descRes.genderScore, genderScore: descRes == null ? void 0 : descRes.genderScore,
embedding: descRes.descriptor, embedding: descRes == null ? void 0 : descRes.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

View File

@ -10938,6 +10938,7 @@ var options2 = {
drawPoints: false, drawPoints: false,
drawLabels: true, drawLabels: true,
drawBoxes: true, drawBoxes: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawGaze: true, drawGaze: true,
fillPolygons: false, fillPolygons: false,
@ -11042,24 +11043,26 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions); const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2) if (!result || !inCanvas2)
return; return;
const ctx = getCanvasContext(inCanvas2); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas2);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where = []; for (let j = 0; j < result.length; j++) {
let what = []; let where = [];
[where, what] = Object.entries(result[j]); let what = [];
if (what.length > 1 && what[1].length > 0) { [where, what] = Object.entries(result[j]);
const who = where[1] > 0 ? `#${where[1]}` : ""; if (what.length > 1 && what[1].length > 0) {
const label = `${where[0]} ${who}: ${what[1]}`; const who = where[1] > 0 ? `#${where[1]}` : "";
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const label = `${where[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
} }
} }
@ -11075,40 +11078,42 @@ async function face(inCanvas2, result, drawOptions) {
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) if (localOptions.drawBoxes)
rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
const labels2 = []; if (localOptions.drawLabels) {
labels2.push(`face: ${Math.trunc(100 * f.score)}%`); const labels2 = [];
if (f.genderScore) labels2.push(`face: ${Math.trunc(100 * f.score)}%`);
labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`); if (f.genderScore)
if (f.age) labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`);
labels2.push(`age: ${f.age || ""}`); if (f.age)
if (f.iris) labels2.push(`age: ${f.age || ""}`);
labels2.push(`distance: ${f.iris}`); if (f.iris)
if (f.real) labels2.push(`distance: ${f.iris}`);
labels2.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.real)
if (f.emotion && f.emotion.length > 0) { labels2.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion3.length > 3) const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
emotion3.length = 3; if (emotion3.length > 3)
labels2.push(emotion3.join(" ")); emotion3.length = 3;
} labels2.push(emotion3.join(" "));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) if (f.rotation && f.rotation.angle && f.rotation.gaze) {
labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`); if (f.rotation.angle.roll)
if (f.rotation.gaze.bearing) labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`);
labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`); if (f.rotation.gaze.bearing)
} labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`);
if (labels2.length === 0) }
labels2.push("face"); if (labels2.length === 0)
ctx.fillStyle = localOptions.color; labels2.push("face");
for (let i = labels2.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels2.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(labels2[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels2[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {
@ -11511,31 +11516,31 @@ var detectFace = async (parent, input) => {
const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]); const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]);
parent.analyze("Start Emotion:"); parent.analyze("Start Emotion:");
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:emotion"; parent.state = "run:emotion";
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Emotion:"); parent.analyze("End Emotion:");
parent.analyze("Start AntiSpoof:"); parent.analyze("Start AntiSpoof:");
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:antispoof"; parent.state = "run:antispoof";
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze("End AntiSpoof:"); parent.analyze("End AntiSpoof:");
parent.analyze("Start Description:"); parent.analyze("Start Description:");
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:description"; parent.state = "run:description";
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Description:"); parent.analyze("End Description:");
@ -11555,10 +11560,10 @@ var detectFace = async (parent, input) => {
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes == null ? void 0 : descRes.age,
gender: descRes.gender, gender: descRes == null ? void 0 : descRes.gender,
genderScore: descRes.genderScore, genderScore: descRes == null ? void 0 : descRes.genderScore,
embedding: descRes.descriptor, embedding: descRes == null ? void 0 : descRes.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

125
dist/human.node.js vendored
View File

@ -10937,6 +10937,7 @@ var options2 = {
drawPoints: false, drawPoints: false,
drawLabels: true, drawLabels: true,
drawBoxes: true, drawBoxes: true,
drawGestures: true,
drawPolygons: true, drawPolygons: true,
drawGaze: true, drawGaze: true,
fillPolygons: false, fillPolygons: false,
@ -11041,24 +11042,26 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions); const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2) if (!result || !inCanvas2)
return; return;
const ctx = getCanvasContext(inCanvas2); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas2);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where = []; for (let j = 0; j < result.length; j++) {
let what = []; let where = [];
[where, what] = Object.entries(result[j]); let what = [];
if (what.length > 1 && what[1].length > 0) { [where, what] = Object.entries(result[j]);
const who = where[1] > 0 ? `#${where[1]}` : ""; if (what.length > 1 && what[1].length > 0) {
const label = `${where[0]} ${who}: ${what[1]}`; const who = where[1] > 0 ? `#${where[1]}` : "";
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const label = `${where[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + i * localOptions.lineHeight);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + i * localOptions.lineHeight);
i += 1;
} }
} }
} }
@ -11074,40 +11077,42 @@ async function face(inCanvas2, result, drawOptions) {
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) if (localOptions.drawBoxes)
rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
const labels2 = []; if (localOptions.drawLabels) {
labels2.push(`face: ${Math.trunc(100 * f.score)}%`); const labels2 = [];
if (f.genderScore) labels2.push(`face: ${Math.trunc(100 * f.score)}%`);
labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`); if (f.genderScore)
if (f.age) labels2.push(`${f.gender || ""} ${Math.trunc(100 * f.genderScore)}%`);
labels2.push(`age: ${f.age || ""}`); if (f.age)
if (f.iris) labels2.push(`age: ${f.age || ""}`);
labels2.push(`distance: ${f.iris}`); if (f.iris)
if (f.real) labels2.push(`distance: ${f.iris}`);
labels2.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.real)
if (f.emotion && f.emotion.length > 0) { labels2.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion3.length > 3) const emotion3 = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
emotion3.length = 3; if (emotion3.length > 3)
labels2.push(emotion3.join(" ")); emotion3.length = 3;
} labels2.push(emotion3.join(" "));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) if (f.rotation && f.rotation.angle && f.rotation.gaze) {
labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`); if (f.rotation.angle.roll)
if (f.rotation.gaze.bearing) labels2.push(`roll: ${rad2deg(f.rotation.angle.roll)}\xB0 yaw:${rad2deg(f.rotation.angle.yaw)}\xB0 pitch:${rad2deg(f.rotation.angle.pitch)}\xB0`);
labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`); if (f.rotation.gaze.bearing)
} labels2.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}\xB0`);
if (labels2.length === 0) }
labels2.push("face"); if (labels2.length === 0)
ctx.fillStyle = localOptions.color; labels2.push("face");
for (let i = labels2.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels2.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== "") { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== "") {
ctx.fillText(labels2[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels2[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels2[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {
@ -11510,31 +11515,31 @@ var detectFace = async (parent, input) => {
const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]); const rotation = calculateFaceAngle(faces[i], [input.shape[2], input.shape[1]]);
parent.analyze("Start Emotion:"); parent.analyze("Start Emotion:");
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:emotion"; parent.state = "run:emotion";
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await predict5(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Emotion:"); parent.analyze("End Emotion:");
parent.analyze("Start AntiSpoof:"); parent.analyze("Start AntiSpoof:");
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:antispoof"; parent.state = "run:antispoof";
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await predict(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze("End AntiSpoof:"); parent.analyze("End AntiSpoof:");
parent.analyze("Start Description:"); parent.analyze("Start Description:");
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = "run:description"; parent.state = "run:description";
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await predict7(faces[i].tensor || tf26.tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze("End Description:"); parent.analyze("End Description:");
@ -11554,10 +11559,10 @@ var detectFace = async (parent, input) => {
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes == null ? void 0 : descRes.age,
gender: descRes.gender, gender: descRes == null ? void 0 : descRes.gender,
genderScore: descRes.genderScore, genderScore: descRes == null ? void 0 : descRes.genderScore,
embedding: descRes.descriptor, embedding: descRes == null ? void 0 : descRes.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

View File

@ -48,11 +48,11 @@ export const detectFace = async (parent /* instance of human */, input: Tensor):
// run emotion, inherits face from blazeface // run emotion, inherits face from blazeface
parent.analyze('Start Emotion:'); parent.analyze('Start Emotion:');
if (parent.config.async) { if (parent.config.async) {
emotionRes = parent.config.face.emotion.enabled ? emotion.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? emotion.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = 'run:emotion'; parent.state = 'run:emotion';
timeStamp = now(); timeStamp = now();
emotionRes = parent.config.face.emotion.enabled ? await emotion.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : {}; emotionRes = parent.config.face.emotion.enabled ? await emotion.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : null;
parent.performance.emotion = Math.trunc(now() - timeStamp); parent.performance.emotion = Math.trunc(now() - timeStamp);
} }
parent.analyze('End Emotion:'); parent.analyze('End Emotion:');
@ -60,11 +60,11 @@ export const detectFace = async (parent /* instance of human */, input: Tensor):
// run antispoof, inherits face from blazeface // run antispoof, inherits face from blazeface
parent.analyze('Start AntiSpoof:'); parent.analyze('Start AntiSpoof:');
if (parent.config.async) { if (parent.config.async) {
antispoofRes = parent.config.face.antispoof.enabled ? antispoof.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? antispoof.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = 'run:antispoof'; parent.state = 'run:antispoof';
timeStamp = now(); timeStamp = now();
antispoofRes = parent.config.face.antispoof.enabled ? await antispoof.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : {}; antispoofRes = parent.config.face.antispoof.enabled ? await antispoof.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : null;
parent.performance.antispoof = Math.trunc(now() - timeStamp); parent.performance.antispoof = Math.trunc(now() - timeStamp);
} }
parent.analyze('End AntiSpoof:'); parent.analyze('End AntiSpoof:');
@ -86,11 +86,11 @@ export const detectFace = async (parent /* instance of human */, input: Tensor):
// run emotion, inherits face from blazeface // run emotion, inherits face from blazeface
parent.analyze('Start Description:'); parent.analyze('Start Description:');
if (parent.config.async) { if (parent.config.async) {
descRes = parent.config.face.description.enabled ? faceres.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? faceres.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : null;
} else { } else {
parent.state = 'run:description'; parent.state = 'run:description';
timeStamp = now(); timeStamp = now();
descRes = parent.config.face.description.enabled ? await faceres.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : []; descRes = parent.config.face.description.enabled ? await faceres.predict(faces[i].tensor || tf.tensor([]), parent.config, i, faces.length) : null;
parent.performance.embedding = Math.trunc(now() - timeStamp); parent.performance.embedding = Math.trunc(now() - timeStamp);
} }
parent.analyze('End Description:'); parent.analyze('End Description:');
@ -124,10 +124,10 @@ export const detectFace = async (parent /* instance of human */, input: Tensor):
faceRes.push({ faceRes.push({
...faces[i], ...faces[i],
id: i, id: i,
age: descRes.age, age: descRes?.age,
gender: descRes.gender, gender: descRes?.gender,
genderScore: descRes.genderScore, genderScore: descRes?.genderScore,
embedding: descRes.descriptor, embedding: descRes?.descriptor,
emotion: emotionRes, emotion: emotionRes,
real: antispoofRes, real: antispoofRes,
iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0, iris: irisSize !== 0 ? Math.trunc(500 / irisSize / 11.7) / 100 : 0,

View File

@ -135,7 +135,7 @@ export class Human {
* - canvas: draw processed canvas which is a processed copy of the input * - canvas: draw processed canvas which is a processed copy of the input
* - all: meta-function that performs: canvas, face, body, hand * - all: meta-function that performs: canvas, face, body, hand
*/ */
draw: { canvas, face, body, hand, gesture, object, person, all, options: DrawOptions }; draw: { canvas: typeof draw.canvas, face: typeof draw.face, body: typeof draw.body, hand: typeof draw.hand, gesture: typeof draw.gesture, object: typeof draw.object, person: typeof draw.person, all: typeof draw.all, options: DrawOptions };
/** Currently loaded models /** Currently loaded models
* @internal * @internal

View File

@ -37,6 +37,7 @@ export interface DrawOptions {
roundRect: number, roundRect: number,
drawPoints: boolean, drawPoints: boolean,
drawLabels: boolean, drawLabels: boolean,
drawGestures: boolean,
drawBoxes: boolean, drawBoxes: boolean,
drawPolygons: boolean, drawPolygons: boolean,
drawGaze: boolean, drawGaze: boolean,
@ -58,6 +59,7 @@ export const options: DrawOptions = {
drawPoints: <boolean>false, drawPoints: <boolean>false,
drawLabels: <boolean>true, drawLabels: <boolean>true,
drawBoxes: <boolean>true, drawBoxes: <boolean>true,
drawGestures: <boolean>true,
drawPolygons: <boolean>true, drawPolygons: <boolean>true,
drawGaze: <boolean>true, drawGaze: <boolean>true,
fillPolygons: <boolean>false, fillPolygons: <boolean>false,
@ -166,24 +168,26 @@ function arrow(ctx: CanvasRenderingContext2D, from: Point, to: Point, radius = 5
export async function gesture(inCanvas: HTMLCanvasElement | OffscreenCanvas, result: Array<GestureResult>, drawOptions?: Partial<DrawOptions>) { export async function gesture(inCanvas: HTMLCanvasElement | OffscreenCanvas, result: Array<GestureResult>, drawOptions?: Partial<DrawOptions>) {
const localOptions = mergeDeep(options, drawOptions); const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return; if (!result || !inCanvas) return;
const ctx = getCanvasContext(inCanvas); if (localOptions.drawGestures) {
ctx.font = localOptions.font; const ctx = getCanvasContext(inCanvas);
ctx.fillStyle = localOptions.color; ctx.font = localOptions.font;
let i = 1; ctx.fillStyle = localOptions.color;
for (let j = 0; j < result.length; j++) { let i = 1;
let where: unknown[] = []; // what&where is a record for (let j = 0; j < result.length; j++) {
let what: unknown[] = []; // what&where is a record let where: unknown[] = []; // what&where is a record
[where, what] = Object.entries(result[j]); let what: unknown[] = []; // what&where is a record
if ((what.length > 1) && ((what[1] as string).length > 0)) { [where, what] = Object.entries(result[j]);
const who = where[1] as number > 0 ? `#${where[1]}` : ''; if ((what.length > 1) && ((what[1] as string).length > 0)) {
const label = `${where[0]} ${who}: ${what[1]}`; const who = where[1] as number > 0 ? `#${where[1]}` : '';
if (localOptions.shadowColor && localOptions.shadowColor !== '') { const label = `${where[0]} ${who}: ${what[1]}`;
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== '') {
ctx.fillText(label, 8, 2 + (i * localOptions.lineHeight)); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(label, 8, 2 + (i * localOptions.lineHeight));
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + (i * localOptions.lineHeight));
i += 1;
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(label, 6, 0 + (i * localOptions.lineHeight));
i += 1;
} }
} }
} }
@ -197,33 +201,35 @@ export async function face(inCanvas: HTMLCanvasElement | OffscreenCanvas, result
ctx.strokeStyle = localOptions.color; ctx.strokeStyle = localOptions.color;
ctx.fillStyle = localOptions.color; ctx.fillStyle = localOptions.color;
if (localOptions.drawBoxes) rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions); if (localOptions.drawBoxes) rect(ctx, f.box[0], f.box[1], f.box[2], f.box[3], localOptions);
// silly hack since fillText does not suport new line if (localOptions.drawLabels) {
const labels:string[] = []; // silly hack since fillText does not suport new line
labels.push(`face: ${Math.trunc(100 * f.score)}%`); const labels:string[] = [];
if (f.genderScore) labels.push(`${f.gender || ''} ${Math.trunc(100 * f.genderScore)}%`); labels.push(`face: ${Math.trunc(100 * f.score)}%`);
if (f.age) labels.push(`age: ${f.age || ''}`); if (f.genderScore) labels.push(`${f.gender || ''} ${Math.trunc(100 * f.genderScore)}%`);
if (f.iris) labels.push(`distance: ${f.iris}`); if (f.age) labels.push(`age: ${f.age || ''}`);
if (f.real) labels.push(`Real: ${Math.trunc(100 * f.real)}%`); if (f.iris) labels.push(`distance: ${f.iris}`);
if (f.emotion && f.emotion.length > 0) { if (f.real) labels.push(`real: ${Math.trunc(100 * f.real)}%`);
const emotion = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`); if (f.emotion && f.emotion.length > 0) {
if (emotion.length > 3) emotion.length = 3; const emotion = f.emotion.map((a) => `${Math.trunc(100 * a.score)}% ${a.emotion}`);
labels.push(emotion.join(' ')); if (emotion.length > 3) emotion.length = 3;
} labels.push(emotion.join(' '));
if (f.rotation && f.rotation.angle && f.rotation.gaze) { }
if (f.rotation.angle.roll) labels.push(`roll: ${rad2deg(f.rotation.angle.roll)}° yaw:${rad2deg(f.rotation.angle.yaw)}° pitch:${rad2deg(f.rotation.angle.pitch)}°`); if (f.rotation && f.rotation.angle && f.rotation.gaze) {
if (f.rotation.gaze.bearing) labels.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}°`); if (f.rotation.angle.roll) labels.push(`roll: ${rad2deg(f.rotation.angle.roll)}° yaw:${rad2deg(f.rotation.angle.yaw)}° pitch:${rad2deg(f.rotation.angle.pitch)}°`);
} if (f.rotation.gaze.bearing) labels.push(`gaze: ${rad2deg(f.rotation.gaze.bearing)}°`);
if (labels.length === 0) labels.push('face'); }
ctx.fillStyle = localOptions.color; if (labels.length === 0) labels.push('face');
for (let i = labels.length - 1; i >= 0; i--) { ctx.fillStyle = localOptions.color;
const x = Math.max(f.box[0], 0); for (let i = labels.length - 1; i >= 0; i--) {
const y = i * localOptions.lineHeight + f.box[1]; const x = Math.max(f.box[0], 0);
if (localOptions.shadowColor && localOptions.shadowColor !== '') { const y = i * localOptions.lineHeight + f.box[1];
ctx.fillStyle = localOptions.shadowColor; if (localOptions.shadowColor && localOptions.shadowColor !== '') {
ctx.fillText(labels[i], x + 5, y + 16); ctx.fillStyle = localOptions.shadowColor;
ctx.fillText(labels[i], x + 5, y + 16);
}
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels[i], x + 4, y + 15);
} }
ctx.fillStyle = localOptions.labelColor;
ctx.fillText(labels[i], x + 4, y + 15);
} }
ctx.lineWidth = 1; ctx.lineWidth = 1;
if (f.mesh && f.mesh.length > 0) { if (f.mesh && f.mesh.length > 0) {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

39
typedoc/classes/Env.html Normal file

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

24
types/src/human.d.ts vendored
View File

@ -1,9 +1,11 @@
/** /**
* Human main module * Human main module
*/ */
import { Env } from './util/env';
import * as tf from '../dist/tfjs.esm.js'; import * as tf from '../dist/tfjs.esm.js';
import * as env from './util/env'; import * as draw from './util/draw';
import * as facemesh from './face/facemesh'; import * as facemesh from './face/facemesh';
import * as image from './image/image';
import * as match from './face/match'; import * as match from './face/match';
import * as models from './models'; import * as models from './models';
import type { Result } from './result'; import type { Result } from './result';
@ -88,7 +90,7 @@ export declare class Human {
*/ */
tf: TensorFlow; tf: TensorFlow;
/** Object containing environment information used for diagnostics */ /** Object containing environment information used for diagnostics */
env: env.Env; env: Env;
/** Draw helper classes that can draw detected objects on canvas using specified draw /** Draw helper classes that can draw detected objects on canvas using specified draw
* - options: {@link DrawOptions} global settings for all draw operations, can be overriden for each draw method * - options: {@link DrawOptions} global settings for all draw operations, can be overriden for each draw method
* - face: draw detected faces * - face: draw detected faces
@ -98,14 +100,14 @@ export declare class Human {
* - all: meta-function that performs: canvas, face, body, hand * - all: meta-function that performs: canvas, face, body, hand
*/ */
draw: { draw: {
canvas: any; canvas: typeof draw.canvas;
face: any; face: typeof draw.face;
body: any; body: typeof draw.body;
hand: any; hand: typeof draw.hand;
gesture: any; gesture: typeof draw.gesture;
object: any; object: typeof draw.object;
person: any; person: typeof draw.person;
all: any; all: typeof draw.all;
options: DrawOptions; options: DrawOptions;
}; };
/** Currently loaded models /** Currently loaded models
@ -162,7 +164,7 @@ export declare class Human {
*/ */
image(input: Input, getTensor?: boolean): { image(input: Input, getTensor?: boolean): {
tensor: Tensor<import("@tensorflow/tfjs-core").Rank> | null; tensor: Tensor<import("@tensorflow/tfjs-core").Rank> | null;
canvas: HTMLCanvasElement | OffscreenCanvas | null; canvas: image.AnyCanvas | null;
}; };
/** Segmentation method takes any input and returns processed canvas with body segmentation /** Segmentation method takes any input and returns processed canvas with body segmentation
* - Optional parameter background is used to fill the background with specific input * - Optional parameter background is used to fill the background with specific input

View File

@ -1 +1 @@
{"version":3,"file":"human.d.ts","sourceRoot":"","sources":["../../src/human.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAO1C,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAQ5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AASnC,OAAO,KAAK,EAAE,MAAM,EAAiF,MAAM,UAAU,CAAC;AACtH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,kEAAkE;AAClE,cAAc,UAAU,CAAC;AAEzB,6DAA6D;AAC7D,cAAc,UAAU,CAAC;AAEzB,yDAAyD;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,2CAA2C;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,+BAA+B;AAC/B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,4DAA4D;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC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AAe,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAAA;KAAE,CAAC;IAIxL;;;;OAIG;IAEH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;;;;MAKE;IACI,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCvD,cAAc;IACd,IAAI,UAAW,MAAM,UAEnB;IAEF;;;;;OAKG;IACH,IAAI,CAAC,MAAM,GAAE,MAAoB,GAAG,MAAM;IAI1C;;;;;MAKE;IACI,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,KAAK,MAAA;KAAE,CAAC;IAIvE;;;;;;;;;MASE;IACI,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;CAkKlF;AAED,oCAAoC;AACpC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC"}

View File

@ -5,11 +5,12 @@ import type { Tensor } from '../tfjs/types';
import type { Config } from '../config'; import type { Config } from '../config';
import { env } from '../util/env'; import { env } from '../util/env';
export declare type Input = Tensor | ImageData | ImageBitmap | HTMLImageElement | HTMLMediaElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | typeof Image | typeof env.Canvas; export declare type Input = Tensor | ImageData | ImageBitmap | HTMLImageElement | HTMLMediaElement | HTMLVideoElement | HTMLCanvasElement | OffscreenCanvas | typeof Image | typeof env.Canvas;
export declare function canvas(width: any, height: any): HTMLCanvasElement | OffscreenCanvas; export declare type AnyCanvas = HTMLCanvasElement | OffscreenCanvas;
export declare function copy(input: HTMLCanvasElement | OffscreenCanvas, output?: HTMLCanvasElement | OffscreenCanvas): HTMLCanvasElement | OffscreenCanvas; export declare function canvas(width: any, height: any): AnyCanvas;
export declare function copy(input: AnyCanvas, output?: AnyCanvas): AnyCanvas;
export declare function process(input: Input, config: Config, getTensor?: boolean): { export declare function process(input: Input, config: Config, getTensor?: boolean): {
tensor: Tensor | null; tensor: Tensor | null;
canvas: OffscreenCanvas | HTMLCanvasElement | null; canvas: AnyCanvas | null;
}; };
export declare function skip(config: any, input: Tensor): Promise<boolean>; export declare function skip(config: any, input: Tensor): Promise<boolean>;
//# sourceMappingURL=image.d.ts.map //# sourceMappingURL=image.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/image/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,oBAAY,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,GAAG,OAAO,KAAK,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC;AAUvL,wBAAgB,MAAM,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA,GAAG,iBAAiB,GAAG,eAAe,CAkBzE;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,eAAe,uCAK5G;AAKD,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,GAAG,IAAI,CAAA;CAAE,CA8J9J;AAkCD,wBAAsB,IAAI,CAAC,MAAM,KAAA,EAAE,KAAK,EAAE,MAAM,oBAY/C"} {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/image/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,oBAAY,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,GAAG,OAAO,KAAK,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC;AACvL,oBAAY,SAAS,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAU5D,wBAAgB,MAAM,CAAC,KAAK,KAAA,EAAE,MAAM,KAAA,GAAG,SAAS,CAkB/C;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,aAKxD;AAKD,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,CA8JpI;AAkCD,wBAAsB,IAAI,CAAC,MAAM,KAAA,EAAE,KAAK,EAAE,MAAM,oBAY/C"}

View File

@ -8,7 +8,6 @@
* @property {function} add add specified filter to filter chain * @property {function} add add specified filter to filter chain
* @property {function} apply execute filter chain and draw result * @property {function} apply execute filter chain and draw result
* @property {function} draw just draw input to result * @property {function} draw just draw input to result
* @param {HTMLCanvasElement | OffscreenCanvas} canvas use specific canvas for all webgl bindings
*/ */
export declare function GLImageFilter(params?: {}): void; export declare function GLImageFilter(): void;
//# sourceMappingURL=imagefx.d.ts.map //# sourceMappingURL=imagefx.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"imagefx.d.ts","sourceRoot":"","sources":["../../../src/image/imagefx.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,KAAK,QAkWxC"} {"version":3,"file":"imagefx.d.ts","sourceRoot":"","sources":["../../../src/image/imagefx.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6CH;;;;;;GAMG;AAEH,wBAAgB,aAAa,SAkW5B"}

View File

@ -1 +1 @@
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/tfjs/backend.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAOpD,wBAAsB,KAAK,CAAC,QAAQ,KAAA,EAAE,KAAK,UAAQ,oBAqGlD;AAGD,wBAAgB,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,KAAA,QAazD"} {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/tfjs/backend.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAOpD,wBAAsB,KAAK,CAAC,QAAQ,KAAA,EAAE,KAAK,UAAQ,oBAoGlD;AAGD,wBAAgB,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,KAAA,QAazD"}

View File

@ -33,6 +33,7 @@ export interface DrawOptions {
roundRect: number; roundRect: number;
drawPoints: boolean; drawPoints: boolean;
drawLabels: boolean; drawLabels: boolean;
drawGestures: boolean;
drawBoxes: boolean; drawBoxes: boolean;
drawPolygons: boolean; drawPolygons: boolean;
drawGaze: boolean; drawGaze: boolean;

View File

@ -1 +1 @@
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../../src/util/draw.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,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O,CAAC,WAAW,CAAC,iBAwB1I;AAED,wBAAsB,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,iBAI1J;AAED,wBAAsB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,GAAG,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,kDAc1H"}

View File

@ -1,20 +1,21 @@
export declare type Env = { /** Env class that holds detected capabilities */
export declare class Env {
/** Running in Browser */ /** Running in Browser */
browser: undefined | boolean; browser: boolean;
/** Running in NodeJS */ /** Running in NodeJS */
node: undefined | boolean; node: boolean;
/** Running in WebWorker thread */ /** Running in WebWorker thread */
worker: undefined | boolean; worker: boolean;
/** Detected platform */ /** Detected platform */
platform: undefined | string; platform: string;
/** Detected agent */ /** Detected agent */
agent: undefined | string; agent: string;
/** List of supported backends */ /** List of supported backends */
backends: string[]; backends: string[];
/** Has any work been performed so far */ /** Has any work been performed so far */
initial: boolean; initial: boolean;
/** Are image filters supported? */ /** Are image filters supported? */
filter: undefined | boolean; filter: boolean | undefined;
/** TFJS instance details */ /** TFJS instance details */
tfjs: { tfjs: {
version: undefined | string; version: undefined | string;
@ -41,6 +42,11 @@ export declare type Env = {
backend: undefined | boolean; backend: undefined | boolean;
adapter: undefined | string; adapter: undefined | string;
}; };
/** CPU info */
cpu: {
model: undefined | string;
flags: string[];
};
/** List of supported kernels for current backend */ /** List of supported kernels for current backend */
kernels: string[]; kernels: string[];
/** MonkeyPatch for Canvas */ /** MonkeyPatch for Canvas */
@ -49,10 +55,9 @@ export declare type Env = {
Image: undefined; Image: undefined;
/** MonkeyPatch for ImageData */ /** MonkeyPatch for ImageData */
ImageData: undefined; ImageData: undefined;
}; constructor();
export declare let env: Env; updateBackend(): Promise<void>;
export declare function cpuInfo(): Promise<void>; updateCPU(): Promise<void>;
export declare function backendInfo(): Promise<void>; }
export declare function get(): Promise<void>; export declare const env: Env;
export declare function set(obj: any): Promise<void>;
//# sourceMappingURL=env.d.ts.map //# sourceMappingURL=env.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/util/env.ts"],"names":[],"mappings":"AAIA,oBAAY,GAAG,GAAG;IAChB,yBAAyB;IACzB,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,wBAAwB;IACxB,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1B,kCAAkC;IAClC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,wBAAwB;IACxB,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC;IAC7B,qBAAqB;IACrB,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,iCAAiC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,4BAA4B;IAC5B,IAAI,EAAE;QACJ,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;KAC7B,CAAC;IACF,oCAAoC;IACpC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;IAC/B,iCAAiC;IACjC,IAAI,EAAE;QACJ,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;QAC/B,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;QAC7B,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;QAC1B,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC;KAClC,CAAC;IACF,kCAAkC;IAClC,KAAK,EAAE;QACL,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;QAC/B,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;QAC7B,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;QAC5B,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC;KAC9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