From 56a6245b1e6b8c488905260c4700ac1c8ae15bd3 Mon Sep 17 00:00:00 2001 From: MulongXie Date: Thu, 8 Jul 2021 17:53:36 +1000 Subject: [PATCH] add reminder for Google OCR api key --- .idea/workspace.xml | 27 ++++---- README.md | 2 + data/output/ocr/30800.json | 72 ++++++++++----------- detect_text/__pycache__/ocr.cpython-35.pyc | Bin 1205 -> 1354 bytes detect_text/ocr.py | 3 +- 5 files changed, 54 insertions(+), 50 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b00790b..292cc2e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -31,7 +31,7 @@ - + @@ -223,7 +223,8 @@ - + + @@ -245,31 +246,31 @@ - + - - + + - - + + - - + + - - + + - + @@ -336,7 +337,7 @@ - + diff --git a/README.md b/README.md index d4f3ead..c0e29c8 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ UIED comprises two parts to detect UI text and graphic elements, such as button, The new version of UIED equipped with Google OCR is easy to deploy and no pre-trained model is needed. Simply donwload the repo along with the dependencies. +> Please replace the Google OCR key at `detect_text/ocr.py line 28` with your own (apply in https://cloud.google.com/vision) + ### Usage To test your own image(s): * To test single image, change *input_path_img* in ``run_single.py`` to your input image and the results will be output to *output_root*. diff --git a/data/output/ocr/30800.json b/data/output/ocr/30800.json index af68e57..534c70d 100644 --- a/data/output/ocr/30800.json +++ b/data/output/ocr/30800.json @@ -6,93 +6,93 @@ ], "texts": [ { - "width": 267, - "height": 62, - "id": 0, "column_max": 311, "column_min": 44, - "content": "Relax Night", + "height": 62, "row_min": 52, + "content": "Relax Night", + "width": 267, + "id": 0, "row_max": 114 }, { - "width": 9, - "height": 57, - "id": 1, "column_max": 1027, "column_min": 1018, - "content": ":", + "height": 57, "row_min": 48, + "content": ":", + "width": 9, + "id": 1, "row_max": 105 }, { - "width": 640, - "height": 51, - "id": 2, "column_max": 860, "column_min": 220, - "content": "Brahms Lullaby and crickets", + "height": 51, "row_min": 186, + "content": "Brahms Lullaby and crickets", + "width": 640, + "id": 2, "row_max": 237 }, { - "width": 62, - "height": 50, - "id": 3, "column_max": 565, "column_min": 503, - "content": "7 &", + "height": 50, "row_min": 454, + "content": "7 &", + "width": 62, + "id": 3, "row_max": 504 }, { - "width": 298, - "height": 55, - "id": 4, "column_max": 333, "column_min": 35, - "content": "Dog House On", + "height": 55, "row_min": 1620, + "content": "Dog House On", + "width": 298, + "id": 4, "row_max": 1675 }, { - "width": 235, - "height": 38, - "id": 5, "column_max": 300, "column_min": 65, - "content": "The Prairie .", + "height": 38, "row_min": 1675, + "content": "The Prairie .", + "width": 235, + "id": 5, "row_max": 1713 }, { - "width": 58, - "height": 43, - "id": 6, "column_max": 559, "column_min": 501, - "content": "Dog", + "height": 43, "row_min": 1612, + "content": "Dog", + "width": 58, + "id": 6, "row_max": 1655 }, { - "width": 523, - "height": 81, - "id": 7, "column_max": 1080, "column_min": 557, - "content": "boarding dog's home and away Dog training home . YUIX from .", + "height": 81, "row_min": 1608, + "content": "boarding dog's home and away Dog training home . YUIX from .", + "width": 523, + "id": 7, "row_max": 1689 }, { - "width": 167, - "height": 29, - "id": 8, "column_max": 853, "column_min": 686, - "content": "facebook.com", + "height": 29, "row_min": 1687, + "content": "facebook.com", + "width": 167, + "id": 8, "row_max": 1716 } ] diff --git a/detect_text/__pycache__/ocr.cpython-35.pyc b/detect_text/__pycache__/ocr.cpython-35.pyc index cd101e8aa4f2220315a3e91194679f7175832a73..e1ceca5fd29ef66eaa7e2c337bb117599a0b8fcc 100644 GIT binary patch delta 309 zcmY+7u};G<6h)ui1ZW^kAjtLxBxr^Nm?~BV77&OsF;Jq|YE9DEa$MRV5J(jxlNSag z{s4)ApI~F{2k-~%q-+fLF6ZdpkLIW6t@*w;dHcS6b>F=XB`@}Zo*fw%SQ91$$gK-k zb1(s59s~lQM0>2_8s(_KtwgE3LQ!Df z7*+1Yahl5^i+X>PQ7Q-VwJ3!wTG*)H?NeiOV}9xwG2m0TR?|$c0Dx}Rb?zuxnyIU_ cDC}3GOV;gKH3k$4Po&W#< delta 150 zcmX@bwUv`goR^nN?#BIu2P_-8f|(d6O^#yHq)$ diff --git a/detect_text/ocr.py b/detect_text/ocr.py index b66764d..2149ebd 100644 --- a/detect_text/ocr.py +++ b/detect_text/ocr.py @@ -25,13 +25,14 @@ def Google_OCR_makeImageData(imgpath): def ocr_detection_google(imgpath): start = time.clock() url = 'https://vision.googleapis.com/v1/images:annotate' - api_key = 'AIzaSyDUc4iOUASJQYkVwSomIArTKhE2C6bHK8U' + api_key = 'AIzaSyDUc4iOUASJQYkVwSomIArTKhE2C6bHK8U' # *** Replace with your own Key *** imgdata = Google_OCR_makeImageData(imgpath) response = requests.post(url, data=imgdata, params={'key': api_key}, headers={'Content_Type': 'application/json'}) # print('*** Text Detection Time Taken:%.3fs ***' % (time.clock() - start)) + print("*** Please replace the Google OCR key at detect_text/ocr.py line 28 with your own (apply in https://cloud.google.com/vision) ***") if response.json()['responses'] == [{}]: # No Text return None