node-red-contrib-axis-host
Version:
Axis Devices resource binding nodes that provides access to events, image capture and analytics data. Node-RED must be running on the Axis Device.
1,869 lines • 61.9 kB
JSON
[
{
"id": "6cd8c9cef39f26e5",
"type": "tab",
"label": "Object Detections",
"disabled": false,
"info": "",
"env": []
},
{
"id": "1ddcd7e82f091363",
"type": "group",
"z": "6cd8c9cef39f26e5",
"name": "Settings",
"style": {
"stroke": "#000000",
"fill": "#ffffbf",
"label": true,
"color": "#000000"
},
"nodes": [
"6d36971f0f2fb48e",
"b8688d966caeb9be",
"21b564d78a9ada45",
"032b01562151de42",
"2d4e0bc63430147a",
"80440ce89cca58e2",
"e1e893fe9e21b469",
"84347ca31bd0fbd5",
"0bc679ad08ad0038",
"2a54d3a98af3bd25",
"caab7ba07f21b455",
"c5d8dc45129240fb",
"cff55e6938c5e0b8",
"ad81651d8c9cdfc0",
"4533a8f67081b32a",
"f755be52df411272",
"69c622324ea57d37",
"4768786745fc9ba5",
"d49c277a8d41416b",
"db4442277ea0ae47",
"f67d2a1d2c3784b3",
"dd5fef0c26dc79b8",
"1364ce68bef7a5e3",
"96bfc98c126f1957"
],
"x": 234,
"y": 1039,
"w": 1012,
"h": 422
},
{
"id": "a1741066688385a8",
"type": "group",
"z": "6cd8c9cef39f26e5",
"name": "Output",
"style": {
"stroke": "#000000",
"fill": "#e3f3d3",
"label": true,
"color": "#000000"
},
"nodes": [
"722ea9b2d6f8d275",
"0f30912545622fa2",
"0c2f8daeff2372e9",
"badd13ccc0f620e9",
"e76830976048f8e2"
],
"x": 234,
"y": 299,
"w": 872,
"h": 162
},
{
"id": "850399c5ecf9ce16",
"type": "group",
"z": "6cd8c9cef39f26e5",
"name": "Dashboard",
"style": {
"stroke": "#000000",
"fill": "#bfdbef",
"label": true,
"color": "#000000"
},
"nodes": [
"1ae44e38633a0f2a",
"ca65b80ff15d7668",
"78030e8ebd1a46c1",
"6fca1a9b56c5c791",
"bb71f05c152ab99b",
"36a4e63834d161af"
],
"x": 234,
"y": 499,
"w": 722,
"h": 262
},
{
"id": "22a8ea23b057580f",
"type": "group",
"z": "6cd8c9cef39f26e5",
"name": "Initialization",
"style": {
"stroke": "#000000",
"fill": "#ffffbf",
"label": true,
"color": "#000000"
},
"nodes": [
"4bd6486c1b4622bc",
"4f36dad842504bfe",
"955b4ec822d1bcb0",
"e3e8f29b286e9946",
"81c28fd5d3ef2778",
"3c3d6f74214bfc5d",
"6aae6ef869513976",
"5771a7f6d28b9939",
"8420f8bd0979f1c0",
"f544c988c382b8ef"
],
"x": 234,
"y": 799,
"w": 1052,
"h": 202
},
{
"id": "9e1df9c3cf6849e3",
"type": "group",
"z": "6cd8c9cef39f26e5",
"name": "Exceptions",
"style": {
"stroke": "#000000",
"fill": "#ffbfbf",
"label": true,
"color": "#000000"
},
"nodes": [
"4229e7987ce2dacc",
"352b2423e005e626",
"a00b261b9dc58fb6",
"ad601df6252c9e22"
],
"x": 234,
"y": 1499,
"w": 642,
"h": 142
},
{
"id": "56e12c58ba8403c7",
"type": "group",
"z": "6cd8c9cef39f26e5",
"name": "Initialization",
"style": {
"stroke": "#000000",
"fill": "#ffffbf",
"label": true,
"color": "#001f60"
},
"nodes": [
"199f45646233e510",
"1c4e1d492d30ce71",
"2acc683e2c458989",
"30d6c4f5cc6c5f7c",
"04fb6bfc534625e2",
"7e51975d95c3f37e",
"481df78367b41c8d",
"7038f5200630dd91",
"735864ffa90628bf",
"f7a62fc594b58285"
],
"x": 224,
"y": 39,
"w": 882,
"h": 222
},
{
"id": "cff55e6938c5e0b8",
"type": "junction",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"x": 1220,
"y": 1080,
"wires": [
[
"673b3c1b43f120fe"
]
]
},
{
"id": "69c622324ea57d37",
"type": "junction",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"x": 980,
"y": 1380,
"wires": [
[
"8e3c9a59332544b4"
]
]
},
{
"id": "d5217a6963e60d8d",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "detections",
"mode": "link",
"links": [
"a74567f7ba3805e7"
],
"x": 1335,
"y": 340,
"wires": []
},
{
"id": "a74567f7ba3805e7",
"type": "link in",
"z": "6cd8c9cef39f26e5",
"name": "Visualize",
"links": [
"8e3c9a59332544b4",
"d5217a6963e60d8d"
],
"x": 55,
"y": 620,
"wires": [
[
"bb71f05c152ab99b"
]
]
},
{
"id": "cd359efacf579037",
"type": "inject",
"z": "6cd8c9cef39f26e5",
"name": "On start",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "5",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 880,
"wires": [
[
"4bd6486c1b4622bc"
]
]
},
{
"id": "14e454fa4561bbe2",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "detections",
"info": "",
"x": 1240,
"y": 340,
"wires": []
},
{
"id": "fb906578bf8348b5",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "Initialized",
"mode": "link",
"links": [
"5ca96a16b0f3eac4"
],
"x": 1455,
"y": 840,
"wires": []
},
{
"id": "154620d4b0954c13",
"type": "link in",
"z": "6cd8c9cef39f26e5",
"name": "Update Settings",
"links": [
"120bb69251b64132",
"673b3c1b43f120fe"
],
"x": 65,
"y": 960,
"wires": [
[
"6aae6ef869513976"
]
]
},
{
"id": "3e4844c9f58d598c",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Init",
"info": "",
"x": 1350,
"y": 840,
"wires": []
},
{
"id": "120bb69251b64132",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "link out 24",
"mode": "link",
"links": [
"154620d4b0954c13"
],
"x": 1135,
"y": 620,
"wires": []
},
{
"id": "44024d3c15bd5e18",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Update",
"info": "",
"x": 150,
"y": 960,
"wires": []
},
{
"id": "5ca96a16b0f3eac4",
"type": "link in",
"z": "6cd8c9cef39f26e5",
"name": "link in 33",
"links": [
"fb906578bf8348b5"
],
"x": 65,
"y": 1080,
"wires": [
[
"84347ca31bd0fbd5"
]
]
},
{
"id": "673b3c1b43f120fe",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "Settings updated",
"mode": "link",
"links": [
"154620d4b0954c13"
],
"x": 1415,
"y": 1080,
"wires": []
},
{
"id": "ce81bdb2d7c221ce",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Init",
"info": "",
"x": 150,
"y": 1080,
"wires": []
},
{
"id": "f8d05ca58dba8540",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Updated",
"info": "",
"x": 1320,
"y": 1080,
"wires": []
},
{
"id": "770017e96a3c5ca3",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Visualize",
"info": "",
"x": 160,
"y": 620,
"wires": []
},
{
"id": "8e3c9a59332544b4",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "aoi",
"mode": "link",
"links": [
"a74567f7ba3805e7"
],
"x": 1415,
"y": 1380,
"wires": []
},
{
"id": "ff04881884865579",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Updated",
"info": "",
"x": 1040,
"y": 620,
"wires": []
},
{
"id": "c2e2d89a95e2a0bf",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Visualize",
"info": "",
"x": 1320,
"y": 1380,
"wires": []
},
{
"id": "2fbcdee8fd6e32e9",
"type": "link in",
"z": "6cd8c9cef39f26e5",
"name": "link in 34",
"links": [
"6e8ad04ab8324c4c"
],
"x": 65,
"y": 840,
"wires": [
[
"4bd6486c1b4622bc"
]
]
},
{
"id": "6e8ad04ab8324c4c",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "Start",
"mode": "link",
"links": [
"2fbcdee8fd6e32e9"
],
"x": 1125,
"y": 540,
"wires": []
},
{
"id": "46ef0190c29adc4b",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Start",
"info": "",
"x": 1040,
"y": 540,
"wires": []
},
{
"id": "4fd6c3678d6d9f18",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Start",
"info": "",
"x": 150,
"y": 840,
"wires": []
},
{
"id": "6d36971f0f2fb48e",
"type": "ui_numeric",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"label": "Age",
"tooltip": "",
"group": "0a6ced67777de145",
"order": 2,
"width": 0,
"height": 0,
"wrap": false,
"passthru": false,
"topic": "topic",
"topicType": "msg",
"format": "{{value}}s",
"min": 0,
"max": 10,
"step": "0.5",
"className": "",
"x": 750,
"y": 1160,
"wires": [
[
"21b564d78a9ada45"
]
]
},
{
"id": "b8688d966caeb9be",
"type": "ui_numeric",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"label": "Distance",
"tooltip": "",
"group": "0a6ced67777de145",
"order": 4,
"width": 0,
"height": 0,
"wrap": false,
"passthru": false,
"topic": "topic",
"topicType": "msg",
"format": "{{value}}%",
"min": 0,
"max": "100",
"step": "5",
"className": "",
"x": 760,
"y": 1200,
"wires": [
[
"032b01562151de42"
]
]
},
{
"id": "21b564d78a9ada45",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "settings.age",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1040,
"y": 1160,
"wires": [
[
"cff55e6938c5e0b8"
]
]
},
{
"id": "032b01562151de42",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "settings.distance",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1030,
"y": 1200,
"wires": [
[
"cff55e6938c5e0b8"
]
]
},
{
"id": "2d4e0bc63430147a",
"type": "ui_dropdown",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "Classes",
"label": "Classes",
"tooltip": "",
"place": "Select detection",
"group": "0a6ced67777de145",
"order": 3,
"width": 0,
"height": 0,
"passthru": false,
"multiple": true,
"options": [
{
"label": "Human",
"value": "Human",
"type": "str"
},
{
"label": "Head",
"value": "Head",
"type": "str"
},
{
"label": "Bag",
"value": "Bag",
"type": "str"
},
{
"label": "Car",
"value": "Car",
"type": "str"
},
{
"label": "Truck",
"value": "Truck",
"type": "str"
},
{
"label": "Bus",
"value": "Bus",
"type": "str"
},
{
"label": "Bike",
"value": "Bike",
"type": "str"
},
{
"label": "Vehicle",
"value": "Vehicle",
"type": "str"
},
{
"label": "LicensePlate",
"value": "License plate",
"type": "str"
},
{
"label": "Animal",
"value": "Animal",
"type": "str"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 760,
"y": 1120,
"wires": [
[
"80440ce89cca58e2"
]
]
},
{
"id": "80440ce89cca58e2",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "settings.classes",
"pt": "flow",
"to": "payload",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1030,
"y": 1120,
"wires": [
[
"cff55e6938c5e0b8"
]
]
},
{
"id": "e1e893fe9e21b469",
"type": "ui_dropdown",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "Confidence",
"label": "Min confidence",
"tooltip": "",
"place": "Select detection",
"group": "0a6ced67777de145",
"order": 5,
"width": 0,
"height": 0,
"passthru": false,
"multiple": false,
"options": [
{
"label": "10",
"value": 10,
"type": "num"
},
{
"label": "20",
"value": 20,
"type": "num"
},
{
"label": "30",
"value": 30,
"type": "num"
},
{
"label": "40",
"value": 40,
"type": "num"
},
{
"label": "50",
"value": 50,
"type": "num"
},
{
"label": "60",
"value": 60,
"type": "num"
},
{
"label": "70",
"value": 70,
"type": "num"
},
{
"label": "80",
"value": 80,
"type": "num"
},
{
"label": "90",
"value": 90,
"type": "num"
}
],
"payload": "",
"topic": "topic",
"topicType": "msg",
"className": "",
"x": 770,
"y": 1080,
"wires": [
[
"4768786745fc9ba5"
]
]
},
{
"id": "84347ca31bd0fbd5",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "settings",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 350,
"y": 1080,
"wires": [
[
"0bc679ad08ad0038",
"2a54d3a98af3bd25",
"caab7ba07f21b455",
"c5d8dc45129240fb",
"d49c277a8d41416b",
"dd5fef0c26dc79b8"
]
]
},
{
"id": "0bc679ad08ad0038",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "confidence",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.confidence",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 590,
"y": 1080,
"wires": [
[
"e1e893fe9e21b469"
]
]
},
{
"id": "2a54d3a98af3bd25",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "classes",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.classes",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 1120,
"wires": [
[
"2d4e0bc63430147a"
]
]
},
{
"id": "caab7ba07f21b455",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "age",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.age",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 570,
"y": 1160,
"wires": [
[
"6d36971f0f2fb48e"
]
]
},
{
"id": "c5d8dc45129240fb",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "distance",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.distance",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 1200,
"wires": [
[
"b8688d966caeb9be"
]
]
},
{
"id": "ad81651d8c9cdfc0",
"type": "ui_button",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"group": "0a6ced67777de145",
"order": 6,
"width": 0,
"height": 0,
"passthru": false,
"label": "Area of Intrest",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 340,
"y": 1380,
"wires": [
[
"4533a8f67081b32a"
]
]
},
{
"id": "4533a8f67081b32a",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "settings.aoi",
"tot": "flow"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "aoi",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 640,
"y": 1380,
"wires": [
[
"69c622324ea57d37"
]
]
},
{
"id": "f755be52df411272",
"type": "ui_button",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"group": "0a6ced67777de145",
"order": 8,
"width": 0,
"height": 0,
"passthru": false,
"label": "Save",
"tooltip": "",
"color": "",
"bgcolor": "green",
"className": "",
"icon": "",
"payload": "false",
"payloadType": "bool",
"topic": "save",
"topicType": "str",
"x": 650,
"y": 1420,
"wires": [
[
"69c622324ea57d37"
]
]
},
{
"id": "4768786745fc9ba5",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "set flow.settings.confidence",
"func": "var settings = flow.get(\"settings\");\nsettings.confidence = parseInt(msg.payload);\nflow.set(\"settings\", settings);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1020,
"y": 1080,
"wires": [
[
"cff55e6938c5e0b8"
]
]
},
{
"id": "722ea9b2d6f8d275",
"type": "Objects",
"z": "6cd8c9cef39f26e5",
"g": "a1741066688385a8",
"version": "1",
"output": "1",
"confidence": "20",
"rotation": "0",
"cog": "0",
"idle": "9999999",
"x": 320,
"y": 340,
"wires": [
[
"0f30912545622fa2"
]
]
},
{
"id": "0f30912545622fa2",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "a1741066688385a8",
"name": "Detections filter",
"func": "\nvar settings = flow.get(\"settings\");\nif(!settings)\n return;\n\nvar list = [];\n\nmsg.payload.forEach( function(item){\n if (item.confidence < settings.confidence)\n return;\n if( item.age < settings.age)\n return;\n var dx = (item.cx - item.bx);\n dx = dx * dx;\n var dy = (item.cy - item.by);\n dy = dy * dy;\n item.distance = parseInt(Math.sqrt(dx+dy)/10);\n if( item.distance < settings.distance )\n return;\n\n var classMatch = false;\n settings.classes.forEach(function (element) {\n if (element === item.class)\n classMatch = true;\n if( item.class === \"Face\" && element === \"Head\")\n classMatch = true;\n });\n if (!classMatch)\n return;\n if( settings.aoi ) {\n if( item.cx < settings.aoi.x1 )\n return;\n if (item.cx > settings.aoi.x2)\n return;\n if (item.cy < settings.aoi.y1)\n return;\n if (item.cy > settings.aoi.y2)\n return;\n } \n list.push(item);\n});\n\n\nmsg.payload = list;\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 340,
"wires": [
[
"d5217a6963e60d8d",
"0c2f8daeff2372e9",
"badd13ccc0f620e9"
]
]
},
{
"id": "1ae44e38633a0f2a",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "850399c5ecf9ce16",
"name": "",
"rules": [
{
"t": "set",
"p": "settings.aoi",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 840,
"y": 620,
"wires": [
[
"120bb69251b64132"
]
]
},
{
"id": "ca65b80ff15d7668",
"type": "ui_button",
"z": "6cd8c9cef39f26e5",
"g": "850399c5ecf9ce16",
"name": "",
"group": "0a6ced67777de145",
"order": 1,
"width": "3",
"height": "1",
"passthru": true,
"label": "Start",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "topic",
"topicType": "msg",
"x": 310,
"y": 540,
"wires": [
[
"6e8ad04ab8324c4c",
"36a4e63834d161af"
]
]
},
{
"id": "4bd6486c1b4622bc",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "Default settings",
"func": "msg.payload = {\n service: \"ObjectDetections\",\n aoi: {\n id: \"aoi\",\n x1: 200,\n y1: 200,\n x2: 800,\n y2: 800\n },\n age: 2,\n distance: 10,\n confidence: 30,\n classes: [\"Human\", \"Car\"],\n timeout: 5,\n threshold: 1\n}\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 340,
"y": 840,
"wires": [
[
"4f36dad842504bfe"
]
]
},
{
"id": "4f36dad842504bfe",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "flow.settings",
"rules": [
{
"t": "set",
"p": "settings",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 840,
"wires": [
[
"955b4ec822d1bcb0"
]
]
},
{
"id": "955b4ec822d1bcb0",
"type": "file in",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "",
"filename": "sdcard/ObjectDetections.json",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 800,
"y": 840,
"wires": [
[
"e3e8f29b286e9946"
]
]
},
{
"id": "e3e8f29b286e9946",
"type": "json",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 1030,
"y": 840,
"wires": [
[
"81c28fd5d3ef2778"
]
]
},
{
"id": "81c28fd5d3ef2778",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "flow.settings",
"rules": [
{
"t": "set",
"p": "settings",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1190,
"y": 840,
"wires": [
[
"fb906578bf8348b5"
]
]
},
{
"id": "3c3d6f74214bfc5d",
"type": "catch",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "",
"scope": [
"955b4ec822d1bcb0"
],
"uncaught": false,
"x": 320,
"y": 920,
"wires": [
[
"6aae6ef869513976"
]
]
},
{
"id": "6aae6ef869513976",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "flow.settings",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "settings",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 470,
"y": 960,
"wires": [
[
"f544c988c382b8ef"
]
]
},
{
"id": "5771a7f6d28b9939",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "pretty",
"func": "msg.payload = JSON.stringify(msg.payload,null,2);\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 810,
"y": 960,
"wires": [
[
"8420f8bd0979f1c0"
]
]
},
{
"id": "8420f8bd0979f1c0",
"type": "file",
"z": "6cd8c9cef39f26e5",
"g": "22a8ea23b057580f",
"name": "",
"filename": "sdcard/ObjectDetections.json",
"filenameType": "str",
"appendNewline": false,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 1050,
"y": 960,
"wires": [
[]
]
},
{
"id": "0c2f8daeff2372e9",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "a1741066688385a8",
"name": "Presence counter",
"func": "if( msg.changes === null )\n return;\n\nvar device = global.get(\"device\");\nif(!device) {\n node.error(\"Missing global.device. Check Readme\",msg);\n return;\n}\nvar settings = flow.get(\"settings\");\nif(!settings) {\n node.error(\"Missing global.device.camera. Check Readme\",msg);\n return;\n}\n\nvar counter = flow.get(\"detectionsCounter\") || 0;\nif( msg.payload.length === counter )\n return;\ncounter = msg.payload.length;\nflow.set(\"detectionsCounter\",counter);\nmsg.topic = \"presence/counter/\" + device.serial;\nmsg.payload = counter;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 790,
"y": 380,
"wires": [
[
"c90125ffad0ffa14"
]
]
},
{
"id": "badd13ccc0f620e9",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "a1741066688385a8",
"name": "Presence state",
"func": "var threshold = flow.get(\"settings\").threshold || 1;\n\nif (msg.payload.length < threshold)\n return;\n\nmsg.delay = flow.get(\"settings\").timeout * 1000;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 420,
"wires": [
[
"e76830976048f8e2"
]
]
},
{
"id": "e76830976048f8e2",
"type": "trigger",
"z": "6cd8c9cef39f26e5",
"g": "a1741066688385a8",
"name": "",
"op1": "true",
"op2": "false",
"op1type": "bool",
"op2type": "bool",
"duration": "5",
"extend": true,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1020,
"y": 420,
"wires": [
[
"b4b8dfefc7d0bfa6"
]
]
},
{
"id": "c90125ffad0ffa14",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "counter",
"mode": "link",
"links": [
"babfce46e9a9ec7d"
],
"x": 1335,
"y": 380,
"wires": []
},
{
"id": "6bf096cf4f7bc061",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "counter",
"info": "",
"x": 1230,
"y": 380,
"wires": []
},
{
"id": "d49c277a8d41416b",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "timeout",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.timeout",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 1240,
"wires": [
[
"db4442277ea0ae47"
]
]
},
{
"id": "db4442277ea0ae47",
"type": "ui_numeric",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"label": "Presence transition",
"tooltip": "",
"group": "0a6ced67777de145",
"order": 7,
"width": 0,
"height": 0,
"wrap": false,
"passthru": false,
"topic": "topic",
"topicType": "msg",
"format": "{{value}}s",
"min": 0,
"max": "100",
"step": "1",
"className": "",
"x": 790,
"y": 1240,
"wires": [
[
"f67d2a1d2c3784b3"
]
]
},
{
"id": "f67d2a1d2c3784b3",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "settings.timeout",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1030,
"y": 1240,
"wires": [
[
"cff55e6938c5e0b8"
]
]
},
{
"id": "78030e8ebd1a46c1",
"type": "ui_text",
"z": "6cd8c9cef39f26e5",
"g": "850399c5ecf9ce16",
"group": "b5eeb4d37fc39c53",
"order": 2,
"width": "4",
"height": "1",
"name": "",
"label": "Counter",
"format": "{{msg.payload}}",
"layout": "row-spread",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 320,
"y": 680,
"wires": []
},
{
"id": "babfce46e9a9ec7d",
"type": "link in",
"z": "6cd8c9cef39f26e5",
"name": "link in 36",
"links": [
"c90125ffad0ffa14"
],
"x": 55,
"y": 680,
"wires": [
[
"78030e8ebd1a46c1"
]
]
},
{
"id": "91660a0d3e252c30",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "Counter",
"info": "",
"x": 150,
"y": 680,
"wires": []
},
{
"id": "14685b79c35069f4",
"type": "link in",
"z": "6cd8c9cef39f26e5",
"name": "link in 37",
"links": [
"b4b8dfefc7d0bfa6"
],
"x": 55,
"y": 720,
"wires": [
[
"6fca1a9b56c5c791"
]
]
},
{
"id": "f8471281b2277b07",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "State",
"info": "",
"x": 150,
"y": 720,
"wires": []
},
{
"id": "6fca1a9b56c5c791",
"type": "ui_text",
"z": "6cd8c9cef39f26e5",
"g": "850399c5ecf9ce16",
"group": "b5eeb4d37fc39c53",
"order": 1,
"width": "4",
"height": "1",
"name": "",
"label": "Presence",
"format": "{{msg.payload}}",
"layout": "row-spread",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 320,
"y": 720,
"wires": []
},
{
"id": "b4b8dfefc7d0bfa6",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "state",
"mode": "link",
"links": [
"14685b79c35069f4"
],
"x": 1335,
"y": 420,
"wires": []
},
{
"id": "9359346033e2b4f4",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "state",
"info": "",
"x": 1230,
"y": 420,
"wires": []
},
{
"id": "4229e7987ce2dacc",
"type": "catch",
"z": "6cd8c9cef39f26e5",
"g": "9e1df9c3cf6849e3",
"name": "",
"scope": null,
"uncaught": true,
"x": 340,
"y": 1540,
"wires": [
[
"352b2423e005e626",
"a00b261b9dc58fb6"
]
]
},
{
"id": "352b2423e005e626",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "9e1df9c3cf6849e3",
"name": "Message",
"func": "msg.topic = \"ObjectDetections\";\nmsg.payload = msg.error;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 1540,
"wires": [
[
"ad601df6252c9e22",
"7d02503caadfee8c"
]
]
},
{
"id": "a00b261b9dc58fb6",
"type": "debug",
"z": "6cd8c9cef39f26e5",
"g": "9e1df9c3cf6849e3",
"name": "debug 198",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "error",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 550,
"y": 1600,
"wires": []
},
{
"id": "ad601df6252c9e22",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "9e1df9c3cf6849e3",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.message",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 770,
"y": 1600,
"wires": [
[
"dcfe023d5af848bf"
]
]
},
{
"id": "dcfe023d5af848bf",
"type": "ui_toast",
"z": "6cd8c9cef39f26e5",
"position": "dialog",
"displayTime": "3",
"highlight": "",
"sendall": true,
"outputs": 1,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "",
"name": "",
"x": 1000,
"y": 1600,
"wires": [
[]
]
},
{
"id": "ff5d490cd67a3943",
"type": "comment",
"z": "6cd8c9cef39f26e5",
"name": "exceptions",
"info": "",
"x": 970,
"y": 1540,
"wires": []
},
{
"id": "7d02503caadfee8c",
"type": "link out",
"z": "6cd8c9cef39f26e5",
"name": "exceptions",
"mode": "link",
"links": [],
"x": 1065,
"y": 1540,
"wires": []
},
{
"id": "dd5fef0c26dc79b8",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "threshold",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.threshold",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 1280,
"wires": [
[
"1364ce68bef7a5e3"
]
]
},
{
"id": "1364ce68bef7a5e3",
"type": "ui_numeric",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"label": "Presence threshold",
"tooltip": "",
"group": "0a6ced67777de145",
"order": 7,
"width": 0,
"height": 0,
"wrap": false,
"passthru": false,
"topic": "topic",
"topicType": "msg",
"format": "{{value}} objects",
"min": "1",
"max": "10",
"step": "1",
"className": "",
"x": 790,
"y": 1280,
"wires": [
[
"96bfc98c126f1957"
]
]
},
{
"id": "96bfc98c126f1957",
"type": "change",
"z": "6cd8c9cef39f26e5",
"g": "1ddcd7e82f091363",
"name": "",
"rules": [
{
"t": "set",
"p": "settings.threshold",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1030,
"y": 1280,
"wires": [
[
"cff55e6938c5e0b8"
]
]
},
{
"id": "36a4e63834d161af",
"type": "function",
"z": "6cd8c9cef39f26e5",
"g": "850399c5ecf9ce16",
"name": "Init",
"func": "msg.topic = \"init\";\nmsg.payload = {\n aspect: \"16:9\",\n rotation: 0,\n resolution: \"1280x720\"\n}\n\nvar camera = global.get(\"camera\");\nif ( camera ) {\n msg.payload.aspect = camera.aspect;\n msg.payload.rotation = camera.rotation;\n msg.payload.resolution = camera.largest;\n}\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 580,
"wires": [
[
"bb71f05c152ab99b"
]
]
},
{
"id": "bb71f05c152ab99b",
"type": "ui_template",
"z": "6cd8c9cef39f26e5",
"g": "850399c5ecf9ce16",
"group": "b5eeb4d37fc39c53",
"name": "Visualization",
"order": 6,
"width": "16",
"height": "16",
"format": "<link rel=\"stylesheet\" href=\"/css/imgareaselect-default.css\">\n<script src=\"/js/jquery.imgareaselect.js\"></script>\n<script src=\"/js/media-stream-player.min.js\"></script>\n\n<div id=\"{{'view_'+$id}}\" style=\"width:800px; height:450px;\">\n <div style=\"width:100%; height:100%; position:relative\">\n <div id=\"{{'video_'+$id}}\" style=\"width:100%; height:100%; position:absolute; top:0px; left:0px;\"></div>\n <canvas id=\"{{'canvas_'+$id}}\" width=\"1000\" height=\"1000\" style=\"width:100%; height:100%; position:absolute; top:0px; left:0px;\"></canvas>\n </div>\n</div>\n\n\n<script>\nvar imageWidth = 800;\nvar imageHeight = 450;\nvar pathList = [];\nvar trackers = {};\nvar selectArea = null;\nvar selectionType = \"None\";\nvar ctx = null;\n\n(function(scope) {\n scope.$watch('msg', function(msg) {\n if( !msg || !msg.topic )\n return;\n console.log(msg.topic);\n\n switch( msg.topic ) {\n case \"init\":\n if( selectArea ) {\n selectArea.setOptions({hide: true});\n selectArea = null;\n }\n ClearCanvas();\n init(scope,msg.payload);\n break;\n\n case \"detections\":\n drawDetections( msg.payload );\n break;\n\n case \"tracker\":\n drawTracker( msg.payload );\n break;\n\n case \"path\":\n drawPath( msg.payload );\n break;\n\n case \"singlePath\":\n ClearCanvas();\n drawPath( msg.payload );\n break;\n\n case \"paths\":\n ClearCanvas();\n pathList = msg.payload;\n msg.payload.forEach(function(path){\n drawPath( path );\n });\n break;\n\n case \"reset\":\n case \"clear\":\n case \"save\":\n ClearCanvas();\n if( selectArea ) {\n selectArea.setOptions({hide: true});\n delete selectArea;\n selectArea = null;\n }\n break;\n\n case \"aoi\":\n case \"birth\":\n case \"death\":\n selectionType = msg.topic;\n if( selectArea ) {\n selectArea.setOptions({hide: true});\n delete selectArea;\n selectArea = null;\n }\n var x1 = parseInt(msg.payload.x1 / 1000 * imageWidth);\n var x2 = parseInt(msg.payload.x2 / 1000 * imageWidth);\n var y1 = parseInt(msg.payload.y1 / 1000 * imageHeight);\n var y2 = parseInt(msg.payload.y2 / 1000 * imageHeight);\n selectArea = $(\"#view_\"+scope.$id).imgAreaSelect( {\n x1:x1, y1:y1, x2:x2, y2:y2,\n show: true, hide:false, minHeight: 5, minWidth: 5, handles: true, movable: true, resizable: true, instance:true,\n onSelectEnd: function( image, area ) {\n var area = {\n id: selectionType,\n x1: parseInt((area.x1/imageWidth) * 1000),\n x2: parseInt((area.x2/imageWidth) * 1000),\n y1: parseInt((area.y1/imageHeight) * 1000