mirror of https://github.com/vladmandic/human
simplify canvas handling in nodejs
parent
3c66210fd8
commit
e3429c3e18
|
@ -114,7 +114,7 @@ async function detect(input, output) {
|
|||
ctx.drawImage(original, 0, 0, outputCanvas.width, outputCanvas.height); // draw original to new canvas
|
||||
|
||||
// draw human results on canvas
|
||||
human.setCanvas(outputCanvas); // tell human to use this canvas
|
||||
// human.setCanvas(outputCanvas); // tell human to use this canvas
|
||||
human.draw.all(outputCanvas, result); // human will draw results as overlays on canvas
|
||||
|
||||
// write canvas to new image 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
File diff suppressed because one or more lines are too long
|
@ -10409,8 +10409,7 @@ __export(draw_exports, {
|
|||
hand: () => hand2,
|
||||
object: () => object,
|
||||
options: () => options2,
|
||||
person: () => person,
|
||||
setCanvas: () => setCanvas
|
||||
person: () => person
|
||||
});
|
||||
var options2 = {
|
||||
color: "rgba(173, 216, 230, 0.6)",
|
||||
|
@ -10431,19 +10430,10 @@ var options2 = {
|
|||
useCurves: false,
|
||||
bufferedOutput: true
|
||||
};
|
||||
var Canvas;
|
||||
function setCanvas(obj) {
|
||||
if (obj.getContext)
|
||||
Canvas = obj;
|
||||
else
|
||||
throw new Error("Human: Canvas is not functional");
|
||||
}
|
||||
var checkCanvas = (input) => {
|
||||
if (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
|
||||
return true;
|
||||
if (typeof Canvas !== "undefined")
|
||||
return true;
|
||||
return false;
|
||||
var getCanvasContext = (input) => {
|
||||
if (input && input.getContext)
|
||||
return input.getContext("2d");
|
||||
throw new Error("Human: Invalid Canvas");
|
||||
};
|
||||
var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
|
||||
function point(ctx, x, y, z = 0, localOptions) {
|
||||
|
@ -10514,11 +10504,7 @@ async function gesture(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.font = localOptions.font;
|
||||
ctx.fillStyle = localOptions.color;
|
||||
let i = 1;
|
||||
|
@ -10544,11 +10530,7 @@ async function face2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
for (const f of result) {
|
||||
ctx.font = localOptions.font;
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -10654,11 +10636,7 @@ async function body2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -10786,11 +10764,7 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -10854,11 +10828,7 @@ async function object(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -10883,11 +10853,7 @@ async function person(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
|
@ -10911,18 +10877,15 @@ async function person(inCanvas2, result, drawOptions) {
|
|||
async function canvas(inCanvas2, outCanvas2) {
|
||||
if (!inCanvas2 || !outCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2) || !checkCanvas(outCanvas2))
|
||||
return;
|
||||
const outCtx = inCanvas2.getContext("2d");
|
||||
outCtx == null ? void 0 : outCtx.drawImage(inCanvas2, 0, 0);
|
||||
getCanvasContext(outCanvas2);
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.drawImage(inCanvas2, 0, 0);
|
||||
}
|
||||
async function all(inCanvas2, result, drawOptions) {
|
||||
const timestamp = now();
|
||||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return null;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return null;
|
||||
const promise = Promise.all([
|
||||
face2(inCanvas2, result.face, localOptions),
|
||||
body2(inCanvas2, result.body, localOptions),
|
||||
|
@ -11819,7 +11782,6 @@ var _Human = class {
|
|||
__privateAdd(this, _firstRun, void 0);
|
||||
__privateAdd(this, _lastInputSum, void 0);
|
||||
__privateAdd(this, _lastCacheDiff, void 0);
|
||||
this.setCanvas = (canvas2) => setCanvas(canvas2);
|
||||
this.analyze = (...msg) => {
|
||||
if (!__privateGet(this, _analyzeMemoryLeaks))
|
||||
return;
|
||||
|
|
|
@ -10410,8 +10410,7 @@ __export(draw_exports, {
|
|||
hand: () => hand2,
|
||||
object: () => object,
|
||||
options: () => options2,
|
||||
person: () => person,
|
||||
setCanvas: () => setCanvas
|
||||
person: () => person
|
||||
});
|
||||
var options2 = {
|
||||
color: "rgba(173, 216, 230, 0.6)",
|
||||
|
@ -10432,19 +10431,10 @@ var options2 = {
|
|||
useCurves: false,
|
||||
bufferedOutput: true
|
||||
};
|
||||
var Canvas;
|
||||
function setCanvas(obj) {
|
||||
if (obj.getContext)
|
||||
Canvas = obj;
|
||||
else
|
||||
throw new Error("Human: Canvas is not functional");
|
||||
}
|
||||
var checkCanvas = (input) => {
|
||||
if (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
|
||||
return true;
|
||||
if (typeof Canvas !== "undefined")
|
||||
return true;
|
||||
return false;
|
||||
var getCanvasContext = (input) => {
|
||||
if (input && input.getContext)
|
||||
return input.getContext("2d");
|
||||
throw new Error("Human: Invalid Canvas");
|
||||
};
|
||||
var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
|
||||
function point(ctx, x, y, z = 0, localOptions) {
|
||||
|
@ -10515,11 +10505,7 @@ async function gesture(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.font = localOptions.font;
|
||||
ctx.fillStyle = localOptions.color;
|
||||
let i = 1;
|
||||
|
@ -10545,11 +10531,7 @@ async function face2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
for (const f of result) {
|
||||
ctx.font = localOptions.font;
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -10655,11 +10637,7 @@ async function body2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -10787,11 +10765,7 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -10855,11 +10829,7 @@ async function object(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -10884,11 +10854,7 @@ async function person(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
|
@ -10912,18 +10878,15 @@ async function person(inCanvas2, result, drawOptions) {
|
|||
async function canvas(inCanvas2, outCanvas2) {
|
||||
if (!inCanvas2 || !outCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2) || !checkCanvas(outCanvas2))
|
||||
return;
|
||||
const outCtx = inCanvas2.getContext("2d");
|
||||
outCtx == null ? void 0 : outCtx.drawImage(inCanvas2, 0, 0);
|
||||
getCanvasContext(outCanvas2);
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.drawImage(inCanvas2, 0, 0);
|
||||
}
|
||||
async function all(inCanvas2, result, drawOptions) {
|
||||
const timestamp = now();
|
||||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return null;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return null;
|
||||
const promise = Promise.all([
|
||||
face2(inCanvas2, result.face, localOptions),
|
||||
body2(inCanvas2, result.body, localOptions),
|
||||
|
@ -11820,7 +11783,6 @@ var _Human = class {
|
|||
__privateAdd(this, _firstRun, void 0);
|
||||
__privateAdd(this, _lastInputSum, void 0);
|
||||
__privateAdd(this, _lastCacheDiff, void 0);
|
||||
this.setCanvas = (canvas2) => setCanvas(canvas2);
|
||||
this.analyze = (...msg) => {
|
||||
if (!__privateGet(this, _analyzeMemoryLeaks))
|
||||
return;
|
||||
|
|
|
@ -10409,8 +10409,7 @@ __export(draw_exports, {
|
|||
hand: () => hand2,
|
||||
object: () => object,
|
||||
options: () => options2,
|
||||
person: () => person,
|
||||
setCanvas: () => setCanvas
|
||||
person: () => person
|
||||
});
|
||||
var options2 = {
|
||||
color: "rgba(173, 216, 230, 0.6)",
|
||||
|
@ -10431,19 +10430,10 @@ var options2 = {
|
|||
useCurves: false,
|
||||
bufferedOutput: true
|
||||
};
|
||||
var Canvas;
|
||||
function setCanvas(obj) {
|
||||
if (obj.getContext)
|
||||
Canvas = obj;
|
||||
else
|
||||
throw new Error("Human: Canvas is not functional");
|
||||
}
|
||||
var checkCanvas = (input) => {
|
||||
if (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
|
||||
return true;
|
||||
if (typeof Canvas !== "undefined")
|
||||
return true;
|
||||
return false;
|
||||
var getCanvasContext = (input) => {
|
||||
if (input && input.getContext)
|
||||
return input.getContext("2d");
|
||||
throw new Error("Human: Invalid Canvas");
|
||||
};
|
||||
var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
|
||||
function point(ctx, x, y, z = 0, localOptions) {
|
||||
|
@ -10514,11 +10504,7 @@ async function gesture(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.font = localOptions.font;
|
||||
ctx.fillStyle = localOptions.color;
|
||||
let i = 1;
|
||||
|
@ -10544,11 +10530,7 @@ async function face2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
for (const f of result) {
|
||||
ctx.font = localOptions.font;
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -10654,11 +10636,7 @@ async function body2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -10786,11 +10764,7 @@ async function hand2(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -10854,11 +10828,7 @@ async function object(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -10883,11 +10853,7 @@ async function person(inCanvas2, result, drawOptions) {
|
|||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return;
|
||||
const ctx = inCanvas2.getContext("2d");
|
||||
if (!ctx)
|
||||
return;
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.lineJoin = "round";
|
||||
ctx.font = localOptions.font;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
|
@ -10911,18 +10877,15 @@ async function person(inCanvas2, result, drawOptions) {
|
|||
async function canvas(inCanvas2, outCanvas2) {
|
||||
if (!inCanvas2 || !outCanvas2)
|
||||
return;
|
||||
if (!checkCanvas(inCanvas2) || !checkCanvas(outCanvas2))
|
||||
return;
|
||||
const outCtx = inCanvas2.getContext("2d");
|
||||
outCtx == null ? void 0 : outCtx.drawImage(inCanvas2, 0, 0);
|
||||
getCanvasContext(outCanvas2);
|
||||
const ctx = getCanvasContext(inCanvas2);
|
||||
ctx.drawImage(inCanvas2, 0, 0);
|
||||
}
|
||||
async function all(inCanvas2, result, drawOptions) {
|
||||
const timestamp = now();
|
||||
const localOptions = mergeDeep(options2, drawOptions);
|
||||
if (!result || !inCanvas2)
|
||||
return null;
|
||||
if (!checkCanvas(inCanvas2))
|
||||
return null;
|
||||
const promise = Promise.all([
|
||||
face2(inCanvas2, result.face, localOptions),
|
||||
body2(inCanvas2, result.body, localOptions),
|
||||
|
@ -11819,7 +11782,6 @@ var _Human = class {
|
|||
__privateAdd(this, _firstRun, void 0);
|
||||
__privateAdd(this, _lastInputSum, void 0);
|
||||
__privateAdd(this, _lastCacheDiff, void 0);
|
||||
this.setCanvas = (canvas2) => setCanvas(canvas2);
|
||||
this.analyze = (...msg) => {
|
||||
if (!__privateGet(this, _analyzeMemoryLeaks))
|
||||
return;
|
||||
|
|
|
@ -66,17 +66,9 @@ export const options: DrawOptions = {
|
|||
bufferedOutput: <boolean>true,
|
||||
};
|
||||
|
||||
let Canvas;
|
||||
|
||||
export function setCanvas(obj) {
|
||||
if (obj.getContext) Canvas = obj;
|
||||
else throw new Error('Human: Canvas is not functional');
|
||||
}
|
||||
|
||||
const checkCanvas = (input) => {
|
||||
if ((typeof HTMLCanvasElement !== 'undefined') && (input instanceof HTMLCanvasElement)) return true;
|
||||
if (typeof Canvas !== 'undefined') return true;
|
||||
return false;
|
||||
const getCanvasContext = (input) => {
|
||||
if (input && input.getContext) return input.getContext('2d');
|
||||
throw new Error('Human: Invalid Canvas');
|
||||
};
|
||||
|
||||
const rad2deg = (theta) => Math.round((theta * 180) / Math.PI);
|
||||
|
@ -150,9 +142,7 @@ function curves(ctx, points: [number, number, number?][] = [], localOptions) {
|
|||
export async function gesture(inCanvas: HTMLCanvasElement, result: Array<Gesture>, drawOptions?: DrawOptions) {
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return;
|
||||
if (!checkCanvas(inCanvas)) return;
|
||||
const ctx = inCanvas.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
ctx.font = localOptions.font;
|
||||
ctx.fillStyle = localOptions.color;
|
||||
let i = 1;
|
||||
|
@ -177,9 +167,7 @@ export async function gesture(inCanvas: HTMLCanvasElement, result: Array<Gesture
|
|||
export async function face(inCanvas: HTMLCanvasElement, result: Array<Face>, drawOptions?: DrawOptions) {
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return;
|
||||
if (!checkCanvas(inCanvas)) return;
|
||||
const ctx = inCanvas.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
for (const f of result) {
|
||||
ctx.font = localOptions.font;
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -281,9 +269,7 @@ export async function face(inCanvas: HTMLCanvasElement, result: Array<Face>, dra
|
|||
export async function body(inCanvas: HTMLCanvasElement, result: Array<Body>, drawOptions?: DrawOptions) {
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return;
|
||||
if (!checkCanvas(inCanvas)) return;
|
||||
const ctx = inCanvas.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
ctx.lineJoin = 'round';
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
ctx.strokeStyle = localOptions.color;
|
||||
|
@ -393,9 +379,7 @@ export async function body(inCanvas: HTMLCanvasElement, result: Array<Body>, dra
|
|||
export async function hand(inCanvas: HTMLCanvasElement, result: Array<Hand>, drawOptions?: DrawOptions) {
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return;
|
||||
if (!checkCanvas(inCanvas)) return;
|
||||
const ctx = inCanvas.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -459,9 +443,7 @@ export async function hand(inCanvas: HTMLCanvasElement, result: Array<Hand>, dra
|
|||
export async function object(inCanvas: HTMLCanvasElement, result: Array<Item>, drawOptions?: DrawOptions) {
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return;
|
||||
if (!checkCanvas(inCanvas)) return;
|
||||
const ctx = inCanvas.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.font = localOptions.font;
|
||||
for (const h of result) {
|
||||
|
@ -486,9 +468,7 @@ export async function object(inCanvas: HTMLCanvasElement, result: Array<Item>, d
|
|||
export async function person(inCanvas: HTMLCanvasElement, result: Array<Person>, drawOptions?: DrawOptions) {
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return;
|
||||
if (!checkCanvas(inCanvas)) return;
|
||||
const ctx = inCanvas.getContext('2d');
|
||||
if (!ctx) return;
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.font = localOptions.font;
|
||||
|
||||
|
@ -513,16 +493,15 @@ export async function person(inCanvas: HTMLCanvasElement, result: Array<Person>,
|
|||
|
||||
export async function canvas(inCanvas: HTMLCanvasElement, outCanvas: HTMLCanvasElement) {
|
||||
if (!inCanvas || !outCanvas) return;
|
||||
if (!checkCanvas(inCanvas) || !checkCanvas(outCanvas)) return;
|
||||
const outCtx = inCanvas.getContext('2d');
|
||||
outCtx?.drawImage(inCanvas, 0, 0);
|
||||
getCanvasContext(outCanvas);
|
||||
const ctx = getCanvasContext(inCanvas);
|
||||
ctx.drawImage(inCanvas, 0, 0);
|
||||
}
|
||||
|
||||
export async function all(inCanvas: HTMLCanvasElement, result: Result, drawOptions?: DrawOptions) {
|
||||
const timestamp = now();
|
||||
const localOptions = mergeDeep(options, drawOptions);
|
||||
if (!result || !inCanvas) return null;
|
||||
if (!checkCanvas(inCanvas)) return null;
|
||||
|
||||
const promise = Promise.all([
|
||||
face(inCanvas, result.face, localOptions),
|
||||
|
|
|
@ -190,13 +190,6 @@ export class Human {
|
|||
this.#lastInputSum = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets internal canvas methods
|
||||
*
|
||||
* @param canvas
|
||||
*/
|
||||
setCanvas = (canvas) => draw.setCanvas(canvas);
|
||||
|
||||
// helper function: measure tensor leak
|
||||
/** @hidden */
|
||||
analyze = (...msg: string[]) => {
|
||||
|
|
Loading…
Reference in New Issue