Amazon Rekognition API - IndexFaces提示外部图像ID出错 - 当'externalImageId'中有文件夹结构时

时间:2018-03-29 14:06:00

标签: amazon-s3 amazon amazon-rekognition

我正在尝试调用IndexFaces API但收到错误:

*"exception":"com.amazonaws.services.rekognition.model.AmazonRekognitionException",
"message": "1 validation error detected: Value 'postman/postworld/postman_female.jpg' at 'externalImageId' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.\\-:]+ (Service: AmazonRekognition; Status Code: 400; Error Code: ValidationException; Request ID: 3ac46c4d-3358-11e8-abd5-d5fb3ad03e33)",
"path": "/enrolluser"*

我能够使用S3的所谓“文件夹结构”将我的文件成功上传到S3。但是当我尝试为IndexFaces读取相同的文件时,它会提示与éxternalImageId'相关的错误。

以下是我上传文件S3的快照:

http://xxxxxx.s3.amazonaws.com/postman/postworld/postman_automated.jpg

如果我摆脱了文件夹结构并直接转储文件,例如:

http://xxxxxx.s3.amazonaws.com/postman_automated.jpg

然后IndexFaces API成功传递它。

如果我有“文件夹结构”,你能否建议如何传递externalImageId?目前我通过我的java代码传递externalImageId,如:

enrolledFileName = userName +"/"+myWorldName+"/"+enrolledFileName;
System.out.println("The FILE NAME MANIPULATED IS:"+enrolledFileName);
String generateAmazonFaceId = amazonRekognitionManagerObj.addToCollectionForEnrollment(collectionName, bucketName, enrolledFileName);
System.out.println("The Generated FaceId is:"+generateAmazonFaceId);**strong text**

以上代码内部调用:

Image image=new Image().withS3Object(new S3Object().withBucket(bucketName)
                              .withName(fileName));

 IndexFacesRequest indexFacesRequest = new IndexFacesRequest()
                  .withImage(image)
                  .withCollectionId(collectionName)
                  .withExternalImageId(fileName)
                  .withDetectionAttributes("ALL");

0 个答案:

没有答案