如何在Swift 3中使用AWS Rekognition比较人脸

编程入门 行业动态 更新时间:2024-10-26 20:34:25
本文介绍了如何在Swift 3中使用AWS Rekognition比较人脸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在尝试使用AWSRekognition SDK来比较人脸。但是,Amazon没有有关如何将其SDK与iOS集成的文档。它们具有显示如何使用识别的链接(开发人员指南),仅提供Java中的示例,而且功能非常有限。

I've been trying to use the AWSRekognition SDK in order to compare face. However, Amazon has no Documentation on how to integrate their SDK with iOS. They have links that show how to work with Recognition (Developer Guide) with examples only in Java and very limited.

我想知道是否有人知道如何将AWS Rekognition集成到Swift 3中。如何初始化它并使用图像进行请求,并接收带有标签的响应。

I wanted to know if anyone knows how to integrate AWS Rekognition in Swift 3. How to Initialize it and make a request with an image, receiving a response with the labels.

我有AWS Signatures AccessKey,SecretKey,AWS Region,服务名称。同样是主体

I have AWS Signatures AccessKey, SecretKey, AWS Region, Service Name. also Body

{ "SourceImage": { "S3Object": { "Bucket": "bucketName", "Name": "ios/sample.jpg" } }, "TargetImage": { "S3Object": { "Bucket": "buketName", "Name": "ios/target.JPG" } } }

我如何初始化识别并建立请求。

how can I initialize Rekognition and build a Request.

谢谢!

推荐答案

  • 实例化Rekognition客户端,这里我使用默认的客户端

  • Instantiate the Rekognition Client, Here I'm using the client with the default configuration. let rekognitionClient:AWSRekognition = AWSRekognition.default()

  • 否则,您可以使用以下凭据:

    Otherwise, you can use the credentials as follows:

    let credentialsProvider = AWSCognitoCredentialsProvider( regionType: AWSRegionType.usEast2, identityPoolId: "us-east-2_myPoolID") let configuration = AWSServiceConfiguration( region: AWSRegionType.usEast2, credentialsProvider: credentialsProvider) AWSServiceManager.default().defaultServiceConfiguration = configuration let rekognitionClient:AWSRekognition = AWSRekognition.default()

  • 现在构造

  • Now construct the request and set the image in it. let image = UIImage(named: "MyImage") let request = AWSRekognitionDetectLabelsRequest() request.image = image request.maxLabels = <num_labels_needed> request.minConfidence = <confidence_interval_needed>

  • 现在要比较人脸,请阅读CompareFacesRequest: github/aws/aws-sdk-ios/blob/ master / AWSRekognition / AWSRekognitionService.m#L288

    SDK中有一个示例测试,用于比较ObjC中有两张面孔,但您可以在Swift中将其翻译:

    There is a sample test in the SDK that compares two faces in ObjC but you can translate that in Swift:

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

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

    如何在Swift 3中使用AWS Rekognition比较人脸

    本文发布于:2023-11-26 21:56:03,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1635350.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:如何在   Swift   Rekognition   AWS

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!