我在尝试使用AWS
调用IOS Swift
识别比较面孔api时遇到逻辑问题。 Swift
尚无任何文档(截至本发布之时),但相信我可能已正确设置了请求,只是没有正确地调用它来接收响应对象并确认结果。
有什么建议吗?
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()
答案 0 :(得分:2)
SDK中的以下示例测试演示了如何比较ObjC中的两个面孔。
Swift中相应的代码段看起来像:
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")
希望有帮助!