목표
이 샘플에서는 Google Vision API를 사용하여 이미지의 얼굴을 인식합니다. 그런 다음 해당 데이터를 사용하여 각 얼굴 주위에 상자를 그려서 얼굴이 정확히 인식되었는지 검증합니다.
비용
이 문서에서는 비용이 청구될 수 있는 Google Cloud구성요소를 사용합니다.
- Cloud Vision
프로젝트 사용량을 기준으로 예상 비용을 산출하려면 가격 계산기를 사용합니다.
시작하기 전에
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Google Cloud Vision API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Google Cloud Vision API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. - 애플리케이션 기본 사용자 인증 정보를 사용할 수 있는 환경을 설정합니다.
-
다음과 같이 언어별로 작업을 수행하고 도구를 설정합니다.
C#
- Google 클라이언트 라이브러리 설치
- Visual Studio 2012/2015를 설치합니다.
Java
- Java 설치
- API 참조
Apache Maven 빌드 시스템을 다운로드하여 설치합니다.
pom.xml에 Google API 클라이언트 라이브러리와 Vision API 클라이언트 라이브러리가 포함되어 있기 때문에 Maven은 프로젝트가 빌드될 때 이러한 라이브러리가 설치되도록 합니다....
Node.js
- Google 클라이언트 라이브러리 설치
- node.js를 설치합니다.
- API 참조
npm 및 node-canvas를 설치합니다. 샘플 코드에는
npm install명령어를 사용하여 모든 종속 항목을 설치하는package.json이 포함되어 있습니다. node-canvas의 추가 종속 항목을 설치해야 할 수 있습니다. 자세한 내용은 node-canvas 설치 문서를 참고하세요.
PHP
- Google 클라이언트 라이브러리 설치
- PHP 및 Composer 설치
- API 참조
- PHP용 GD를 설치하고 사용 설정합니다.
Python
- Google 클라이언트 라이브러리 설치
- Python을 설치합니다.
- API 참조
- pillow를 설치합니다.
Ruby
- Google 클라이언트 라이브러리 설치
- Ruby 및 Bundler 설치
- API 참조
- ImageMagick을 설치합니다.
서비스 객체 만들기
공식 클라이언트 SDK를 사용하여 Google API에 액세스하려면 API를 SDK에 설명하는 API의 탐색 문서를 기반으로 서비스 객체를 만듭니다. 탐색 문서는 Vision API의 검색 서비스에서 사용자 인증 정보를 사용하여 가져와야 합니다.
Java