From 0dc96a2a2684c3394ab90bd054404c3ee4b180bf Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 21 Aug 2018 12:44:14 +0900 Subject: [PATCH] Delete original text detection --- text_detection.py | 48 ----------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 text_detection.py diff --git a/text_detection.py b/text_detection.py deleted file mode 100644 index fb98121..0000000 --- a/text_detection.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -This script uses the Vision API's text detection capabilities to find a text -based on an image's content. - -To run the example, install the necessary libraries by running: - - pip install -r requirements.txt - -Run the script on an image to get text, E.g.: - - ./text_detection.py -""" - -import argparse -import os - -from utils import Service, encode_image - - -def main(photo_file): - """Run a text detection request on a single image""" - - access_token = os.environ.get('VISION_API') - service = Service('vision', 'v1', access_token=access_token) - - with open(photo_file, 'rb') as image: - base64_image = encode_image(image) - body = { - 'requests': [{ - 'image': { - 'content': base64_image, - }, - 'features': [{ - 'type': 'TEXT_DETECTION', - 'maxResults': 1, - }] - - }] - } - response = service.execute(body=body) - text = response['responses'][0]['textAnnotations'][0]['description'] - print('Found text: {}'.format(text)) - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument('image_file', help='The image you\'d like to detect text.') - args = parser.parse_args() - main(args.image_file)