기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
컬렉션 설명
DescribeCollection작업을 사용하여 컬렉션에 대한 다음 정보를 얻을 수 있습니다.
컬렉션 설명하기 (SDK)
-
아직 설정하지 않았다면 다음과 같이 하세요.
-
AmazonRekognitionFullAccess
권한이 있는 사용자를 생성하거나 업데이트합니다. 자세한 내용은 1단계: AWS 계정 설정 및 사용자 생성 단원을 참조하십시오.
-
및 를 설치 AWS CLI 및 구성합니다 AWS SDKs. 자세한 내용은 2단계: 설정 AWS CLI 그리고 AWS SDKs 단원을 참조하십시오.
-
다음 예제를 사용하여 DescribeCollection
작업을 호출합니다.
- Java
-
이 예제는 모음을 설명합니다.
collectionId
의 값을 원하는 모음의 ID로 변경합니다.
//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.)
package com.amazonaws.samples;
import com.amazonaws.services.rekognition.AmazonRekognition;
import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder;
import com.amazonaws.services.rekognition.model.DescribeCollectionRequest;
import com.amazonaws.services.rekognition.model.DescribeCollectionResult;
public class DescribeCollection {
public static void main(String[] args) throws Exception {
String collectionId = "CollectionID";
AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
System.out.println("Describing collection: " +
collectionId );
DescribeCollectionRequest request = new DescribeCollectionRequest()
.withCollectionId(collectionId);
DescribeCollectionResult describeCollectionResult = rekognitionClient.describeCollection(request);
System.out.println("Collection Arn : " +
describeCollectionResult.getCollectionARN());
System.out.println("Face count : " +
describeCollectionResult.getFaceCount().toString());
System.out.println("Face model version : " +
describeCollectionResult.getFaceModelVersion());
System.out.println("Created : " +
describeCollectionResult.getCreationTimestamp().toString());
}
}
- Java V2
-
이 코드는 AWS 문서 SDK 예제 GitHub 리포지토리에서 가져온 것입니다. 전체 예제는 여기에서 확인하세요.
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.rekognition.RekognitionClient;
import software.amazon.awssdk.services.rekognition.model.DescribeCollectionRequest;
import software.amazon.awssdk.services.rekognition.model.DescribeCollectionResponse;
import software.amazon.awssdk.services.rekognition.model.RekognitionException;
//snippet-end:[rekognition.java2.describe_collection.import]
/**
* 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 DescribeCollection {
public static void main(String[] args) {
final String usage = "\n" +
"Usage: " +
" <collectionName>\n\n" +
"Where:\n" +
" collectionName - The name of the Amazon Rekognition collection. \n\n";
if (args.length != 1) {
System.out.println(usage);
System.exit(1);
}
String collectionName = args[0];
Region region = Region.US_EAST_1;
RekognitionClient rekClient = RekognitionClient.builder()
.region(region)
.credentialsProvider(ProfileCredentialsProvider.create("profile-name"))
.build();
describeColl(rekClient, collectionName);
rekClient.close();
}
// snippet-start:[rekognition.java2.describe_collection.main]
public static void describeColl(RekognitionClient rekClient, String collectionName) {
try {
DescribeCollectionRequest describeCollectionRequest = DescribeCollectionRequest.builder()
.collectionId(collectionName)
.build();
DescribeCollectionResponse describeCollectionResponse = rekClient.describeCollection(describeCollectionRequest);
System.out.println("Collection Arn : " + describeCollectionResponse.collectionARN());
System.out.println("Created : " + describeCollectionResponse.creationTimestamp().toString());
} catch(RekognitionException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
// snippet-end:[rekognition.java2.describe_collection.main]
}
- AWS CLI
-
이 AWS CLI 명령은 describe-collection
CLI 작업에 대한 JSON 출력을 표시합니다. collection-id
의 값을 원하는 모음의 ID로 변경합니다. Rekognition 세션을 생성하는 라인에서 profile_name
의 값을 개발자 프로필의 이름으로 대체합니다.
aws rekognition describe-collection --collection-id collection-name --profile profile-name
- Python
-
이 예제는 모음을 설명합니다.
collection_id
의 값을 원하는 모음의 ID로 변경합니다. Rekognition 세션을 생성하는 라인에서 profile_name
의 값을 개발자 프로필의 이름으로 대체합니다.
# 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
def describe_collection(collection_id):
print('Attempting to describe collection ' + collection_id)
session = boto3.Session(profile_name='default')
client = session.client('rekognition')
try:
response = client.describe_collection(CollectionId=collection_id)
print("Collection Arn: " + response['CollectionARN'])
print("Face Count: " + str(response['FaceCount']))
print("Face Model Version: " + response['FaceModelVersion'])
print("Timestamp: " + str(response['CreationTimestamp']))
except ClientError as e:
if e.response['Error']['Code'] == 'ResourceNotFoundException':
print('The collection ' + collection_id + ' was not found ')
else:
print('Error other than Not Found occurred: ' + e.response['Error']['Message'])
print('Done...')
def main():
collection_id = 'collection-name'
describe_collection(collection_id)
if __name__ == "__main__":
main()
- .NET
-
이 예제는 모음을 설명합니다.
collectionId
의 값을 원하는 모음의 ID로 변경합니다.
//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.)
using System;
using Amazon.Rekognition;
using Amazon.Rekognition.Model;
public class DescribeCollection
{
public static void Example()
{
AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient();
String collectionId = "CollectionID";
Console.WriteLine("Describing collection: " + collectionId);
DescribeCollectionRequest describeCollectionRequest = new DescribeCollectionRequest()
{
CollectionId = collectionId
};
DescribeCollectionResponse describeCollectionResponse = rekognitionClient.DescribeCollection(describeCollectionRequest);
Console.WriteLine("Collection ARN: " + describeCollectionResponse.CollectionARN);
Console.WriteLine("Face count: " + describeCollectionResponse.FaceCount);
Console.WriteLine("Face model version: " + describeCollectionResponse.FaceModelVersion);
Console.WriteLine("Created: " + describeCollectionResponse.CreationTimestamp);
}
}
- Node.js
-
//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 { DescribeCollectionCommand } from "@aws-sdk/client-rekognition";
import { RekognitionClient } from "@aws-sdk/client-rekognition";
import {fromIni} from '@aws-sdk/credential-providers';
// Set the AWS Region.
const REGION = "region-name"; //e.g. "us-east-1"
// Set the profile name
const profileName = "profile-name"
// Name the collection
const rekogClient = new RekognitionClient({region: REGION,
credentials: fromIni({profile: profileName,}),
});
// Name the collection
const collection_name = "collection-name"
const describeCollection = async (collectionName) => {
try {
console.log(`Attempting to describe collection named - ${collectionName}`)
var response = await rekogClient.send(new DescribeCollectionCommand({CollectionId: collectionName}))
console.log('Collection Arn:')
console.log(response.CollectionARN)
console.log('Face Count:')
console.log(response.FaceCount)
console.log('Face Model Version:')
console.log(response.FaceModelVersion)
console.log('Timestamp:')
console.log(response.CreationTimestamp)
return response; // For unit tests.
} catch (err) {
console.log("Error", err.stack);
}
};
describeCollection(collection_name)
DescribeCollection 작업 요청
입력 DescribeCollection
to는 다음 JSON 예와 같이 원하는 컬렉션의 ID입니다.
{
"CollectionId": "MyCollection"
}
DescribeCollection작업 응답
응답에는 다음이 포함됩니다.
-
모음에 인덱싱된 얼굴의 수, FaceCount
.
-
컬렉션과 함께 사용되는 얼굴 모델 버전, FaceModelVersion
. 자세한 내용은 모델 버전 관리에 대한 이해 단원을 참조하십시오.
-
모음의 Amazon 리소스 이름, CollectionARN
.
-
모음의 생성 날짜 및 시간, CreationTimestamp
. CreationTimestamp
의 값은 밀리초인데 모음 생성까지의 Unix epoch 시간 때문입니다. 유닉스 에포크 타임은 1970년 1월 1일 목요일 00:00:00 협정 세계시 (UTC) 입니다. 자세한 내용은 Unix Time을 참조하십시오.
{
"CollectionARN": "arn:aws:rekognition:us-east-1:nnnnnnnnnnnn:collection/MyCollection",
"CreationTimestamp": 1.533422155042E9,
"FaceCount": 200,
"UserCount" : 20,
"FaceModelVersion": "1.0"
}