Skip to content

Commit a6ce322

Browse files
authored
Merge pull request #20 from tmobile/unable-to-set-name
Add name default
2 parents 53ce4b4 + 08430bf commit a6ce322

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

yolo-object-detection.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
category: 'function',
44
color: '#a6bbcf',
55
defaults: {
6-
detectionServerPort: {value:"8885"}
6+
detectionServerPort: {value:"8888"},
7+
name: {value:""}
78
},
89
inputs:1,
910
outputs:1,

yolo-object-detection.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,18 @@ module.exports = (RED) => {
8383
port: '8888',
8484
method: 'POST',
8585
headers: {
86-
'Content-Length': Buffer.byteLength(msg.payload)
8786
}
8887
}
8988

90-
try {
91-
JSON.parse()
89+
let requestBody = null
90+
if (msg.payload['video-frame'] === true) {
91+
requestBody = JSON.stringify(msg.payload)
9292
options.headers['Content-Type'] = 'application/json'
93+
options.headers['Content-Length'] = requestBody.length
9394
node.debug('Forwarding JSON payload')
94-
} catch (e) {
95+
} else {
96+
requestBody = msg.payload
97+
options.headers['Content-Length'] = Buffer.byteLength(requestBody)
9598
node.debug('Forwarding raw image payload')
9699
}
97100

@@ -118,7 +121,7 @@ module.exports = (RED) => {
118121
node.error('Error connecting to model server')
119122
serverStatus = { fill: 'red', shape: 'ring', text: 'disconnected' }
120123
node.status(serverStatus)
121-
}).end(msg.payload)
124+
}).end(requestBody)
122125

123126
// This call is wrapped in a check that 'done' exists
124127
// so the node will work in earlier versions of Node-RED (<1.0)

0 commit comments

Comments
 (0)