Skip to content

Commit

Permalink
Merge pull request #20 from tmobile/unable-to-set-name
Browse files Browse the repository at this point in the history
Add name default
  • Loading branch information
jbondpk authored Jul 21, 2020
2 parents 53ce4b4 + 08430bf commit a6ce322
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion yolo-object-detection.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
category: 'function',
color: '#a6bbcf',
defaults: {
detectionServerPort: {value:"8885"}
detectionServerPort: {value:"8888"},
name: {value:""}
},
inputs:1,
outputs:1,
Expand Down
13 changes: 8 additions & 5 deletions yolo-object-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,18 @@ module.exports = (RED) => {
port: '8888',
method: 'POST',
headers: {
'Content-Length': Buffer.byteLength(msg.payload)
}
}

try {
JSON.parse()
let requestBody = null
if (msg.payload['video-frame'] === true) {
requestBody = JSON.stringify(msg.payload)
options.headers['Content-Type'] = 'application/json'
options.headers['Content-Length'] = requestBody.length
node.debug('Forwarding JSON payload')
} catch (e) {
} else {
requestBody = msg.payload
options.headers['Content-Length'] = Buffer.byteLength(requestBody)
node.debug('Forwarding raw image payload')
}

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

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

0 comments on commit a6ce322

Please sign in to comment.