

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

# SDK for Kotlin을 사용한 Amazon Rekognition 예제
<a name="kotlin_rekognition_code_examples"></a>

다음 코드 예제에서는 Amazon Rekognition과 함께 AWS SDK for Kotlin을 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접 호출하는 방법을 보여주며, 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

*시나리오*는 동일한 서비스 내에서 또는 다른 AWS 서비스와 결합된 상태에서 여러 함수를 직접적으로 호출하여 특정 태스크를 수행하는 방법을 보여주는 코드 예제입니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)
+ [시나리오](#scenarios)

## 작업
<a name="actions"></a>

### `CompareFaces`
<a name="rekognition_CompareFaces_kotlin_topic"></a>

다음 코드 예시는 `CompareFaces`의 사용 방법을 보여줍니다.

자세한 내용은 [이미지에 있는 얼굴 비교](https://docs.aws.amazon.com/rekognition/latest/dg/faces-comparefaces.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun compareTwoFaces(
    similarityThresholdVal: Float,
    sourceImageVal: String,
    targetImageVal: String,
) {
    val sourceBytes = (File(sourceImageVal).readBytes())
    val targetBytes = (File(targetImageVal).readBytes())

    // Create an Image object for the source image.
    val souImage =
        Image {
            bytes = sourceBytes
        }

    val tarImage =
        Image {
            bytes = targetBytes
        }

    val facesRequest =
        CompareFacesRequest {
            sourceImage = souImage
            targetImage = tarImage
            similarityThreshold = similarityThresholdVal
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->

        val compareFacesResult = rekClient.compareFaces(facesRequest)
        val faceDetails = compareFacesResult.faceMatches

        if (faceDetails != null) {
            for (match: CompareFacesMatch in faceDetails) {
                val face = match.face
                val position = face?.boundingBox
                if (position != null) {
                    println("Face at ${position.left} ${position.top} matches with ${face.confidence} % confidence.")
                }
            }
        }

        val uncompared = compareFacesResult.unmatchedFaces
        if (uncompared != null) {
            println("There was ${uncompared.size} face(s) that did not match")
        }

        println("Source image rotation: ${compareFacesResult.sourceImageOrientationCorrection}")
        println("target image rotation: ${compareFacesResult.targetImageOrientationCorrection}")
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [CompareFaces](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `CreateCollection`
<a name="rekognition_CreateCollection_kotlin_topic"></a>

다음 코드 예시는 `CreateCollection`의 사용 방법을 보여줍니다.

자세한 내용은 [컬렉션 생성](https://docs.aws.amazon.com/rekognition/latest/dg/create-collection-procedure.html)을 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun createMyCollection(collectionIdVal: String) {
    val request =
        CreateCollectionRequest {
            collectionId = collectionIdVal
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.createCollection(request)
        println("Collection ARN is ${response.collectionArn}")
        println("Status code is ${response.statusCode}")
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [CreateCollection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)을 참조하세요.

### `DeleteCollection`
<a name="rekognition_DeleteCollection_kotlin_topic"></a>

다음 코드 예시는 `DeleteCollection`의 사용 방법을 보여줍니다.

자세한 내용은 [컬렉션 삭제](https://docs.aws.amazon.com/rekognition/latest/dg/delete-collection-procedure.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun deleteMyCollection(collectionIdVal: String) {
    val request =
        DeleteCollectionRequest {
            collectionId = collectionIdVal
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.deleteCollection(request)
        println("The collectionId status is ${response.statusCode}")
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DeleteCollection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)을 참조하세요.

### `DeleteFaces`
<a name="rekognition_DeleteFaces_kotlin_topic"></a>

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

자세한 내용은 [컬렉션에서 얼굴 삭제를](https://docs.aws.amazon.com/rekognition/latest/dg/delete-faces-procedure.html) 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun deleteFacesCollection(
    collectionIdVal: String?,
    faceIdVal: String,
) {
    val deleteFacesRequest =
        DeleteFacesRequest {
            collectionId = collectionIdVal
            faceIds = listOf(faceIdVal)
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        rekClient.deleteFaces(deleteFacesRequest)
        println("$faceIdVal was deleted from the collection")
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DeleteFaces](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `DescribeCollection`
<a name="rekognition_DescribeCollection_kotlin_topic"></a>

다음 코드 예시는 `DescribeCollection`의 사용 방법을 보여줍니다.

자세한 내용은 [컬렉션 설명](https://docs.aws.amazon.com/rekognition/latest/dg/describe-collection-procedure.html)을 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun describeColl(collectionName: String) {
    val request =
        DescribeCollectionRequest {
            collectionId = collectionName
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.describeCollection(request)
        println("The collection Arn is ${response.collectionArn}")
        println("The collection contains this many faces ${response.faceCount}")
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DescribeCollection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)을 참조하세요.

### `DetectFaces`
<a name="rekognition_DetectFaces_kotlin_topic"></a>

다음 코드 예시는 `DetectFaces`의 사용 방법을 보여줍니다.

자세한 내용은 [이미지에서 얼굴 감지](https://docs.aws.amazon.com/rekognition/latest/dg/faces-detect-images.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun detectFacesinImage(sourceImage: String?) {
    val souImage =
        Image {
            bytes = (File(sourceImage).readBytes())
        }

    val request =
        DetectFacesRequest {
            attributes = listOf(Attribute.All)
            image = souImage
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.detectFaces(request)
        response.faceDetails?.forEach { face ->
            val ageRange = face.ageRange
            println("The detected face is estimated to be between ${ageRange?.low} and ${ageRange?.high} years old.")
            println("There is a smile ${face.smile?.value}")
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DetectFaces](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `DetectLabels`
<a name="rekognition_DetectLabels_kotlin_topic"></a>

다음 코드 예시는 `DetectLabels`의 사용 방법을 보여줍니다.

자세한 내용은 [이미지에서 레이블 감지](https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun detectImageLabels(sourceImage: String) {
    val souImage =
        Image {
            bytes = (File(sourceImage).readBytes())
        }
    val request =
        DetectLabelsRequest {
            image = souImage
            maxLabels = 10
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.detectLabels(request)
        response.labels?.forEach { label ->
            println("${label.name} : ${label.confidence}")
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DetectLabels](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `DetectModerationLabels`
<a name="rekognition_DetectModerationLabels_kotlin_topic"></a>

다음 코드 예시는 `DetectModerationLabels`의 사용 방법을 보여줍니다.

자세한 내용은 [부적절한 이미지 감지](https://docs.aws.amazon.com/rekognition/latest/dg/procedure-moderate-images.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun detectModLabels(sourceImage: String) {
    val myImage =
        Image {
            this.bytes = (File(sourceImage).readBytes())
        }

    val request =
        DetectModerationLabelsRequest {
            image = myImage
            minConfidence = 60f
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.detectModerationLabels(request)
        response.moderationLabels?.forEach { label ->
            println("Label: ${label.name} - Confidence: ${label.confidence} % Parent: ${label.parentName}")
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DetectModerationLabels](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `DetectText`
<a name="rekognition_DetectText_kotlin_topic"></a>

다음 코드 예시는 `DetectText`의 사용 방법을 보여줍니다.

자세한 내용은 [이미지에서 텍스트 감지](https://docs.aws.amazon.com/rekognition/latest/dg/text-detecting-text-procedure.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun detectTextLabels(sourceImage: String?) {
    val souImage =
        Image {
            bytes = (File(sourceImage).readBytes())
        }

    val request =
        DetectTextRequest {
            image = souImage
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.detectText(request)
        response.textDetections?.forEach { text ->
            println("Detected: ${text.detectedText}")
            println("Confidence: ${text.confidence}")
            println("Id: ${text.id}")
            println("Parent Id:  ${text.parentId}")
            println("Type: ${text.type}")
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [DetectText](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `IndexFaces`
<a name="rekognition_IndexFaces_kotlin_topic"></a>

다음 코드 예시는 `IndexFaces`의 사용 방법을 보여줍니다.

자세한 내용은 [컬렉션에 얼굴 추가](https://docs.aws.amazon.com/rekognition/latest/dg/add-faces-to-collection-procedure.html)를 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun addToCollection(
    collectionIdVal: String?,
    sourceImage: String,
) {
    val souImage =
        Image {
            bytes = (File(sourceImage).readBytes())
        }

    val request =
        IndexFacesRequest {
            collectionId = collectionIdVal
            image = souImage
            maxFaces = 1
            qualityFilter = QualityFilter.Auto
            detectionAttributes = listOf(Attribute.Default)
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val facesResponse = rekClient.indexFaces(request)

        // Display the results.
        println("Results for the image")
        println("\n Faces indexed:")
        facesResponse.faceRecords?.forEach { faceRecord ->
            println("Face ID: ${faceRecord.face?.faceId}")
            println("Location: ${faceRecord.faceDetail?.boundingBox}")
        }

        println("Faces not indexed:")
        facesResponse.unindexedFaces?.forEach { unindexedFace ->
            println("Location: ${unindexedFace.faceDetail?.boundingBox}")
            println("Reasons:")

            unindexedFace.reasons?.forEach { reason ->
                println("Reason:  $reason")
            }
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [IndexFaces](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `ListCollections`
<a name="rekognition_ListCollections_kotlin_topic"></a>

다음 코드 예시는 `ListCollections`의 사용 방법을 보여줍니다.

자세한 내용은 [컬렉션 나열](https://docs.aws.amazon.com/rekognition/latest/dg/list-collection-procedure.html)을 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun listAllCollections() {
    val request =
        ListCollectionsRequest {
            maxResults = 10
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.listCollections(request)
        response.collectionIds?.forEach { resultId ->
            println(resultId)
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [ListCollections](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `ListFaces`
<a name="rekognition_ListFaces_kotlin_topic"></a>

다음 코드 예시는 `ListFaces`의 사용 방법을 보여줍니다.

자세한 내용은 [컬렉션 내 얼굴 나열](https://docs.aws.amazon.com/rekognition/latest/dg/list-faces-in-collection-procedure.html)을 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun listFacesCollection(collectionIdVal: String?) {
    val request =
        ListFacesRequest {
            collectionId = collectionIdVal
            maxResults = 10
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.listFaces(request)
        response.faces?.forEach { face ->
            println("Confidence level there is a face: ${face.confidence}")
            println("The face Id value is ${face.faceId}")
        }
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [ListFaces](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

### `RecognizeCelebrities`
<a name="rekognition_RecognizeCelebrities_kotlin_topic"></a>

다음 코드 예시는 `RecognizeCelebrities`의 사용 방법을 보여줍니다.

자세한 내용은 [이미지에서 유명인 인식](https://docs.aws.amazon.com/rekognition/latest/dg/celebrities-procedure-image.html)을 참조하세요.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

```
suspend fun recognizeAllCelebrities(sourceImage: String?) {
    val souImage =
        Image {
            bytes = (File(sourceImage).readBytes())
        }

    val request =
        RecognizeCelebritiesRequest {
            image = souImage
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val response = rekClient.recognizeCelebrities(request)
        response.celebrityFaces?.forEach { celebrity ->
            println("Celebrity recognized: ${celebrity.name}")
            println("Celebrity ID:${celebrity.id}")
            println("Further information (if available):")
            celebrity.urls?.forEach { url ->
                println(url)
            }
        }
        println("${response.unrecognizedFaces?.size} face(s) were unrecognized.")
    }
}
```
+  API 세부 정보는 *AWS SDK for Kotlin API 참조*의 [RecognizeCelebrities](https://sdk.amazonaws.com/kotlin/api/latest/index.html)를 참조하세요.

## 시나리오
<a name="scenarios"></a>

### 사진을 관리하기 위한 서버리스 애플리케이션 만들기
<a name="cross_PAM_kotlin_topic"></a>

다음 코드 예시에서는 사용자가 레이블을 사용하여 사진을 관리할 수 있는 서버리스 애플리케이션을 생성하는 방법을 보여줍니다.

**SDK for Kotlin**  
 Amazon Rekognition을 사용하여 이미지에서 레이블을 감지하고 나중에 검색할 수 있도록 저장하는 사진 자산 관리 애플리케이션을 개발하는 방법을 보여줍니다.  
전체 소스 코드와 설정 및 실행 방법에 대한 지침은 [GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/usecases/creating_pam)에서 전체 예제를 참조하세요.  
이 예제의 출처에 대한 자세한 내용은 [AWS  커뮤니티](https://community.aws/posts/cloud-journeys/01-serverless-image-recognition-app)의 게시물을 참조하세요.  

**이 예제에서 사용되는 서비스**
+ API Gateway
+ DynamoDB
+ Lambda
+ Amazon Rekognition
+ Amazon S3
+ Amazon SNS

### 동영상 내 정보 감지
<a name="rekognition_VideoDetection_kotlin_topic"></a>

다음 코드 예제에서는 다음과 같은 작업을 수행하는 방법을 보여줍니다.
+ Amazon Rekognition 작업을 시작하여 동영상에서 사람, 사물, 텍스트와 같은 요소를 탐지하세요.
+ 작업이 완료될 때까지 작업 상태를 확인하세요.
+ 각 작업에서 감지한 요소의 목록을 출력합니다.

**SDK for Kotlin**  
 GitHub에 더 많은 내용이 있습니다. [AWS 코드 예 리포지토리](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/rekognition#code-examples)에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.
Amazon S3 버킷에 저장된 동영상에서 얼굴을 감지합니다.  

```
suspend fun startFaceDetection(
    channelVal: NotificationChannel?,
    bucketVal: String,
    videoVal: String,
) {
    val s3Obj =
        S3Object {
            bucket = bucketVal
            name = videoVal
        }
    val vidOb =
        Video {
            s3Object = s3Obj
        }

    val request =
        StartFaceDetectionRequest {
            jobTag = "Faces"
            faceAttributes = FaceAttributes.All
            notificationChannel = channelVal
            video = vidOb
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val startLabelDetectionResult = rekClient.startFaceDetection(request)
        startJobId = startLabelDetectionResult.jobId.toString()
    }
}

suspend fun getFaceResults() {
    var finished = false
    var status: String
    var yy = 0
    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        var response: GetFaceDetectionResponse? = null

        val recognitionRequest =
            GetFaceDetectionRequest {
                jobId = startJobId
                maxResults = 10
            }

        // Wait until the job succeeds.
        while (!finished) {
            response = rekClient.getFaceDetection(recognitionRequest)
            status = response.jobStatus.toString()
            if (status.compareTo("Succeeded") == 0) {
                finished = true
            } else {
                println("$yy status is: $status")
                delay(1000)
            }
            yy++
        }

        // Proceed when the job is done - otherwise VideoMetadata is null.
        val videoMetaData = response?.videoMetadata
        println("Format: ${videoMetaData?.format}")
        println("Codec: ${videoMetaData?.codec}")
        println("Duration: ${videoMetaData?.durationMillis}")
        println("FrameRate: ${videoMetaData?.frameRate}")

        // Show face information.
        response?.faces?.forEach { face ->
            println("Age: ${face.face?.ageRange}")
            println("Face: ${face.face?.beard}")
            println("Eye glasses: ${face?.face?.eyeglasses}")
            println("Mustache: ${face.face?.mustache}")
            println("Smile: ${face.face?.smile}")
        }
    }
}
```
Amazon S3 버킷에 저장된 동영상에서 부적절하거나 불쾌감을 주는 콘텐츠를 감지합니다.  

```
suspend fun startModerationDetection(
    channel: NotificationChannel?,
    bucketVal: String?,
    videoVal: String?,
) {
    val s3Obj =
        S3Object {
            bucket = bucketVal
            name = videoVal
        }
    val vidOb =
        Video {
            s3Object = s3Obj
        }
    val request =
        StartContentModerationRequest {
            jobTag = "Moderation"
            notificationChannel = channel
            video = vidOb
        }

    RekognitionClient.fromEnvironment { region = "us-east-1" }.use { rekClient ->
        val startModDetectionResult = rekClient.startContentModeration(request)
        startJobId = startModDetectionResult.jobId.toString()
    }
}

suspend fun getModResults() {
    var finished = false
    var status: String
    var yy = 0
    RekognitionClient { region = "us-east-1" }.use { rekClient ->
        var modDetectionResponse: GetContentModerationResponse? = null

        val modRequest =
            GetContentModerationRequest {
                jobId = startJobId
                maxResults = 10
            }

        // Wait until the job succeeds.
        while (!finished) {
            modDetectionResponse = rekClient.getContentModeration(modRequest)
            status = modDetectionResponse.jobStatus.toString()
            if (status.compareTo("Succeeded") == 0) {
                finished = true
            } else {
                println("$yy status is: $status")
                delay(1000)
            }
            yy++
        }

        // Proceed when the job is done - otherwise VideoMetadata is null.
        val videoMetaData = modDetectionResponse?.videoMetadata
        println("Format: ${videoMetaData?.format}")
        println("Codec: ${videoMetaData?.codec}")
        println("Duration: ${videoMetaData?.durationMillis}")
        println("FrameRate: ${videoMetaData?.frameRate}")

        modDetectionResponse?.moderationLabels?.forEach { mod ->
            val seconds: Long = mod.timestamp / 1000
            print("Mod label: $seconds ")
            println(mod.moderationLabel)
        }
    }
}
```
+ API 세부 정보는 *AWS SDK for Kotlin API 참조*의 다음 주제를 참조하세요.
  + [GetCelebrityRecognition](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [GetContentModeration](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [GetLabelDetection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [GetPersonTracking](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [GetSegmentDetection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [GetTextDetection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [StartCelebrityRecognition](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [StartContentModeration](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [StartLabelDetection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [StartPersonTracking](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [StartSegmentDetection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)
  + [StartTextDetection](https://sdk.amazonaws.com/kotlin/api/latest/index.html)

### 이미지에서 객체 감지
<a name="cross_RekognitionPhotoAnalyzer_kotlin_topic"></a>

다음 코드 예제에서는 Amazon Rekognition을 사용하여 이미지에서 범주별 객체를 감지하는 앱을 구축하는 방법을 보여줍니다.

**SDK for Kotlin**  
 Amazon Rekognition Kotlin API를 사용하여 Amazon Simple Storage Service(Amazon S3) 버킷에 있는 이미지에서 범주별로 객체를 식별하기 위해 Amazon Rekognition을 사용하여 앱을 만드는 방법을 보여줍니다. 이 앱은 Amazon Simple Email Service(Amazon SES)를 사용하여 결과와 함께 이메일 알림을 관리자에게 보냅니다.  
 전체 소스 코드와 설정 및 실행 방법에 대한 지침은 [GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/usecases/creating_photo_analyzer_app)에서 전체 예제를 참조하세요.  

**이 예제에서 사용되는 서비스**
+ Amazon Rekognition
+ Amazon S3
+ Amazon SES