@droneblocks/node-red-dexi
Version:
You want to make sure you don't lose any of your flow development. Make sure to map the host "flows" directory to the container directory as shown below. This will store the flow on your host machine if/when the container is destroyed.
29 lines (22 loc) • 923 B
JavaScript
module.exports = function (RED) {
const tf = require("@tensorflow/tfjs-node");
const handpose = require("@tensorflow-models/handpose");
function HandPoseNode(config) {
RED.nodes.createNode(this, config);
let node = this;
let modelPromise = handpose.load(); // Load the HandPose model once
node.on("input", async function (msg) {
try {
let buffer = Buffer.from(msg.payload.data, "base64");
let imageTensor = tf.node.decodeImage(buffer);
let model = await modelPromise;
let predictions = await model.estimateHands(imageTensor);
msg.detections = predictions; // Return hand keypoints
node.send(msg);
} catch (error) {
node.error(error.message, msg);
}
});
}
RED.nodes.registerType("hand-pose", HandPoseNode);
};