2016-06-02 6 views
0

Google Cloud Vision API에서 얼굴 인식 예제를 실행하려고합니다. 나는 [faces.py here] [1]을 (를) 실행하려고합니다.Google의 Cloud Vision API를 실행하는 중에 오류가 발생했습니다. (얼굴 인식)

나는 다음과 실행하면 :

faces.py 데모-picture.jpg 대신

아래

되어 내가 오류 :

[email protected]:~/Documents/code/python- stuff/googleapis/cloudvisionapi/cloud-vision/python/face_detection$ python  faces.py demo-image.jpg 
Traceback (most recent call last): 
    File "faces.py", line 121, in <module> 
    main(args.input_image, args.output, args.max_results) 
    File "faces.py", line 98, in main 
    faces = detect_face(image, max_results) 
    File "faces.py", line 62, in detect_face 
    service = get_vision_service() 
    File "faces.py", line 35, in get_vision_service 
    credentials = GoogleCredentials.get_application_default() 
    File "/home/ubuntu/.local/lib/python2.7/site-  packages/oauth2client/client.py", line 1398, in get_application_default 
    return GoogleCredentials._get_implicit_credentials() 
    File "/home/ubuntu/.local/lib/python2.7/site- packages/oauth2client/client.py", line 1388, in _get_implicit_credentials 
    raise ApplicationDefaultCredentialsError(ADC_HELP_MSG) 
oauth2client.client.ApplicationDefaultCredentialsError: The Application  Default Credentials are not available. They are available if running in Google  Compute Engine. Otherwise, the environment variable  GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the  credentials. See https://developers.google.com/accounts/docs/application- default-credentials for more information. 
[email protected]:~/Documents/code/python- stuff/googleapis/cloudvisionapi/cloud-vision/python/face_detection$ 
    [1]: https://github.com/GoogleCloudPlatform/cloud- vision/tree/master/python/face_detection 

내 질문은 생각 - - 어떻게해야합니까?

그렇지 않으면 환경 변수 GOOGLE_APPLICATION_CREDENTIALS가 자격 증명을 정의하는 파일을 가리 키도록 정의되어야합니다.

답변

0

서비스 계정 키를 다운로드해야합니다. 일반적으로 JSON 파일입니다. 자격 증명을 만들지 않았거나 키를 얻은 경우 다음 단계를 따르십시오.

API 관리자로 이동하십시오.
자격 증명을 만듭니다.
"서비스 계정 키"를 선택하십시오.
"키 유형"을 JSON으로 선택하십시오.

이 후에는 JSON 파일을 받아야합니다.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/JSON

그런 다음 얼굴을 다시 실행 지금 exec bash

하여 떠들썩한 파티를 다시 시작 : 당신이 키를 얻으면

, 다음 (~/.bashrc에) 당신의 bashrc에 이동 및 추가 .py.

+0

줄'export ...'줄이'~/.bashrc' 파일의 끝 부분에 있어야합니까? – user1406716

+0

일반적으로 ~/.bashrc에 추가하는 모든 추가/사용자 정의 행이 끝까지 이동합니다. 그러나 그것은 당신에게 달려 있습니다. –

관련 문제