이 페이지에서는 Vision API를 사용하여 이미지에서 유명인을 인식하는 방법을 설명합니다.
Vision API를 사용하여 이미지에서 얼굴을 감지할 수 있습니다. 얼굴이 인식되면 Vision API가 얼굴을 Google에서 수집한 유명인의 색인 갤러리와 비교할 수 있습니다.
Vision API는 수천 명의 유명인을 인식할 수 있으며, 전문적으로 촬영된 누구나 알아볼 수 있는 유명인이 나오는 미디어 콘텐츠에서만 사용하기 위한 것입니다.
일치하는 얼굴이 발견되면 Vision API는 유명인의 지식 정보 머신 ID(MID), 이름, 이미지에 얼굴이 표시되는 위치를 나타내는 경계 상자를 제공합니다.
API 액세스 요청
이 기능은 전문적으로 제작된 미디어 콘텐츠에서 미디어 및 엔터테인먼트 회사나 승인을 받은 파트너가 사용하기 위한 것입니다. API 액세스를 요청하려면 이 양식에 회사 및 사용 사례에 대한 정보를 작성하여 제출하세요.
로컬 이미지에 대한 유명인 인식 요청
Vision API를 사용하여 로컬 이미지 파일에서 기능 감지를 수행할 수 있습니다.
REST 요청의 경우 이미지 파일의 콘텐츠를 요청 본문에 base64로 인코딩된 문자열로 보냅니다.
gcloud
및 클라이언트 라이브러리 요청의 경우 요청에 로컬 이미지 경로를 지정합니다.
유명인 인식 요청을 보내려면 먼저 프로젝트에서 이 기능에 대한 액세스 권한을 얻은 후에 기존의 얼굴 인식 기능(FACE_DETECTION
enum)을 사용하세요.
유명인이 인식되면 결과에 유명인 정보가 포함됩니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- BASE64_ENCODED_IMAGE: 바이너리 이미지 데이터의 base64 표현(ASCII 문자열)입니다. 이 문자열은 다음 문자열과 유사하게 표시됩니다.
/9j/4QAYRXhpZgAA...9tAVx/zDQDlGxn//2Q==
- PROJECT_ID: Google Cloud 프로젝트 ID
HTTP 메서드 및 URL:
POST https://vision.googleapis.com/v1p4beta1/images:annotate
JSON 요청 본문:
{ "requests": [ { "image": { "content": "BASE64_ENCODED_IMAGE " }, "features": [ { "type": "FACE_DETECTION" } ], "imageContext": { "faceRecognitionParams": { "celebritySet": ["builtin/default"] } } } ] }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
요청 본문을 request.json
파일에 저장하고 다음 명령어를 실행합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project:PROJECT_ID " \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://vision.googleapis.com/v1p4beta1/images:annotate"
요청 본문을 request.json
파일에 저장하고 다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID " }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://vision.googleapis.com/v1p4beta1/images:annotate" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
응답
{ "responses": [ { "faceAnnotations": [ { "boundingPoly": { "vertices": [ { "x": 203 }, { "x": 570 }, { "x": 570, "y": 368 }, { "x": 203, "y": 368 } ] }, "fdBoundingPoly": { "vertices": [ { "x": 254, "y": 48 }, { "x": 524, "y": 48 }, { "x": 524, "y": 318 }, { "x": 254, "y": 318 } ] }, "landmarks": [ { "type": "LEFT_EYE", "position": { "x": 328.92297, "y": 135.14728, "z": -0.00084506406 } }, { "type": "RIGHT_EYE", "position": { "x": 440.65927, "y": 131.96986, "z": -0.18113805 } }, { "type": "LEFT_OF_LEFT_EYEBROW", "position": { "x": 290.14877, "y": 114.45657, "z": 11.400304 } }, { "type": "RIGHT_OF_LEFT_EYEBROW", "position": { "x": 357.85278, "y": 109.40719, "z": -21.749352 } }, { "type": "LEFT_OF_RIGHT_EYEBROW", "position": { "x": 411.14322, "y": 108.33092, "z": -21.866737 } }, { "type": "RIGHT_OF_RIGHT_EYEBROW", "position": { "x": 480.46622, "y": 110.60321, "z": 11.405331 } }, { "type": "MIDPOINT_BETWEEN_EYES", "position": { "x": 384.6528, "y": 129.57939, "z": -23.62145 } }, { "type": "NOSE_TIP", "position": { "x": 383.5203, "y": 196.91586, "z": -55.91733 } }, { "type": "UPPER_LIP", "position": { "x": 387.36368, "y": 236.28792, "z": -29.9772 } }, { "type": "LOWER_LIP", "position": { "x": 385.20834, "y": 277.3345, "z": -21.621998 } }, { "type": "MOUTH_LEFT", "position": { "x": 341.77988, "y": 248.98514, "z": 0.5651365 } }, { "type": "MOUTH_RIGHT", "position": { "x": 439.91428, "y": 244.32759, "z": 2.6951885 } }, { "type": "MOUTH_CENTER", "position": { "x": 385.44574, "y": 254.93304, "z": -21.696716 } }, { "type": "NOSE_BOTTOM_RIGHT", "position": { "x": 415.55923, "y": 201.68005, "z": -13.386427 } }, { "type": "NOSE_BOTTOM_LEFT", "position": { "x": 354.17462, "y": 205.03098, "z": -12.758772 } }, { "type": "NOSE_BOTTOM_CENTER", "position": { "x": 385.9818, "y": 213.22089, "z": -30.45643 } }, { "type": "LEFT_EYE_TOP_BOUNDARY", "position": { "x": 329.98587, "y": 128.55806, "z": -7.625594 } }, { "type": "LEFT_EYE_RIGHT_CORNER", "position": { "x": 350.25543, "y": 136.96538, "z": 0.3162137 } }, { "type": "LEFT_EYE_BOTTOM_BOUNDARY", "position": { "x": 327.47772, "y": 142.9333, "z": -1.0234838 } }, { "type": "LEFT_EYE_LEFT_CORNER", "position": { "x": 307.4751, "y": 137.34349, "z": 10.214714 } }, { "type": "LEFT_EYE_PUPIL", "position": { "x": 328.45987, "y": 136.19621, "z": -3.1551569 } }, { "type": "RIGHT_EYE_TOP_BOUNDARY", "position": { "x": 440.0691, "y": 126.8801, "z": -7.779711 } }, { "type": "RIGHT_EYE_RIGHT_CORNER", "position": { "x": 464.28534, "y": 135.34042, "z": 10.301969 } }, { "type": "RIGHT_EYE_BOTTOM_BOUNDARY", "position": { "x": 441.76584, "y": 140.32564, "z": -1.2271972 } }, { "type": "RIGHT_EYE_LEFT_CORNER", "position": { "x": 422.21207, "y": 135.32939, "z": 0.33341154 } }, { "type": "RIGHT_EYE_PUPIL", "position": { "x": 441.37714, "y": 134.46259, "z": -3.4412556 } }, { "type": "LEFT_EYEBROW_UPPER_MIDPOINT", "position": { "x": 324.93048, "y": 96.94437, "z": -13.394134 } }, { "type": "RIGHT_EYEBROW_UPPER_MIDPOINT", "position": { "x": 444.3336, "y": 95.093765, "z": -13.487409 } }, { "type": "LEFT_EAR_TRAGION", "position": { "x": 261.2239, "y": 191.10706, "z": 136.27896 } }, { "type": "RIGHT_EAR_TRAGION", "position": { "x": 513.192, "y": 187.88185, "z": 136.99525 } }, { "type": "FOREHEAD_GLABELLA", "position": { "x": 384.6936, "y": 107.73683, "z": -26.120888 } }, { "type": "CHIN_GNATHION", "position": { "x": 388.01538, "y": 322.47537, "z": -6.83534 } }, { "type": "CHIN_LEFT_GONION", "position": { "x": 274.37195, "y": 261.15628, "z": 91.56324 } }, { "type": "CHIN_RIGHT_GONION", "position": { "x": 500.2335, "y": 257.99966, "z": 91.12145 } } ], "rollAngle": -0.8706148, "panAngle": -0.0915068, "tiltAngle": 0.05244069, "detectionConfidence": 0.99914575, "landmarkingConfidence": 0.7713903, "joyLikelihood": "VERY_LIKELY", "sorrowLikelihood": "VERY_UNLIKELY", "angerLikelihood": "VERY_UNLIKELY", "surpriseLikelihood": "VERY_UNLIKELY", "underExposedLikelihood": "VERY_UNLIKELY", "blurredLikelihood": "VERY_UNLIKELY", "headwearLikelihood": "VERY_UNLIKELY", "recognitionResult": [ { "celebrity": { "name": "builtin/celebrity-mid ", "displayName": "celebrity-name " }, "confidence": 0.82625544 } ] } ] } ] }
원격 이미지에 대한 유명인 인식 요청
Vision API를 사용하여 Cloud Storage 또는 웹에 있는 원격 이미지 파일에서 기능 감지를 수행할 수 있습니다. 원격 파일 요청을 보내려면 요청 본문에 파일의 웹 URL 또는 Cloud Storage URI를 지정합니다.
유명인 인식 요청을 보내려면 먼저 프로젝트에서 이 기능에 대한 액세스 권한을 얻은 후에 기존의 얼굴 인식 기능(FACE_DETECTION
enum)을 사용하세요.
유명인이 인식되면 결과에 유명인 정보가 포함됩니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- CLOUD_STORAGE_IMAGE_URI: Cloud Storage 버킷에 있는 유효한 이미지 파일의 경로입니다. 적어도 파일에 대한 읽기 권한이 있어야 합니다.
예를 들면 다음과 같습니다.
gs://my-cloud-bucket/img/celebrity_image.jpg
- PROJECT_ID: Google Cloud 프로젝트 ID
HTTP 메서드 및 URL:
POST https://vision.googleapis.com/v1p4beta1/images:annotate
JSON 요청 본문:
{ "requests": [ { "image": { "source": { "imageUri": "CLOUD_STORAGE_FILE_URI " } }, "features": [ { "type": "FACE_DETECTION" } ], "imageContext": { "faceRecognitionParams": { "celebritySet": ["builtin/default"] } } } ] }
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
요청 본문을 request.json
파일에 저장하고 다음 명령어를 실행합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project:PROJECT_ID " \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://vision.googleapis.com/v1p4beta1/images:annotate"
요청 본문을 request.json
파일에 저장하고 다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID " }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://vision.googleapis.com/v1p4beta1/images:annotate" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
응답
{ "responses": [ { "faceAnnotations": [ { "boundingPoly": { "vertices": [ { "x": 203 }, { "x": 570 }, { "x": 570, "y": 368 }, { "x": 203, "y": 368 } ] }, "fdBoundingPoly": { "vertices": [ { "x": 254, "y": 48 }, { "x": 524, "y": 48 }, { "x": 524, "y": 318 }, { "x": 254, "y": 318 } ] }, "landmarks": [ { "type": "LEFT_EYE", "position": { "x": 328.92297, "y": 135.14728, "z": -0.00084506406 } }, { "type": "RIGHT_EYE", "position": { "x": 440.65927, "y": 131.96986, "z": -0.18113805 } }, { "type": "LEFT_OF_LEFT_EYEBROW", "position": { "x": 290.14877, "y": 114.45657, "z": 11.400304 } }, { "type": "RIGHT_OF_LEFT_EYEBROW", "position": { "x": 357.85278, "y": 109.40719, "z": -21.749352 } }, { "type": "LEFT_OF_RIGHT_EYEBROW", "position": { "x": 411.14322, "y": 108.33092, "z": -21.866737 } }, { "type": "RIGHT_OF_RIGHT_EYEBROW", "position": { "x": 480.46622, "y": 110.60321, "z": 11.405331 } }, { "type": "MIDPOINT_BETWEEN_EYES", "position": { "x": 384.6528, "y": 129.57939, "z": -23.62145 } }, { "type": "NOSE_TIP", "position": { "x": 383.5203, "y": 196.91586, "z": -55.91733 } }, { "type": "UPPER_LIP", "position": { "x": 387.36368, "y": 236.28792, "z": -29.9772 } }, { "type": "LOWER_LIP", "position": { "x": 385.20834, "y": 277.3345, "z": -21.621998 } }, { "type": "MOUTH_LEFT", "position": { "x": 341.77988, "y": 248.98514, "z": 0.5651365 } }, { "type": "MOUTH_RIGHT", "position": { "x": 439.91428, "y": 244.32759, "z": 2.6951885 } }, { "type": "MOUTH_CENTER", "position": { "x": 385.44574, "y": 254.93304, "z": -21.696716 } }, { "type": "NOSE_BOTTOM_RIGHT", "position": { "x": 415.55923, "y": 201.68005, "z": -13.386427 } }, { "type": "NOSE_BOTTOM_LEFT", "position": { "x": 354.17462, "y": 205.03098, "z": -12.758772 } }, { "type": "NOSE_BOTTOM_CENTER", "position": { "x": 385.9818, "y": 213.22089, "z": -30.45643 } }, { "type": "LEFT_EYE_TOP_BOUNDARY", "position": { "x": 329.98587, "y": 128.55806, "z": -7.625594 } }, { "type": "LEFT_EYE_RIGHT_CORNER", "position": { "x": 350.25543, "y": 136.96538, "z": 0.3162137 } }, { "type": "LEFT_EYE_BOTTOM_BOUNDARY", "position": { "x": 327.47772, "y": 142.9333, "z": -1.0234838 } }, { "type": "LEFT_EYE_LEFT_CORNER", "position": { "x": 307.4751, "y": 137.34349, "z": 10.214714 } }, { "type": "LEFT_EYE_PUPIL", "position": { "x": 328.45987, "y": 136.19621, "z": -3.1551569 } }, { "type": "RIGHT_EYE_TOP_BOUNDARY", "position": { "x": 440.0691, "y": 126.8801, "z": -7.779711 } }, { "type": "RIGHT_EYE_RIGHT_CORNER", "position": { "x": 464.28534, "y": 135.34042, "z": 10.301969 } }, { "type": "RIGHT_EYE_BOTTOM_BOUNDARY", "position": { "x": 441.76584, "y": 140.32564, "z": -1.2271972 } }, { "type": "RIGHT_EYE_LEFT_CORNER", "position": { "x": 422.21207, "y": 135.32939, "z": 0.33341154 } }, { "type": "RIGHT_EYE_PUPIL", "position": { "x": 441.37714, "y": 134.46259, "z": -3.4412556 } }, { "type": "LEFT_EYEBROW_UPPER_MIDPOINT", "position": { "x": 324.93048, "y": 96.94437, "z": -13.394134 } }, { "type": "RIGHT_EYEBROW_UPPER_MIDPOINT", "position": { "x": 444.3336, "y": 95.093765, "z": -13.487409 } }, { "type": "LEFT_EAR_TRAGION", "position": { "x": 261.2239, "y": 191.10706, "z": 136.27896 } }, { "type": "RIGHT_EAR_TRAGION", "position": { "x": 513.192, "y": 187.88185, "z": 136.99525 } }, { "type": "FOREHEAD_GLABELLA", "position": { "x": 384.6936, "y": 107.73683, "z": -26.120888 } }, { "type": "CHIN_GNATHION", "position": { "x": 388.01538, "y": 322.47537, "z": -6.83534 } }, { "type": "CHIN_LEFT_GONION", "position": { "x": 274.37195, "y": 261.15628, "z": 91.56324 } }, { "type": "CHIN_RIGHT_GONION", "position": { "x": 500.2335, "y": 257.99966, "z": 91.12145 } } ], "rollAngle": -0.8706148, "panAngle": -0.0915068, "tiltAngle": 0.05244069, "detectionConfidence": 0.99914575, "landmarkingConfidence": 0.7713903, "joyLikelihood": "VERY_LIKELY", "sorrowLikelihood": "VERY_UNLIKELY", "angerLikelihood": "VERY_UNLIKELY", "surpriseLikelihood": "VERY_UNLIKELY", "underExposedLikelihood": "VERY_UNLIKELY", "blurredLikelihood": "VERY_UNLIKELY", "headwearLikelihood": "VERY_UNLIKELY", "recognitionResult": [ { "celebrity": { "name": "builtin/celebrity-mid ", "displayName": "celebrity-name " }, "confidence": 0.82625544 } ] } ] } ] }
유명인 선택 해제 요청
귀하가 Cloud Vision 또는 Video Intelligence API에서 이 기능에 포함되고 싶지 않은 유명인인 경우에는 이 양식을 작성하여 제출하세요.
오용 신고
Vision API 유명인 인식 기능이 오용된 것으로 의심되는 경우 이 양식을 사용하여 알려주시기 바랍니다.