Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def detect_text(path):
- """Detects text in the file."""
- import io, os
- from google.cloud import vision
- import json
- os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = './GoogleVisionKeys.json' # Autentykacja klienta
- client = vision.ImageAnnotatorClient()
- with io.open(path, 'rb') as image_file:
- content = image_file.read()
- image = vision.Image(content=content)
- response = client.text_detection(image=image)
- texts = response.text_annotations
- print(float(texts[0].description))
- if response.error.message:
- raise Exception('{}\nFor more info on error messages, check: ' 'https://cloud.google.com/apis/design/errors'.format(response.error.message))
- return float(texts[0].description)
- detect_text('meter_digits_only.png') # obrazek do detekcji cyferek
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement