*[구글 클라우드] Vision API 사용하기
(1) GCP에서 프로젝트 생성
(2) GCP에서 compute engine 생성 (VM인스턴스)
(3) GCP에서 Vision API 검색 후 추가
(4) compute engine 에서 서비스 계정키 생성 (json 파일로)
(5) 서버에 접속할 클라이언트 환경에서 서비스 계정키 등록
export GOOGLE_APPLICATION_CREDENTIALS=서비스계정path
(6) 클라이언트 환경에서 아래 파이썬 코드를 실행 (끝)
import io def detect_text(path): from google.cloud import vision 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 return texts image_path = "/Users/mezzaninegwak/html/x_1_resized.jpg" result = detect_text(image_path) print(result)
반응형
'스타트업 > 프로그래밍' 카테고리의 다른 글
[프로그래밍] pip 와 pip3 차이 (0) | 2020.09.07 |
---|---|
[프로그래밍] Xcode (0) | 2020.09.07 |
[프로그래밍] echo 명령어 (0) | 2020.09.07 |
[프로그래밍] Mac [Homebrew] & [파이썬3 설치] & [가상환경] & [VSCode에 연결] (0) | 2020.09.07 |
[프로그래밍] 구글 클라우드 방화벽 설정 (0) | 2020.09.04 |