다음과 DeleteFaces 함께 사용하십시오. AWS SDK또는 CLI - Amazon Rekognition

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

다음과 DeleteFaces 함께 사용하십시오. AWS SDK또는 CLI

다음 코드 예제는 DeleteFaces의 사용 방법을 보여 줍니다.

자세한 내용은 컬렉션에서 얼굴 삭제를 참조하십시오.

.NET
AWS SDK for .NET
참고

더 많은 정보가 있습니다 GitHub. 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리.

using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon.Rekognition; using Amazon.Rekognition.Model; /// <summary> /// Uses the Amazon Rekognition Service to delete one or more faces from /// a Rekognition collection. /// </summary> public class DeleteFaces { public static async Task Main() { string collectionId = "MyCollection"; var faces = new List<string> { "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }; var rekognitionClient = new AmazonRekognitionClient(); var deleteFacesRequest = new DeleteFacesRequest() { CollectionId = collectionId, FaceIds = faces, }; DeleteFacesResponse deleteFacesResponse = await rekognitionClient.DeleteFacesAsync(deleteFacesRequest); deleteFacesResponse.DeletedFaces.ForEach(face => { Console.WriteLine($"FaceID: {face}"); }); } }
  • 자세한 API 내용은 DeleteFaces을 참조하십시오. AWS SDK for .NET API참조.

CLI
AWS CLI

모음에서 얼굴을 삭제하는 방법

다음 delete-faces 명령은 모음에서 지정된 얼굴을 삭제합니다.

aws rekognition delete-faces \ --collection-id MyCollection --face-ids '["0040279c-0178-436e-b70a-e61b074e96b0"]'

출력:

{ "DeletedFaces": [ "0040279c-0178-436e-b70a-e61b074e96b0" ] }

자세한 내용은 Amazon Rekognition 개발자 안내서의 모음에서 얼굴 삭제를 참조하세요.

  • 자세한 API 내용은 DeleteFaces을 참조하십시오. AWS CLI 명령 참조.

Java
SDK자바 2.x의 경우
참고

더 많은 내용이 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.rekognition.RekognitionClient; import software.amazon.awssdk.services.rekognition.model.DeleteFacesRequest; import software.amazon.awssdk.services.rekognition.model.RekognitionException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class DeleteFacesFromCollection { public static void main(String[] args) { final String usage = """ Usage: <collectionId> <faceId>\s Where: collectionId - The id of the collection from which faces are deleted.\s faceId - The id of the face to delete.\s """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String collectionId = args[0]; String faceId = args[1]; Region region = Region.US_EAST_1; RekognitionClient rekClient = RekognitionClient.builder() .region(region) .build(); System.out.println("Deleting collection: " + collectionId); deleteFacesCollection(rekClient, collectionId, faceId); rekClient.close(); } public static void deleteFacesCollection(RekognitionClient rekClient, String collectionId, String faceId) { try { DeleteFacesRequest deleteFacesRequest = DeleteFacesRequest.builder() .collectionId(collectionId) .faceIds(faceId) .build(); rekClient.deleteFaces(deleteFacesRequest); System.out.println("The face was deleted from the collection."); } catch (RekognitionException e) { System.out.println(e.getMessage()); System.exit(1); } } }
  • 자세한 API 내용은 DeleteFaces을 참조하십시오. AWS SDK for Java 2.x API참조.

Kotlin
SDK코틀린의 경우
참고

더 많은 정보가 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리.

suspend fun deleteFacesCollection( collectionIdVal: String?, faceIdVal: String, ) { val deleteFacesRequest = DeleteFacesRequest { collectionId = collectionIdVal faceIds = listOf(faceIdVal) } RekognitionClient { region = "us-east-1" }.use { rekClient -> rekClient.deleteFaces(deleteFacesRequest) println("$faceIdVal was deleted from the collection") } }
  • 자세한 API 내용은 DeleteFaces을 참조하십시오. AWS SDKKotlin API 레퍼런스는 여기를 참조하세요.

Python
SDK파이썬용 (보토3)
참고

더 많은 정보가 있습니다. GitHub 전체 예제를 찾아 설치 및 실행 방법을 알아보십시오. AWS 코드 예제 리포지토리.

class RekognitionCollection: """ Encapsulates an Amazon Rekognition collection. This class is a thin wrapper around parts of the Boto3 Amazon Rekognition API. """ def __init__(self, collection, rekognition_client): """ Initializes a collection object. :param collection: Collection data in the format returned by a call to create_collection. :param rekognition_client: A Boto3 Rekognition client. """ self.collection_id = collection["CollectionId"] self.collection_arn, self.face_count, self.created = self._unpack_collection( collection ) self.rekognition_client = rekognition_client @staticmethod def _unpack_collection(collection): """ Unpacks optional parts of a collection that can be returned by describe_collection. :param collection: The collection data. :return: A tuple of the data in the collection. """ return ( collection.get("CollectionArn"), collection.get("FaceCount", 0), collection.get("CreationTimestamp"), ) def delete_faces(self, face_ids): """ Deletes faces from the collection. :param face_ids: The list of IDs of faces to delete. :return: The list of IDs of faces that were deleted. """ try: response = self.rekognition_client.delete_faces( CollectionId=self.collection_id, FaceIds=face_ids ) deleted_ids = response["DeletedFaces"] logger.info( "Deleted %s faces from %s.", len(deleted_ids), self.collection_id ) except ClientError: logger.exception("Couldn't delete faces from %s.", self.collection_id) raise else: return deleted_ids
  • 자세한 API 내용은 DeleteFaces을 참조하십시오. AWS SDK파이썬 (Boto3) API 참조용.

전체 목록은 다음과 같습니다. AWS SDK개발자 가이드 및 코드 예제는 을 참조하십시오Rekognition과 함께 사용하기 AWS SDK. 이 항목에는 시작에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.