1
0
Fork 0
mirror of https://github.com/Luzifer/mondash.git synced 2024-12-23 20:41:17 +00:00
mondash/vendor/github.com/aws/aws-sdk-go/service/rekognition/examples_test.go
Knut Ahlers fd7056f82f
Switch to dep for vendoring, update libraries
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-11-22 21:39:52 +01:00

531 lines
19 KiB
Go

// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package rekognition_test
import (
"fmt"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rekognition"
)
var _ time.Duration
var _ strings.Reader
var _ aws.Config
func parseTime(layout, value string) *time.Time {
t, err := time.Parse(layout, value)
if err != nil {
panic(err)
}
return &t
}
// To compare two images
//
// This operation compares the largest face detected in the source image with each face
// detected in the target image.
func ExampleRekognition_CompareFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.CompareFacesInput{
SimilarityThreshold: aws.Float64(90.000000),
SourceImage: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("mybucket"),
Name: aws.String("mysourceimage"),
},
},
TargetImage: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("mybucket"),
Name: aws.String("mytargetimage"),
},
},
}
result, err := svc.CompareFaces(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeImageTooLargeException:
fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeInvalidImageFormatException:
fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To create a collection
//
// This operation creates a Rekognition collection for storing image data.
func ExampleRekognition_CreateCollection_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.CreateCollectionInput{
CollectionId: aws.String("myphotos"),
}
result, err := svc.CreateCollection(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeResourceAlreadyExistsException:
fmt.Println(rekognition.ErrCodeResourceAlreadyExistsException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To delete a collection
//
// This operation deletes a Rekognition collection.
func ExampleRekognition_DeleteCollection_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DeleteCollectionInput{
CollectionId: aws.String("myphotos"),
}
result, err := svc.DeleteCollection(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To delete a face
//
// This operation deletes one or more faces from a Rekognition collection.
func ExampleRekognition_DeleteFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DeleteFacesInput{
CollectionId: aws.String("myphotos"),
FaceIds: []*string{
aws.String("ff43d742-0c13-5d16-a3e8-03d3f58e980b"),
},
}
result, err := svc.DeleteFaces(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To detect faces in an image
//
// This operation detects faces in an image stored in an AWS S3 bucket.
func ExampleRekognition_DetectFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DetectFacesInput{
Image: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("mybucket"),
Name: aws.String("myphoto"),
},
},
}
result, err := svc.DetectFaces(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeImageTooLargeException:
fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeInvalidImageFormatException:
fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To detect labels
//
// This operation detects labels in the supplied image
func ExampleRekognition_DetectLabels_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DetectLabelsInput{
Image: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("mybucket"),
Name: aws.String("myphoto"),
},
},
MaxLabels: aws.Int64(123),
MinConfidence: aws.Float64(70.000000),
}
result, err := svc.DetectLabels(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeImageTooLargeException:
fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeInvalidImageFormatException:
fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To add a face to a collection
//
// This operation detects faces in an image and adds them to the specified Rekognition
// collection.
func ExampleRekognition_IndexFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.IndexFacesInput{
CollectionId: aws.String("myphotos"),
ExternalImageId: aws.String("myphotoid"),
Image: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("mybucket"),
Name: aws.String("myphoto"),
},
},
}
result, err := svc.IndexFaces(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeImageTooLargeException:
fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInvalidImageFormatException:
fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To list the collections
//
// This operation returns a list of Rekognition collections.
func ExampleRekognition_ListCollections_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.ListCollectionsInput{}
result, err := svc.ListCollections(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To list the faces in a collection
//
// This operation lists the faces in a Rekognition collection.
func ExampleRekognition_ListFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.ListFacesInput{
CollectionId: aws.String("myphotos"),
MaxResults: aws.Int64(20),
}
result, err := svc.ListFaces(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To delete a face
//
// This operation searches for matching faces in the collection the supplied face belongs
// to.
func ExampleRekognition_SearchFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.SearchFacesInput{
CollectionId: aws.String("myphotos"),
FaceId: aws.String("70008e50-75e4-55d0-8e80-363fb73b3a14"),
FaceMatchThreshold: aws.Float64(90.000000),
MaxFaces: aws.Int64(10),
}
result, err := svc.SearchFaces(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// To search for faces matching a supplied image
//
// This operation searches for faces in a Rekognition collection that match the largest
// face in an S3 bucket stored image.
func ExampleRekognition_SearchFacesByImage_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.SearchFacesByImageInput{
CollectionId: aws.String("myphotos"),
FaceMatchThreshold: aws.Float64(95.000000),
Image: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("mybucket"),
Name: aws.String("myphoto"),
},
},
MaxFaces: aws.Int64(5),
}
result, err := svc.SearchFacesByImage(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeImageTooLargeException:
fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInvalidImageFormatException:
fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}