-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflows.json
1 lines (1 loc) · 6.04 KB
/
flows.json
1
[{"id":"c2b69313.473ee8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"d21a5024.256688","type":"function","z":"c2b69313.473ee8","name":"filter bicycle","func":"var payload=msg.payload;\n\nvar best_obj = {};\nbest_obj.probability = 0;\nbest_obj.detection_box = [0.0, 0.0, 0.0, 0.0];\nbest_obj.label = 'none'\n\nvar objs = msg.details.predictions;\nfor (i=0;i<objs.length;i++){\n if (objs[i].label == 'bicycle' && (objs[i].probability>0.7)){\n if (objs[i].probability > best_obj.probability){\n best_obj = objs[i];\n }\n// objs[i].label_id = 999;\n\n }\n \n}\n\nmsg.topic = 'bicycle_detection';\nmsg.payload = best_obj;\nreturn msg;","outputs":1,"noerr":0,"x":722.3333740234375,"y":113,"wires":[["b1c58f5f.b39818"]]},{"id":"88a98f47.b583c","type":"vtjbot-shine","z":"c2b69313.473ee8","botId":"adacec12.a5d78","mode":"pulse","color":"aqua","duration":"1","name":"pit","x":1197.833251953125,"y":123.3333740234375,"wires":[]},{"id":"c7287c55.2d4dc8","type":"object-detector","z":"c2b69313.473ee8","service":"279ca546.e2d02a","method":"predict","passthrough":"","annotated_input":true,"predict_body":"","predict_bodyType":"str","predict_threshold":"0.05","predict_thresholdType":"str","name":"bicycle texting detector","x":456,"y":172.5,"wires":[["d21a5024.256688","fe4a35de.115be","18336772.bec1b9"]]},{"id":"332d8ee5.5403a2","type":"vtjbot-see","z":"c2b69313.473ee8","botId":"adacec12.a5d78","mode":"takephoto","returnOnPayload":true,"width":960,"height":720,"name":"image","x":255,"y":172,"wires":[["c7287c55.2d4dc8"]]},{"id":"fe4a35de.115be","type":"function","z":"c2b69313.473ee8","name":"filter person","func":"var payload=msg.payload;\n\nvar best_obj = {};\nbest_obj.probability = 0;\nbest_obj.detection_box = [0.0, 0.0, 0.0, 0.0];\nbest_obj.label = 'none'\n\nvar objs = msg.details.predictions;\nfor (i=0;i<objs.length;i++){\n if (objs[i].label == 'person' && (objs[i].probability>0.7)){\n if (objs[i].probability > best_obj.probability){\n best_obj = objs[i];\n }\n }\n}\n\nmsg.topic = 'person_detection';\nmsg.payload = best_obj;\nreturn msg;","outputs":1,"noerr":0,"x":721,"y":171.5,"wires":[["b1c58f5f.b39818"]]},{"id":"18336772.bec1b9","type":"function","z":"c2b69313.473ee8","name":"filter cell phone","func":"var payload=msg.payload;\n\nvar best_obj = {};\nbest_obj.probability = 0;\nbest_obj.detection_box = [0.0, 0.0, 0.0, 0.0];\nbest_obj.label = 'none'\n\nvar objs = msg.details.predictions;\nfor (i=0;i<objs.length;i++){\n if (objs[i].label == 'cell phone' && (objs[i].probability>0.05)){\n if (objs[i].probability > best_obj.probability){\n best_obj = objs[i];\n }\n }\n}\n\nmsg.topic = 'phone_detection';\nmsg.payload = best_obj;\nreturn msg;","outputs":1,"noerr":0,"x":728,"y":222.5,"wires":[["b1c58f5f.b39818"]]},{"id":"b1c58f5f.b39818","type":"function","z":"c2b69313.473ee8","name":"overlap image","func":"// basic collosion detection, can be improved\n// check if phone and person image overlap or if\n// phone and bicycle image overlap\n\ncontext.data = context.data || {};\nswitch(msg.topic){\n case 'phone_detection':\n context.data.phone = msg.payload;\n msg = null;\n break;\n case 'person_detection':\n context.data.person = msg.payload;\n msg = null;\n break;\n case 'bicycle_detection':\n context.data.bicycle = msg.payload;\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\nfunction collision(A,B){\n // y1, x1, y2 ,x2\n // L, U,R, D\n //[x0,y0,x1,y1]\n if ( A[0] < B[2] &&\n A[2] > B[0] &&\n A[1] < B[3] &&\n A[3] > B[1]) {\n return true;\n } else {\n return false;\n }\n}\n \n\nif ( context.data.phone != null && context.data.person != null && context.data.bicycle != null ){\n if ( context.data.phone.probability == 0 || context.data.person.probability == 0 || context.data.bicycle.probability == 0){\n return null;\n } else {\n if ( collision(context.data.phone.detection_box, context.data.person.detection_box) || \n collision(context.data.phone.detection_box, context.data.bicycle.detection_box) ) {\n msg = {\"_msgid\": \"12345\", \"payload\": \"true\"};\n } else {\n msg = null;\n }\n //msg.payload = true;\n \n return msg;\n }\n\n} else\n return msg;","outputs":1,"noerr":0,"x":953,"y":171.5,"wires":[["88a98f47.b583c","75332cc5.4982c4","8f0a7eae.c59528"]]},{"id":"8f20594f.467088","type":"comment","z":"c2b69313.473ee8","name":"use localhost:5000 for max-object-detector service","info":"","x":195,"y":28,"wires":[]},{"id":"75332cc5.4982c4","type":"vtjbot-wave","z":"c2b69313.473ee8","botId":"adacec12.a5d78","motion":"wave","name":"Wave arm","x":1221,"y":171,"wires":[]},{"id":"8f0a7eae.c59528","type":"vtjbot-speak","z":"c2b69313.473ee8","botId":"adacec12.a5d78","mode":"play","payload":"siren.mp3","name":"siren","x":1206,"y":229,"wires":[[]]},{"id":"b744adb0.50222","type":"inject","z":"c2b69313.473ee8","name":"input_5s","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"onceDelay":"5","x":94,"y":171,"wires":[["332d8ee5.5403a2"]]},{"id":"10281ba5.c337e4","type":"comment","z":"c2b69313.473ee8","name":"read file is for testing a local image","info":"","x":145,"y":64,"wires":[]},{"id":"adacec12.a5d78","type":"vtjbot-config","z":"","botGender":"male","name":"My TJ Officer","speak":"en-GB","hasServo":true,"hasLED":true,"hasSpeaker":true,"hasMicrophone":false,"hasCamera":true,"aUrl":"https://gateway.watsonplatform.net/assistant/api","taUrl":"https://gateway.watsonplatform.net/tone-analyzer/api","ltUrl":"https://gateway.watsonplatform.net/language-translator/api","sttUrl":"https://stream.watsonplatform.net/speech-to-text/api","ttsUrl":"https://stream.watsonplatform.net/text-to-speech/api","vrUrl":"https://gateway.watsonplatform.net/visual-recognition/api"},{"id":"279ca546.e2d02a","type":"object-detector-service","z":"","host":"http://localhost:5000","name":"DOCKER codait/max-object-detector"}]