본문 바로가기

Google Cloud Vision Api (2)-설정

한번 써볼려고 구글api 콘솔을 갔더니 이미지나 바이너리기 때문에 업로드 공간이 있어야 되서 그런지

Google cloud Storage를 생성 하란다.


그래서 생성할려고 가봤더니 기본 결제를 설정하란다.


아휴.. 항상 하나에 하나가 꼬리를 물고 꼬리를 물고 빙빙 돌아돌아오면 겨우 제자리 스타트가 되고

귀찮고 불편하다.


아무튼



결제 사용 설정에 들어가서 새 결제 계정을 만들고 나서 다시 돌아온 화면인다

Vision API를 쓸려면 저 버킷키가 필요하다 버킷을 만들려면 Google Cloud 를 설정해야 하고

Google Cloud를 설정할려면 결제 사용설정을 해야 하고 꼬리에 꼬리를 물고 블라블라 투덜 투덜


아무튼 새결제 계정을 만들고 다시 위 화면으로 돌아오면 결제 사용 설정을 재차 눌러서 새로 생성한

계정을 선택한다





선택을 하면 위 처럼 왼쪽에 위치하던 결제 계정 설정은 사라지고 버킷 만들기만 노출 된다.





만드는거야 간단하고 어렵지 않으니 메뉴얼도 안보고 그냥 대충 만든다.



만들고 난뒤의 화면이다. 먼지 이게..


Google Cloud Vision Api 샘플 깃 주소다.

https://github.com/GoogleCloudPlatform/cloud-vision


여기 받아서 php 코드의 creds.php를 보면 여기에 Bucket을 적는란이 있다.


위에 적어논 버킷 이름을 여기에 적어준다.


버킷과 apikey를 적어줘야 하는데 적어주고 웹서버에 올려서 열어보면 500 Internal Server Error가 난다.


왜냐면 스토리지에 올릴 AppSDK for PHP가 없기 때문이다.


앱SDK는 https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP

여기에서 받을 수 있다 난 리눅스 서버라서 리눅스 버전을 받았다.



설치방법 : 다운로드 페이지에 설명이 되어 있다.

To install on Linux:

  1. Unzip the App Engine PHP file you downloaded (google_appengine_1.9.33.zip). For example:
    unzip google_appengine_1.9.33.zip 

    There is no App Engine installation script that you need to run after unzipping the files.

  2. Add the google_appengine directory to your PATH:
    export PATH="$PATH:/path/to/google_appengine/"
  3. Make sure Python 2.7 is installed on your machine using the following command:
    /usr/bin/env python -V
    The output should look like this: Python 2.7.<number>. If Python 2.7 isn't installed, install it now using the installation instructions for your Linux distribution.
  4. Build and install the PHP interpreter and App Engine PHP extension. Specify the path to php-cgi and gae_runtime_module.so when running the development server.
  5. Install MySQL on your local machine. (You will need this to test your app locally.) On Debian-based Linux systems, you can use the following command:
    sudo apt-get install mysql-server-5.5

    You will be prompted to enter a password for the MySQL root user; make sure that you remember it.


한글로 풀어 쓰면

1.압축 파일을 풀고

2.패스 설정하고

3.파이썬 버전을 확인하여 2.7이상인지 보고

4.빌드 및 인스톨해라

5.MySQL 설치해라. -- 있으니 패스


샘플 실행 참조 : http://terrenceryan.com/blog/index.php/working-with-cloud-vision-api-from-php/


--------------------------------------------------------------------------------------------------------------

앱엔진 설치 참조 : http://archive.oreilly.com/pub/a/web-services/excerpts/9780596800697/run-google-app-linux.html

앱엔진 php 설명 : https://cloud.google.com/appengine/docs/php/

https://cloud.google.com/appengine/docs/php/gettingstarted/introduction


--------------------------------------------------------------------------------------------------------------

아 앱엔진 때문에 쓸데업이 엄청난 삽질했네.

결과적으로 필요 없다.


아무튼 사진을 넣으면 어디에 있는 곳인지 이름은 뭔지 위치는 어딘지 알려준다.

허허 재밌겠는데 이거