node-red-contrib-oscar-segmentation-data
Version:
Segmentation Data Service
380 lines • 14.4 kB
JSON
{
"id": "bb066c573be5a9b9",
"type": "subflow",
"name": "Segmentation Service",
"info": "<main>\r\n <section>\r\n <article>\r\n <h3>About Segmentation </h3>\r\n <p>Video segmentation is the process of dividing videos into multiple regions based on certain characteristics, such as object boundaries, motion, color, texture, or other visual characteristics.</p>\r\n </article>\r\n <article>\r\n <h3>About Segmentation Data Service in OSCAR</h3>\r\n <p>It segments a video into audios of n seconds (configurable when creating the ser-vice) and extracts frames within the video every n seconds. Therefore, it generates an X (video duration in seconds divided by n) amount of audio in MP3 format and frames in JPEG format that will serve as input for the two subsequent services implemented. In addition, it will connect to an MQTT broker and publish in a topic (segmentation/part) the amount of audio and frames generated. </p>\r\n <p>For more information consult:</p>\r\n <ul>\r\n <li>\r\n <a rel=\"stylesheet\" href=\"\"> Segmentation Data Service </a>\r\n </li>\r\n </ul>\r\n </article>\r\n <article>\r\n <h3>Inputs</h3>\r\n <p>This takes the OSCAR cluster credentials (set as input parameters to the node) and makes a GET request to the service (segmentation service node), using the OSCAR API (/system/services/serviceName), obtaining all the service data. These elements extract the credentials from the service’s MinIO input bucket (extract minio features node). From there, with the Object Operations, the video is uploaded in the MinIO input bucket), invoking the service. The creation of the Segmentation Data node makes this entire process transparent for users, who are only responsible for composing the flow\r\nand entering the OSCAR cluster credentials. In the processing stage, the user does not intervene; everything is carried out through the composition and execution of the OSCAR services in the cloud cluster. As the services execute, they publish the results of the execution of the services in MQTT topics.</p>\r\n </article>\r\n <article>\r\n <h3>Outputs</h3>\r\n <p> The node does not return anything.</p>\r\n </article>\r\n </section>\r\n</main>\r\n<footer>\r\n GryCAP\r\n</footer>",
"category": "",
"in": [
{
"x": 60,
"y": 160,
"wires": [
{
"id": "59063a66127d9eb6"
}
]
}
],
"out": [
{
"x": 1220,
"y": 260,
"wires": [
{
"id": "8dc658023bad8bfc",
"port": 0
}
]
}
],
"env": [
{
"name": "Server",
"type": "str",
"value": ""
},
{
"name": "Service Name",
"type": "str",
"value": ""
},
{
"name": "User",
"type": "str",
"value": ""
},
{
"name": "Password",
"type": "cred"
},
{
"name": "Object Name",
"type": "str",
"value": ""
}
],
"meta": {
"module": "node-red-contrib-oscar-segmentation-data",
"version": "0.1.3",
"author": "Vicente Rodriguez Benitez <vicente.rdguezb@gmail.com, vrodben1@i3m.upv.es>",
"desc": "Segmentation Data Service for OSCAR",
"keywords": "node-red, upv, grycap, segmentation data service, segmentation data service, oscar",
"license": "Apache-2.0"
},
"credentials": {
"Password": ""
},
"color": "#3FADB5",
"icon": "font-awesome/fa-file-video-o",
"status": {
"x": 1220,
"y": 80,
"wires": [
{
"id": "66612ca25bfad62a",
"port": 0
},
{
"id": "7c8d1325c3d9a1dd",
"port": 0
}
]
},
"flow": [
{
"id": "59063a66127d9eb6",
"type": "change",
"z": "bb066c573be5a9b9",
"name": "",
"rules": [
{
"t": "set",
"p": "oscar_server",
"pt": "msg",
"to": "Server",
"tot": "env"
},
{
"t": "set",
"p": "username",
"pt": "msg",
"to": "User",
"tot": "env"
},
{
"t": "set",
"p": "pass",
"pt": "msg",
"to": "Password",
"tot": "env"
},
{
"t": "set",
"p": "video",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "service",
"pt": "msg",
"to": "Service Name",
"tot": "env"
},
{
"t": "set",
"p": "archive",
"pt": "msg",
"to": "Object Name",
"tot": "env"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 180,
"y": 160,
"wires": [
[
"66612ca25bfad62a",
"28eec741b7c9954c"
]
]
},
{
"id": "66612ca25bfad62a",
"type": "change",
"z": "bb066c573be5a9b9",
"name": "Start Service",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Processing...",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 410,
"y": 80,
"wires": [
[]
]
},
{
"id": "28eec741b7c9954c",
"type": "function",
"z": "bb066c573be5a9b9",
"name": "Load Log",
"func": "msg.payload = {\n \"username\": msg.username,\n \"password\": msg.pass\n}\nmsg.url = msg.oscar_server + \"/system/services/\" + msg.service;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 400,
"y": 180,
"wires": [
[
"1cdf6fb3d7ca9bc8"
]
]
},
{
"id": "1cdf6fb3d7ca9bc8",
"type": "change",
"z": "bb066c573be5a9b9",
"name": "",
"rules": [
{
"t": "set",
"p": "headers",
"pt": "msg",
"to": "{\t \"Authorization\": 'Basic ' & $base64encode(\t payload.username & ':' & payload.password\t ) \t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 180,
"wires": [
[
"40b862e1357554d9"
]
]
},
{
"id": "40b862e1357554d9",
"type": "http request",
"z": "bb066c573be5a9b9",
"name": "segmentation service",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": true,
"authType": "basic",
"senderr": true,
"headers": [],
"x": 720,
"y": 180,
"wires": [
[
"53056bea5718440b"
]
]
},
{
"id": "53056bea5718440b",
"type": "json",
"z": "bb066c573be5a9b9",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 830,
"y": 180,
"wires": [
[
"c4afa05bbc6ed141"
]
]
},
{
"id": "c4afa05bbc6ed141",
"type": "function",
"z": "bb066c573be5a9b9",
"name": "extract features",
"func": "var services = msg.payload\nvar name = services.name;\nvar token_service;\nvar bucket_input\nvar bucket_output = [];\nvar bucket_providers = [];\nvar providers = [];\nif (msg.service == name) {\n token_service = services.token\n bucket_input = services.input[0].path;\n if (services.output.length > 1) {\n for (var ii = 0; ii < services.output.length; ii++) {\n bucket_output[ii] = services.output[ii].path;\n bucket_providers[ii] = services.output[ii].storage_provider;\n }\n }\n else {\n bucket_output[0] = services.output[0].path;\n bucket_providers[0] = services.output[0].storage_provider;\n }\n providers = services.storage_providers.minio;\n}\nelse {\n msg.payload = \"ERROR\"\n}\nmsg.token_service = token_service;\nmsg.bucket_input = bucket_input;\nmsg.bucket_out = bucket_output;\nmsg.bucket_providers = bucket_providers;\nmsg.providers = providers;\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 260,
"wires": [
[
"59da22a4fc1b5b39"
]
]
},
{
"id": "59da22a4fc1b5b39",
"type": "function",
"z": "bb066c573be5a9b9",
"name": "extract minio features",
"func": "var input = msg.bucket_input\nvar output = msg.bucket_out\nvar service = msg.payload;\n\nif (msg.archive != \"\") {\n msg.objectName = input.substring(input.indexOf(\"/\") + 1) + \"/\" + msg.archive + \".mpg\"\n global.set(\"name\", msg.archive)\n}\nelse {\n msg.objectName = input.substring(input.indexOf(\"/\") + 1) + \"/video.mpg\"\n global.set(\"name\", msg.archive)\n}\nmsg.bucketName = input.substring(0, input.indexOf(\"/\"))\nmsg.stream = msg.video;\nmsg.operation = \"putObject\";\n\nmsg.name = \"Minio Rasp\"\nmsg.endPoint = \"minio.\" + msg.oscar_server;\n\nmsg.port = 443\nmsg.useSsl = true;\n\nvar credentials = {\n accessKey: service.storage_providers.minio.default.access_key,\n secretKey: service.storage_providers.minio.default.secret_key\n\n};\nmsg.credentials = credentials;\nmsg.test = msg.credentials.accessKey;\n\nif (!msg.credentials || !msg.credentials.accessKey || !msg.credentials.secretKey) {\n node.error(\"Las credenciales de MinIO no están correctamente definidas\");\n return null;\n}\n\nreturn msg\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 260,
"wires": [
[
"8dc658023bad8bfc"
]
]
},
{
"id": "8dc658023bad8bfc",
"type": "objects",
"z": "bb066c573be5a9b9",
"objects_name": "",
"host": "54a24153b23f8c49",
"objects_operation": "putObject",
"objects_bucket": "",
"objects_object": "",
"objects_offset": "",
"objects_length": "",
"objects_stream": "",
"objects_size": "",
"objects_metadata": "",
"objects_sourceobject": "",
"objects_conditions": "",
"objects_objectslist": [],
"objects_prefix": "",
"objects_etag": "",
"objects_datetime": "",
"x": 910,
"y": 260,
"wires": [
[
"7c8d1325c3d9a1dd"
],
[]
]
},
{
"id": "7c8d1325c3d9a1dd",
"type": "change",
"z": "bb066c573be5a9b9",
"name": "End Service",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Finished...",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1050,
"y": 120,
"wires": [
[]
]
},
{
"id": "11eac2c5c64b674a",
"type": "minio-config",
"z": "bb066c573be5a9b9",
"name": "MinIO Instance",
"host": "minio.graspi.im.grycap.net",
"port": "443",
"useSsl": true
},
{
"id": "54a24153b23f8c49",
"type": "minio-config",
"z": "bb066c573be5a9b9",
"name": "MinIO-Raspi",
"host": "minio.graspi.im.grycap.net",
"port": "443",
"useSsl": true
},
{
"id": "89d91b91ca1b220b",
"type": "subflow:bb066c573be5a9b9",
"z": "676912fe7a55b352",
"name": "",
"x": 460,
"y": 1100,
"wires": [
[]
]
}
]
}