Skip to content

Commit

Permalink
add reminder for Google OCR api key
Browse files Browse the repository at this point in the history
  • Loading branch information
MulongXie committed Jul 8, 2021
1 parent 22de48f commit 56a6245
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 50 deletions.
27 changes: 14 additions & 13 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand Down
72 changes: 36 additions & 36 deletions data/output/ocr/30800.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
Expand Down
Binary file modified detect_text/__pycache__/ocr.cpython-35.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion detect_text/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56a6245

Please sign in to comment.