1

I have an issue with my logic trying to invoke the AWS Recognition Compare Faces api using IOS Swift. There isn't any documentation for Swift yet (as of this posting), but believe I may have the request set up correctly, just not invoking it correctly to receive the response object and confirm the results.

Any advice?

let sourceImage = AWSRekognitionImage()
let sourceImageS3Object = AWSRekognitionS3Object()
sourceImageS3Object?.bucket = "face-badges"
sourceImageS3Object?.name = "me.jpg"
sourceImage?.s3Object = sourceImageS3Object

let targetImage = AWSRekognitionImage()
let targetImageS3Object = AWSRekognitionS3Object()
targetImageS3Object?.bucket = "face-badges"
targetImageS3Object?.name = "me2.jpg"
targetImage?.s3Object = targetImageS3Object

let request = AWSRekognitionCompareFacesRequest()
request?.similarityThreshold = 90
request?.sourceImage = sourceImage
request?.targetImage = targetImage

let key = "testCompareFaces"
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,
                                                        identityPoolId:"xxxxx")
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)

AWSRekognition.register(with: configuration!, forKey: key)
AWSRekognition(forKey: key).compareFaces(AWSRekognitionCompareFacesRequest()).continueWith(block: {(_ task: AWSTask) -> Any in
    print("completed")

    return true;

}).waitUntilFinished()
sirhcmcd
  • 81
  • 6
  • This documentation is 3 month old - https://github.com/aws-samples/amazon-rekognition-celebrity-detection-ios/tree/master/AWSRekognitionStarterApp – canister_exister Dec 28 '18 at 15:31
  • https://aws.amazon.com/blogs/mobile/amazon-rekognition-detects-celebrities-in-ios-app/ – canister_exister Dec 28 '18 at 15:35
  • 1
    Possible duplicate of [How to use AWS Rekognition to Compare Face in Swift 3](https://stackoverflow.com/questions/46483447/how-to-use-aws-rekognition-to-compare-face-in-swift-3) – canister_exister Dec 28 '18 at 15:35

1 Answers1

4

The following sample test in the SDK demonstrated how to compare two faces in ObjC.

https://github.com/aws/aws-sdk-ios/blob/master/AWSRekognitionUnitTests/AWSGeneralRekognitionTests.m#L60

Corresponding snippet in Swift would look something like :

let key = "testCompareFaces"
let configuration = AWSServiceConfiguration(region: AWSRegionUSEast2, credentialsProvider: nil)
AWSRekognition.register(with: configuration, forKey: key)
AWSRekognition(for: key).compareFaces(AWSRekognitionCompareFacesRequest()).continue(withBlock: {(_ task: AWSTask) -> Any in
    print("completed")

Hope that helps!

Roshan
  • 753
  • 5
  • 14