This repository was archived by the owner on Sep 21, 2023. It is now read-only.
forked from lysdexic-audio/n4m-handpose
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (35 loc) · 1.14 KB
/
index.js
File metadata and controls
39 lines (35 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const io = require("socket.io")();
const { Client } = require('node-osc');
const client = new Client('127.0.0.1', 8008);
io.on("connection", (socket) => {
console.log("Socket is connected with Electron App");
socket.on("dispatch", (data) => {
if (data.oscFormatting.handInViewConfidence) {
client.send("/handInViewConfidence", data.predictions.handInViewConfidence)
}
if (data.oscFormatting.boundingBox) {
client.send("/boundingBox/topLeft", data.predictions.boundingBox.topLeft)
client.send("/boundingBox/bottomRight", data.predictions.boundingBox.bottomRight)
}
if (data.oscFormatting.landmarks) {
client.send("/landmarks", data.predictions.landmarks)
}
if (data.oscFormatting.annotations) {
let annotations = data.predictions.annotations;
for (var key in annotations) {
if (annotations.hasOwnProperty(key)) {
client.send("/annotations/" + key, annotations[key]);
}
}
}
});
socket.on("oscPortSet", (port) => {
client.port = port;
console.log('OSC port set to', client.port);
});
socket.on("hostSet", (host) => {
client.host = host;
console.log('Host set to', client.host);
});
});
io.listen(3000);