Created
February 24, 2016 05:24
-
-
Save utaani/9eee22ccdb7283ac11f7 to your computer and use it in GitHub Desktop.
Google Cloud Vision OCR test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "b9814cc7.854288", | |
"type": "template", | |
"z": "cec74554.ecbe", | |
"name": "JSON template", | |
"field": "payloadrule", | |
"fieldType": "msg", | |
"format": "json", | |
"syntax": "plain", | |
"template": "{\n \"requests\":[\n {\n \"image\":{\n \"content\":\"base64-encoded-file-data\"\n },\n \"features\":[\n {\n \"type\":\"TEXT_DETECTION\",\n \"maxResults\":1\n }\n ],\n \"imageContext\": {\n \"languageHints\": [\n \"en\"\n ]\n }\n }\n ]\n}", | |
"x": 357, | |
"y": 382, | |
"wires": [ | |
[ | |
"75f29394.9ec6ac" | |
] | |
] | |
}, | |
{ | |
"id": "f1d904d.52a44f8", | |
"type": "http in", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"url": "/gcvuploaderpost", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 166, | |
"y": 194, | |
"wires": [ | |
[ | |
"beda337a.453d58", | |
"11231db8.92097a" | |
] | |
] | |
}, | |
{ | |
"id": "10e643e0.6e26c4", | |
"type": "http response", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"x": 746, | |
"y": 660, | |
"wires": [] | |
}, | |
{ | |
"id": "beda337a.453d58", | |
"type": "debug", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "false", | |
"x": 430, | |
"y": 196.5, | |
"wires": [] | |
}, | |
{ | |
"id": "11231db8.92097a", | |
"type": "function", | |
"z": "cec74554.ecbe", | |
"name": "multipart splitter (file in first part only)", | |
"func": "var mpart=new Buffer(msg.payload.length);\nvar bpart=new Buffer(msg.payload.length);\n\n// skip header to bpart (after \\r\\n\\r\\n)\nvar spos=0;\nfor(var i=0; i<msg.payload.length; i++) {\n mpart[i]=msg.payload.readInt8(i);\n if(mpart[i]==10 && mpart[i-1]==13 && mpart[i-2]==10 && mpart[i-3]==13) {\n spos=i+1;\n }\n}\nmpart.copy(bpart,0,spos);\n\n// drop fooder to msg.payload (before \\r\\n--)\nvar epos=0;\nfor(var i=0; i<bpart.length; i++) {\n mpart[i]=bpart.readInt8(i);\n if(mpart[i]==45 && mpart[i-1]==45 && mpart[i-2]==10 && mpart[i-3]==13) {\n epos=i-3;\n break;\n }\n}\nmsg.payload=new Buffer(epos);\nmpart.copy(msg.payload,0,0,epos);\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 319, | |
"y": 262, | |
"wires": [ | |
[ | |
"52b05767.7efdc", | |
"bf8997c6.b998b" | |
] | |
] | |
}, | |
{ | |
"id": "52b05767.7efdc", | |
"type": "debug", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "false", | |
"x": 773.5, | |
"y": 384, | |
"wires": [] | |
}, | |
{ | |
"id": "30dbd84c.f0123", | |
"type": "http in", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"url": "/gcvup", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 137, | |
"y": 100, | |
"wires": [ | |
[ | |
"5ddb1373.73dc84" | |
] | |
] | |
}, | |
{ | |
"id": "5ddb1373.73dc84", | |
"type": "template", | |
"z": "cec74554.ecbe", | |
"name": "form", | |
"field": "payload", | |
"fieldType": "msg", | |
"format": "html", | |
"syntax": "mustache", | |
"template": "<!DOCTYPE html>\n<html>\n<head>\n<meta name=\"viewport\" content=\"user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;\" />\n</head>\n<body>\n<div class=\"form\">\nUpload Photo\n<form method=\"post\" action=\"gcvuploaderpost\" enctype=\"multipart/form-data\">\n<p><input type=\"file\" name=\"example5\" accept=\"image/jpeg\"></p>\n<p><input type=\"submit\"></p>\n</div>\n</form>\n</body>\n</html>", | |
"x": 320, | |
"y": 100, | |
"wires": [ | |
[ | |
"d7180415.b6842" | |
] | |
] | |
}, | |
{ | |
"id": "d7180415.b6842", | |
"type": "http response", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"x": 525, | |
"y": 100, | |
"wires": [] | |
}, | |
{ | |
"id": "9737bc4f.a5563", | |
"type": "comment", | |
"z": "cec74554.ecbe", | |
"name": "Uploader form", | |
"info": "", | |
"x": 138, | |
"y": 52, | |
"wires": [] | |
}, | |
{ | |
"id": "d7af09e6.5de05", | |
"type": "debug", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "payloadrule", | |
"x": 794, | |
"y": 427, | |
"wires": [] | |
}, | |
{ | |
"id": "75f29394.9ec6ac", | |
"type": "change", | |
"z": "cec74554.ecbe", | |
"name": "request body json maker", | |
"rules": [ | |
{ | |
"t": "change", | |
"p": "payloadrule", | |
"pt": "msg", | |
"from": "base64-encoded-file-data", | |
"fromt": "str", | |
"to": "payload", | |
"tot": "msg" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 387, | |
"y": 428, | |
"wires": [ | |
[ | |
"d7af09e6.5de05", | |
"22e577fa.d12da8" | |
] | |
] | |
}, | |
{ | |
"id": "2a6b9a52.d2b906", | |
"type": "http request", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"method": "POST", | |
"ret": "obj", | |
"url": "", | |
"x": 355, | |
"y": 520, | |
"wires": [ | |
[ | |
"3b9e7b8c.b3ee14", | |
"5696f75c.63a58" | |
] | |
] | |
}, | |
{ | |
"id": "22e577fa.d12da8", | |
"type": "change", | |
"z": "cec74554.ecbe", | |
"name": "http request maker", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "payloadrule", | |
"tot": "msg" | |
}, | |
{ | |
"t": "set", | |
"p": "url", | |
"pt": "msg", | |
"to": "https://vision.googleapis.com/v1/images:annotate\\?key=YOUR_GOOGLE_APIKey", | |
"tot": "str" | |
}, | |
{ | |
"t": "set", | |
"p": "headers", | |
"pt": "msg", | |
"to": "\"Content-Type: application/json\"", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 372, | |
"y": 474, | |
"wires": [ | |
[ | |
"2b488937.9b9246", | |
"2a6b9a52.d2b906" | |
] | |
] | |
}, | |
{ | |
"id": "2b488937.9b9246", | |
"type": "debug", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "true", | |
"x": 756, | |
"y": 470, | |
"wires": [] | |
}, | |
{ | |
"id": "3b9e7b8c.b3ee14", | |
"type": "debug", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "false", | |
"x": 777, | |
"y": 516, | |
"wires": [] | |
}, | |
{ | |
"id": "bf8997c6.b998b", | |
"type": "base64", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"x": 341, | |
"y": 336, | |
"wires": [ | |
[ | |
"b9814cc7.854288" | |
] | |
] | |
}, | |
{ | |
"id": "22fe864f.d46c6a", | |
"type": "debug", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "payload", | |
"x": 759, | |
"y": 595, | |
"wires": [] | |
}, | |
{ | |
"id": "5696f75c.63a58", | |
"type": "function", | |
"z": "cec74554.ecbe", | |
"name": "", | |
"func": "msg.payload = msg.payload.responses[0].textAnnotations[0].description\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 557.5, | |
"y": 596.5, | |
"wires": [ | |
[ | |
"22fe864f.d46c6a", | |
"10e643e0.6e26c4" | |
] | |
] | |
}, | |
{ | |
"id": "a7be63d8.da6318", | |
"type": "comment", | |
"z": "cec74554.ecbe", | |
"name": "API post", | |
"info": "", | |
"x": 128.5, | |
"y": 150.5, | |
"wires": [] | |
}, | |
{ | |
"id": "7eaa7e3c.e2ade8", | |
"type": "comment", | |
"z": "cec74554.ecbe", | |
"name": "check your languageHints ->", | |
"info": "", | |
"x": 129, | |
"y": 382, | |
"wires": [] | |
}, | |
{ | |
"id": "952ae6c7.5810f8", | |
"type": "comment", | |
"z": "cec74554.ecbe", | |
"name": "check your APIkey in msg.url ->", | |
"info": "https://cloud.google.com/vision/docs/getting-started#setting_up_an_api_key", | |
"x": 135, | |
"y": 473, | |
"wires": [] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment