[
{
"id": "50a1cbed.f2a044",
"type": "tab",
"label": "Face Recognition Terminal"
},
{
"id": "804423ae.c04088",
"type": "function",
"z": "50a1cbed.f2a044",
"name": "Is this a Celebrity",
"func": "// A function to determine if this image contains a celebrity.\n// Functions can access the msg.result via array indexes\n// Watson Visual Recognition v3 API Documentation is post here:\n// https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/visual-recognition/api/v3/?node#detect_faces\nvar i=0;\nvar Celebrity=0;\nvar CelebrityName=\"No one famous detected\";\n\n// There might be multiple faces in this image.\n// Loop through the faces and determine if Watson has\n// detected the identity of at least one celebrity.\nwhile ( msg.result.images[0].faces[i] ) {\n if (msg.result.images[0].faces[i].identity != null) {\n Celebrity=1;\n CelebrityName=msg.result.images[0].faces[i].identity.name;\n }\n i++;\n}\n\nmsg.payload = CelebrityName;\n// if a Celebrity was found, send the Name to output 1\n// else send the default \"No one famous detected\" to output 2\nif (Celebrity == 1) {\n return [ msg, null ];\n} else {\n return [ null, msg ];\n}\n",
"outputs": "2",
"noerr": 0,
"x": 818,
"y": 218,
"wires": [
[
"80c2c31f.e3e7f"
],
[
"2583337b.d75be4"
]
]
},
{
"id": "2583337b.d75be4",
"type": "debug",
"z": "50a1cbed.f2a044",
"name": "Celebrity detection",
"active": true,
"console": "false",
"complete": "payload",
"x": 1100,
"y": 224,
"wires": []
},
{
"id": "80c2c31f.e3e7f",
"type": "template",
"z": "50a1cbed.f2a044",
"name": "Paparazzi",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "This image contains a celebrity: {{payload}} !",
"x": 972,
"y": 144,
"wires": [
[
"2583337b.d75be4"
]
]
},
{
"id": "29d8aa3d.c8d186",
"type": "visual-recognition-v3",
"z": "50a1cbed.f2a044",
"name": "Face Detection",
"apikey": "Put your API key here",
"image-feature": "detectFaces",
"x": 617,
"y": 294,
"wires": [
[
"7bf1363c.14e078",
"58921d60.63caf4",
"804423ae.c04088"
]
]
},
{
"id": "7bf1363c.14e078",
"type": "debug",
"z": "50a1cbed.f2a044",
"name": "Face Detection result",
"active": true,
"console": "false",
"complete": "true",
"x": 1000,
"y": 290,
"wires": []
},
{
"id": "a14f1e1c.9177e",
"type": "ui_template",
"z": "50a1cbed.f2a044",
"group": "59423245.1e5ba4",
"name": "ImageViewer",
"order": 3,
"width": "6",
"height": "6",
"format": "
\n
\n
",
"storeOutMessages": true,
"fwdInMessages": true,
"x": 1105,
"y": 429,
"wires": [
[]
]
},
{
"id": "4eb2e726.ba32d8",
"type": "base64",
"z": "50a1cbed.f2a044",
"name": "",
"x": 782.5,
"y": 429,
"wires": [
[
"a14f1e1c.9177e"
]
]
},
{
"id": "39cfe80d.855b38",
"type": "ui_template",
"z": "50a1cbed.f2a044",
"group": "59423245.1e5ba4",
"name": "Detection Result",
"order": 0,
"width": "8",
"height": "5",
"format": "",
"storeOutMessages": true,
"fwdInMessages": true,
"x": 1124.5,
"y": 341,
"wires": [
[]
]
},
{
"id": "58921d60.63caf4",
"type": "template",
"z": "50a1cbed.f2a044",
"name": "Report faces via HTML template",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": " {{^result}}\n No Face detected
\n {{/result}}\n Images Processed: {{result.images_processed}}
\n \n Age Range | Confidence | Gender | Confidence | Name |
\n {{#result.images.0.faces}}\n {{age.min}} - {{age.max}} | {{age.score}} | \n {{gender.gender}} | {{gender.score}} | \n {{identity.name}} ({{identity.score}}) | \n
{{/result.images.0.faces}}\n
\n",
"x": 863,
"y": 341,
"wires": [
[
"39cfe80d.855b38"
]
]
},
{
"id": "a7f21d85.db2ba",
"type": "inject",
"z": "50a1cbed.f2a044",
"name": "Test",
"topic": "",
"payload": "",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 134.5,
"y": 334,
"wires": [
[
"5128b3f1.f15364"
]
]
},
{
"id": "b6d130de.cb63a8",
"type": "debug",
"z": "50a1cbed.f2a044",
"name": "COS output",
"active": false,
"console": "false",
"complete": "true",
"x": 559.5,
"y": 241,
"wires": []
},
{
"id": "5128b3f1.f15364",
"type": "cos-get",
"z": "50a1cbed.f2a044",
"name": "Get COS Object",
"bucket": "Your bucket name",
"objectname": "campic.jpg",
"filepath": "",
"filename": "",
"mode": "1",
"cosconfig": "21bc3dd3.475faa",
"x": 373.5,
"y": 293,
"wires": [
[
"b6d130de.cb63a8",
"29d8aa3d.c8d186",
"4eb2e726.ba32d8"
]
]
},
{
"id": "85b214b9.699708",
"type": "ibmiot in",
"z": "50a1cbed.f2a044",
"authentication": "boundService",
"apiKey": "",
"inputType": "evt",
"deviceId": "Enter MAC address here",
"applicationId": "",
"deviceType": "+",
"eventType": "+",
"commandType": "",
"format": "json",
"name": "Laptop event",
"service": "registered",
"allDevices": "",
"allApplications": "",
"allDeviceTypes": true,
"allEvents": true,
"allCommands": "",
"allFormats": "",
"qos": 0,
"x": 110,
"y": 211,
"wires": [
[
"410a44e7.6a702c",
"a7691978.dc0a98"
]
]
},
{
"id": "410a44e7.6a702c",
"type": "debug",
"z": "50a1cbed.f2a044",
"name": "Entire event",
"active": false,
"console": "false",
"complete": "true",
"x": 321.5,
"y": 143,
"wires": []
},
{
"id": "a7691978.dc0a98",
"type": "change",
"z": "50a1cbed.f2a044",
"name": "Set COS Objname",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "campic.jpg",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 379.5,
"y": 200,
"wires": [
[
"5128b3f1.f15364"
]
]
},
{
"id": "aaf75619.7f0be",
"type": "cos-get",
"z": "50a1cbed.f2a044",
"name": "",
"bucket": "Your bucket name",
"objectname": "campic.jpg",
"filepath": "",
"filename": "",
"mode": "1",
"cosconfig": "21bc3dd3.475faa",
"x": 422.5,
"y": 596,
"wires": [
[
"3bc415b.31e736a"
]
]
},
{
"id": "42c04208.c35a24",
"type": "inject",
"z": "50a1cbed.f2a044",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 199.5,
"y": 596,
"wires": [
[
"aaf75619.7f0be"
]
]
},
{
"id": "3bc415b.31e736a",
"type": "debug",
"z": "50a1cbed.f2a044",
"name": "",
"active": true,
"console": "false",
"complete": "true",
"x": 623.5,
"y": 596,
"wires": []
},
{
"id": "865c6314.ef4bd8",
"type": "comment",
"z": "50a1cbed.f2a044",
"name": "Step 1 - Configure Laptop event node",
"info": "1. Double-click the **Laptop event** node\n2. Fill in the MAC address (without colons) into the *Device Id* field",
"x": 177.5,
"y": 93,
"wires": []
},
{
"id": "edc0a30c.40309",
"type": "comment",
"z": "50a1cbed.f2a044",
"name": "Step 2 - Configure Get COS Object Node",
"info": "1. Double-click the **Get COS Object** node\n2. Add new credentials for the Cloud Object Storage service\n2. Fill in your bucket name",
"x": 368.5,
"y": 362,
"wires": []
},
{
"id": "a03f9163.c2973",
"type": "comment",
"z": "50a1cbed.f2a044",
"name": "Step 3 - Configure Face Detection Node",
"info": "1. Double-click the **Face Detection** node\n2. Put in your Watson Visual recognition API key\n3. Select \"Detect Faces\" for the *Detect* drop-down",
"x": 669,
"y": 172,
"wires": []
},
{
"id": "59423245.1e5ba4",
"type": "ui_group",
"z": "",
"name": "Watson visual recognition v3 face detection",
"tab": "978c8a85.2c7d68",
"order": 1,
"disp": true,
"width": "8"
},
{
"id": "21bc3dd3.475faa",
"type": "cos-config",
"z": "",
"key": "Your access key",
"secret": "Your secret access key",
"endpoint": "s3-api.us-geo.objectstorage.softlayer.net",
"name": "Your account"
},
{
"id": "978c8a85.2c7d68",
"type": "ui_tab",
"z": "",
"name": "Face Recognition Terminal",
"icon": "dashboard",
"order": 2
}
]