기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
사용자 생성
CreateUser 작업을 사용하여 귀하가 제공하는 고유한 사용자 ID로 컬렉션에 새 사용자를 생성할 수 있습니다. 그런 다음 새로 만든 사용자와 얼굴 여러 개를 연결할 수 있습니다.
사용자를 생성하려면(SDK)
-
아직 설정하지 않았다면 다음과 같이 하세요.
-
AmazonRekognitionFullAccess권한이 있는 IAM 사용자 계정을 생성하거나 업데이트합니다. 자세한 내용은 1단계: AWS 계정 설정 및 사용자 생성 단원을 참조하십시오. -
AWS CLI 및 AWS SDKs를 설치하고 구성합니다. 자세한 내용은 2단계: AWS CLI 및 AWS SDKs 설정 단원을 참조하십시오.
-
-
다음 예제를 사용하여
CreateUser작업을 호출합니다.- Java
-
이 Java 코드 예제는 사용자를 생성합니다.
import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.CreateUserRequest; import com.amazonaws.services.rekognition.model.CreateUserResult; public class CreateUser { public static void main(String[] args) throws Exception { AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); //Replace collectionId and userId with the name of the user that you want to create in that target collection. String collectionId = "MyCollection"; String userId = "demoUser"; System.out.println("Creating new user: " + userId); CreateUserRequest request = new CreateUserRequest() .withCollectionId(collectionId) .withUserId(userId); rekognitionClient.createUser(request); } } - AWS CLI
-
이 AWS CLI 명령은
create-userCLI 작업을 사용하여 사용자를 생성합니다.aws rekognition create-user --user-iduser-id--collection-idcollection-name--regionregion-name--client-request-tokenrequest-token - Python
-
이 Python 코드 예제는 사용자를 생성합니다.
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) import boto3 from botocore.exceptions import ClientError import logging logger = logging.getLogger(__name__) session = boto3.Session(profile_name='profile-name') client = session.client('rekognition') def create_user(collection_id, user_id): """ Creates a new User within a collection specified by CollectionId. Takes UserId as a parameter, which is a user provided ID which should be unique within the collection. :param collection_id: The ID of the collection where the indexed faces will be stored at. :param user_id: ID for the UserID to be created. This ID needs to be unique within the collection. :return: The indexFaces response """ try: logger.info(f'Creating user: {collection_id}, {user_id}') client.create_user( CollectionId=collection_id, UserId=user_id ) except ClientError: logger.exception(f'Failed to create user with given user id: {user_id}') raise def main(): collection_id = "collection-id" user_id = "user-id" create_user(collection_id, user_id) if __name__ == "__main__": main() - Go
-
이 Go 코드 예제에서는 AWS Go SDK V2를 사용하고 사용자를 생성합니다.
package main import ( "context" "fmt" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/rekognition" ) func main() { // Load the AWS SDK configuration cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2")) if err != nil { log.Fatalf("Failed to load configuration: %v", err) } // Create a Rekognition client client := rekognition.NewFromConfig(cfg) // Set up the input parameters input := &rekognition.CreateUserInput{ CollectionId: aws.String("my-new-collection"), // Replace with your collection ID UserId: aws.String("user12345678910"), // Replace with desired user ID } // Call the CreateUser operation result, err := client.CreateUser(context.TODO(), input) if err != nil { log.Fatalf("Failed to create user: %v", err) } // Print out the results fmt.Printf("User created successfully:\n") }
컬렉션에서 얼굴 삭제
사용자 삭제