Head vs breakz
[code] - 이미지에서 글씨 찾기 구글 API / windows에서 본문
from google.cloud import vision
import os,io
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='구글에서받은.json'
# def detect_text(path):
client = vision.ImageAnnotatorClient()
with io.open(path, 'rb') as image_file:
content = image_file.read()
image = vision.types.Image(content=content)
response = client.text_detection(image=image)
texts = response.text_annotations
print(texts)
for text in texts:
print("{}".format(text.description))
file_name ='C:/Users/82107/Desktop/project/Images/final_image/circle_gray/3752.jpg'
detect_text(file_name)
이미지에서 글씨 추출을 위한 google API를 검색해서 진행하다보면, GOOGLE_APPLICATION_CREDENTIALS 문제를 만나게 되서 다양한 방법을 해보았다. 결국은 os.environ을 통해 code내에서 해결하는 방법이 현재 상황에서 가장 깔끔하게 해결 되었다.
'Head > Code' 카테고리의 다른 글
[code] - 카카오 호텔 방 배정 python (0) | 2020.05.02 |
---|---|
[code] - 카카오 크레인 인형뽑기 python (0) | 2020.05.02 |
[code] - 이미지에서 색상 투명화 하기 (0) | 2020.04.16 |
[code] - OpenCV GrabCut (0) | 2020.04.16 |
[code] - 백준 수학 1193,2869,10250,2775,1712,2839,2292 python (0) | 2020.04.08 |
Comments