forked from krishnac7/IotImageAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflows.json
executable file
·1 lines (1 loc) · 4.26 KB
/
flows.json
1
[{"id":"6f4186f8.bddf48","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"f92d07f0.5716a8","type":"function","z":"6f4186f8.bddf48","name":"Process results","func":"result=[];\nmsg.result.images[0].classifiers.forEach(function(current_value, index, initial_array) {\n current_value.classes.forEach(function(current_value,index,initial_array){\n result.push(current_value.class);\n });\n });\nmsg.verbal=result.toString();\nreturn msg;","outputs":1,"noerr":0,"x":548.8933410644531,"y":364.6071472167969,"wires":[["d2c11b1d.2c8438"]]},{"id":"eaa3633c.aa8be8","type":"http in","z":"6f4186f8.bddf48","name":"","url":"/upload","method":"get","upload":false,"swaggerDoc":"","x":121.42855834960938,"y":158.57147216796875,"wires":[["7e303a9.e4e57c4"]]},{"id":"7e303a9.e4e57c4","type":"template","z":"6f4186f8.bddf48","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<center>\n <h1>Upload an image here:</h1>\n<form action=\"/uploadsimple_post\" method=\"POST\" enctype=\"multipart/form-data\">\n <input type=\"file\" name=\"myFile\" />\n <input type=\"submit\" value=\"Submit\">\n</form>\n</center>","output":"str","x":324.2858581542969,"y":165.71426391601562,"wires":[["7fd5b38d.55ca84"]]},{"id":"7fd5b38d.55ca84","type":"http response","z":"6f4186f8.bddf48","name":"","x":484.2858581542969,"y":165.71426391601562,"wires":[]},{"id":"a4d56e30.ee88f","type":"http response","z":"6f4186f8.bddf48","name":"","statusCode":"","headers":{},"x":1043.7501220703125,"y":571.25,"wires":[]},{"id":"eb80106f.0a91d8","type":"template","z":"6f4186f8.bddf48","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<center>\n<h1>Image Analysed!</h1>\n<pre>\n{{{payload}}}\n</pre>\n<h4>Classification results:</h4>\n<p>{{verbal}}</p>\n<h1>{{action}}</h1>\n</center>","output":"str","x":959.385009765625,"y":504.80169677734375,"wires":[["a4d56e30.ee88f"]]},{"id":"2194c99b.44dec6","type":"function","z":"6f4186f8.bddf48","name":"process image output","func":"if (msg.req.files[0].mimetype.includes('image')) {\n msg.payload = `<img src=\"data:image/gif;base64,${msg.payload.toString('base64')}\">`;\n} else {\n msg.payload = msg.payload.toString();\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":773.5359497070312,"y":447.0357666015625,"wires":[["eb80106f.0a91d8","1fada4d7.59cb2b"]]},{"id":"6f7166ba.1b3db","type":"http in","z":"6f4186f8.bddf48","name":"","url":"/uploadsimple_post","method":"post","upload":true,"swaggerDoc":"","x":133.57144165039062,"y":251.60714721679688,"wires":[["212a39c5.6e21ae"]]},{"id":"212a39c5.6e21ae","type":"change","z":"6f4186f8.bddf48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"req.files[0].buffer","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":133.9287109375,"y":351.0713806152344,"wires":[["1240e8c1.41c977"]]},{"id":"1240e8c1.41c977","type":"visual-recognition-v3","z":"6f4186f8.bddf48","name":"","apikey":"OH3F3mALHm3EsdFOPjlclIDDVy1sweMw25TqrsmPTFL4","vr-service-endpoint":"https://gateway.watsonplatform.net/visual-recognition/api","image-feature":"classifyImage","lang":"en","x":332.2859191894531,"y":383.21429443359375,"wires":[["f92d07f0.5716a8"]]},{"id":"d2c11b1d.2c8438","type":"function","z":"6f4186f8.bddf48","name":"trigger action","func":"if (msg.verbal.includes(\"fire\")){\n msg.action=\"Fire Detected:Triggering Fire rescue\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":739.2859497070312,"y":334.2856750488281,"wires":[["2194c99b.44dec6"]]},{"id":"1fada4d7.59cb2b","type":"switch","z":"6f4186f8.bddf48","name":"","property":"action","propertyType":"msg","rules":[{"t":"cont","v":"Fire","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":975.71435546875,"y":417.1428527832031,"wires":[["5eb452e0.a4ef94"]]},{"id":"bad497eb.ea80c8","type":"ibmiot out","z":"6f4186f8.bddf48","authentication":"boundService","apiKey":"","outputType":"evt","deviceId":"sprinkler1","deviceType":"fireSafety","eventCommandType":"Fire","format":"json","data":"0","qos":0,"name":"IBM IoT","service":"registered","x":1200,"y":220,"wires":[]},{"id":"5eb452e0.a4ef94","type":"function","z":"6f4186f8.bddf48","name":"","func":"var msg;\nmsg.payload=\"1\";\nreturn msg;","outputs":1,"noerr":0,"x":1110,"y":340,"wires":[["bad497eb.ea80c8"]]}]