From a3b2b84b6912650e5d5dfb329a51d319ce6de744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kol=C3=A1=C5=99?= Date: Wed, 10 Apr 2024 13:47:41 +0200 Subject: [PATCH] QR code color, eval wait for input option, optional tfjs AI models url --- src/nodes/AI/BodyPartSegmentation.ts | 7 ++++++- src/nodes/AI/BodySegmentation.ts | 9 +++++++-- src/nodes/AI/FaceFeaturePosition.ts | 12 +++++++++--- src/nodes/Eval.ts | 24 ++++++++++++++++++++++-- src/nodes/QRCodeGenerator.ts | 12 +++++++++++- 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/nodes/AI/BodyPartSegmentation.ts b/src/nodes/AI/BodyPartSegmentation.ts index 9f6e66f..d2d194e 100644 --- a/src/nodes/AI/BodyPartSegmentation.ts +++ b/src/nodes/AI/BodyPartSegmentation.ts @@ -1,7 +1,8 @@ import { BooleanVar, ImageVar, - NumberVar + NumberVar, + StringVar, } from '../io/AbstractIOSet'; import Node from "../Node"; import '@tensorflow/tfjs-backend-webgl'; @@ -66,6 +67,9 @@ const inputs = { min: 0, max: 1, } as NumberVar, + modelUrl: { + type: 'String', + } as StringVar, ...(flow([ bodyParts => keyBy(bodyParts, (bodyPart) => bodyPart), bodyParts => mapValues(bodyParts, () => ({ @@ -106,6 +110,7 @@ export default class BodyPartSegmentation extends Node { +export default class Eval extends Node { constructor() { super('Eval', inputs, outputs); } @@ -61,12 +73,20 @@ export default class NumberBinaryOperation extends Node const encodeHintTypeMap = new Map(); encodeHintTypeMap.set(EncodeHintType.MARGIN, this.in.margin.value); encodeHintTypeMap.set(EncodeHintType.ERROR_CORRECTION, QRCodeDecoderErrorCorrectionLevel[this.in.correction.value]); - const svgElement = this.writer.write(this.in.text.value, this.in.size.value, this.in.size.value, encodeHintTypeMap); + const svgElement: SVGSVGElement = this.writer.write(this.in.text.value, this.in.size.value, this.in.size.value, encodeHintTypeMap); + + for(const element of svgElement.querySelectorAll('[fill]')) { + element.setAttribute('fill', this.in.color.value); + } + const canvas = canvasPool2D.createCanvas(); canvas.width = this.in.size.value; canvas.height = this.in.size.value;