From 89df1423e5422f9ed8e435c199d29a5472fb4339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=A3=BC=EC=84=B1?= Date: Fri, 30 Sep 2022 16:15:52 +0900 Subject: [PATCH 1/2] feat: determine node for iot camera --- .../object-detection-iot-html.js | 264 ++++++++++++++++++ .../object-detection-iot.html | 117 ++++++++ object-detection-iot/object-detection-iot.js | 93 ++++++ 3 files changed, 474 insertions(+) create mode 100644 object-detection-iot/object-detection-iot-html.js create mode 100644 object-detection-iot/object-detection-iot.html create mode 100644 object-detection-iot/object-detection-iot.js diff --git a/object-detection-iot/object-detection-iot-html.js b/object-detection-iot/object-detection-iot-html.js new file mode 100644 index 00000000..741dd415 --- /dev/null +++ b/object-detection-iot/object-detection-iot-html.js @@ -0,0 +1,264 @@ +module.exports.code = (config) => { + return String.raw` + + + + + + + + +
+

Object detection display

+
+ +
+
+ + +
+ +
+

Detected objects


+

INDEX Objects register

+
+
+ + +
+ +
+ +
+ +
+ +
+
+ + +
+
+ + + D5MI + | + Seunghoon Park | Youngjin + Choi + | Juseong Hong | Sangwoo Han + | + Donghyun Han | Yongwoong + Kim
+
+ + + + + + + + + + + + + ` +} \ No newline at end of file diff --git a/object-detection-iot/object-detection-iot.html b/object-detection-iot/object-detection-iot.html new file mode 100644 index 00000000..39b3da90 --- /dev/null +++ b/object-detection-iot/object-detection-iot.html @@ -0,0 +1,117 @@ + + + + + \ No newline at end of file diff --git a/object-detection-iot/object-detection-iot.js b/object-detection-iot/object-detection-iot.js new file mode 100644 index 00000000..8c3cb673 --- /dev/null +++ b/object-detection-iot/object-detection-iot.js @@ -0,0 +1,93 @@ + +const ws = require('ws') +const http = require('http') +const cors = require('cors') +const express = require('express') +const Stream = require('node-rtsp-stream') + +module.exports = function (RED) { + + function ObjectDetectionNode(config) { + RED.nodes.createNode(this, config) + var node = this; + + + + function HTML() { + return require('./object-detection-html-iot.js').code(config) + } + + node.on('input', function (msg, send) { + const rtspUrl = msg.payload.com + const rtspPort = config.rtspPort || 1886 + const app = express(); + + app.use(cors({ + origin: true, + credentials: true + })) + + const httpServer = http.createServer(app) + + httpServer.once('error', err => { + if (err.code === 'EADDRINUSE') { + console.log('WEbSocker [RTSP] : port ${rtspPort} is already in use.') + } + }) + + httpServer.once('listening', () => { + const stream = Stream + stream.prototype = Stream.prototype + stream.prototype.constructor = stream + + stream.prototype.pipeStreamToSeockerServer = function () { + this.wsServer = new ws.Server({ + server: httpServer + }) + this.wsServer.on('connection', (socker, requset) => { + return this.soSockerConnect(socker, requset) + }) + this.wsServer.broadcast = function (data, opts) { + var results = [] + for (let client of this.clients) { + if (client.readyState === 1) { + results.push(client.send(data, opts)) + } + } + return results + } + return this.on('camdata', (data) => { + return this.wsServer.broadcast(data) + }) + } + const smartthingsMnid = this.credentials.smartthingsMnid + const smartthingsPat = this.credentials.smartthingsPat + + rtspStream = new newStream({ + name: 'name', + streamUrl: `rtsps://${smartthingsMnid}:${smartthingsPat}@${rtspUrl}`, + wsPort: rtspPort, + ffmpegOptions: { + '-stats': '', + '-r': 30 + } + }) + }) + httpServer.listen(rtspPort) + + msg.payload = HTML() + send = send || function () { this.send.apply(this, arguments) } + send(msg) + }) + this.on('close', function () { + rtspStream.stop() + }) + } + + RED.nodes.registerType("object-detect-iotcam", PoseDetectIotcamNode, { + credentials: { + smartthingsMnid: { type: "text" }, + smartthingsPat: { type: "text" } + } + }) +} From abc85543369187a592e77942504a0a215237ab11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=A3=BC=EC=84=B1?= Date: Mon, 3 Oct 2022 06:38:54 +0900 Subject: [PATCH 2/2] feat: object-detecting node for iot-camera --- .../object-detection-iot-html.js | 433 ++++++++++++------ .../object-detection-iot.html | 261 ++++++----- object_detection/object-detection-html.js | 1 + package.json | 9 +- 4 files changed, 452 insertions(+), 252 deletions(-) diff --git a/object-detection-iot/object-detection-iot-html.js b/object-detection-iot/object-detection-iot-html.js index 741dd415..62ad2256 100644 --- a/object-detection-iot/object-detection-iot-html.js +++ b/object-detection-iot/object-detection-iot-html.js @@ -1,86 +1,209 @@ module.exports.code = (config) => { return String.raw` - - - + #detected-result-section { + width: 30%; + background-color: white; + border: 1px solid black; + border-radius: 10px; + padding: 10px; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: center; + } -
-

Object detection display

-
+ #detected-objects { + display: flex; + flex-direction: column; + align-items: center; + } -
-
- - -
+ .sub-title { + font-size: 20px; + font-weight: bold; + padding: 10px; + } -
-

Detected objects


-

INDEX Objects register

-
-
- - -
- -
- -
- -
- -
-
+ #detected-objects-table { + width: 100%; + } + #detected-objects-table th, td { + padding: 5px; + text-align: center; + } -
-
- - - D5MI - | - Seunghoon Park | Youngjin - Choi - | Juseong Hong | Sangwoo Han - | - Donghyun Han | Yongwoong - Kim
-
+ .sub-btn { + display: flex; + justify-content: center; + background-color: rgb(153, 0, 0); + width: 100%; + padding: 8px 0; + margin: 8px 0; + border-radius: 5px; + color: white; + } + + .sub-btn:hover { + cursor: pointer; + } + #pose-object-register { + display: flex; + flex-direction: column; + align-items: center; + } + + #pose-object-mapping select { + width: 100%; + } + + #pose-object-mapping td { + text-align: right; + } + + #footer { + width: 100%; + padding: 30px; + display: flex; + justify-content: center; + gap: 10px; + background-color: white; + } + + #footer a { + color: black; + text-decoration: none; + } + #footer a:visited { + color: black; + } + + + + +
+
OBJECT DETECTION DISPLAY
+
+
+ + + +
+ +
+
+
Detected Objects
+ + + + +
INDEXOBJECTSREGISTER
+
REGISTER
+
+ +
+
Pose Object Register
+ + + + + + + + + + + + + +
Name + +
Pose + +
Object + +
+
REGISTER
+ +
+
+
+ + +
+ + + diff --git a/object-detection-iot/object-detection-iot.html b/object-detection-iot/object-detection-iot.html index 39b3da90..31ea4855 100644 --- a/object-detection-iot/object-detection-iot.html +++ b/object-detection-iot/object-detection-iot.html @@ -1,117 +1,162 @@ - - + if (!this.poseField) { + this.poseField = 'payload'; + $("#node-input-poseField").val("payload"); + } + if (!this.poseFieldType) { + this.poseFieldType = 'msg'; + } + $("#node-input-poseField").typedInput({ + default: 'msg', + types: ['msg','flow','global'], + typeField: $("#node-input-poseFieldType") + }); + + }, + }) + + + + + \ No newline at end of file +

Output

+
+
HTTP Response Payload
+
HTML payload for forwarding to http response node.
+
+ \ No newline at end of file diff --git a/object_detection/object-detection-html.js b/object_detection/object-detection-html.js index b9a083ed..1c468e72 100644 --- a/object_detection/object-detection-html.js +++ b/object_detection/object-detection-html.js @@ -81,6 +81,7 @@ module.exports.code = (config) => { +