【发布时间】:2018-11-03 13:51:14
【问题描述】:
因此,我长期以来一直致力于开发一种产品(首先是 Android,然后是 iOS),该产品可以索引使用 AWS Rekognition 的人的面孔,并且当他们稍后再次被扫描时,它会识别出他们。 当我从 Android 设备索引人脸然后尝试使用 Android 设备搜索它时,它工作得很好。但如果我稍后尝试在 iOS 应用程序上搜索它,它不会找到它。如果我反过来,结果也是一样。用 iOS 索引,用 Android 搜索,没有找到。 在两个设备上进行索引和搜索时,集合 ID 相同。我不知道在其他设备上找不到由一种操作系统类型、相同区域、相同集合索引的面孔。
如果这里有人可以尝试帮助我解决这个问题,请这样做。我会很感激的。
更新 1:我在 iOS 和 android 应用程序上都调用了“listCollections”函数。他们都显示了不同的收藏列表。这就是问题所在。但我无法弄清楚我们为什么会这样。两者的身份池和区域相同。
这是我访问 Rekognition 的 Android 代码:
mCredentialsProvider = new CognitoCachingCredentialsProvider(
mContext,
"us-east-2:xbxfxexf-x5x5-xax7-x9xf-x5x0xexfx1xb", // Identity pool ID
Regions.US_EAST_2 // Region
);
mUUID = UUID.randomUUID().toString().replace("-", "");
mAmazonS3Client = new AmazonS3Client(mCredentialsProvider);
mAmazonS3Client.setRegion(Region.getRegion(Regions.US_EAST_2));
mAmazonRekognitionClient = new AmazonRekognitionClient(mCredentialsProvider);
if(!mAmazonS3Client.doesBucketExist(mFacesBucket)) {
mAmazonS3Client.createBucket(mFacesBucket);
}
Log.i(TAG, "Uploading image to S3 Bucket");
mAmazonS3Client.putObject(mFacesBucket, getS3ObjectName(), new File(data[0].toString()));
Log.i(TAG, "Image Uploaded");
Image image = new Image();
try {
image.setBytes(ByteBuffer.wrap(Files.toByteArray(new File(data[0].toString()))));
} catch (IOException e) {
e.printStackTrace();
}
Log.i(TAG, "Indexing image");
IndexFacesRequest indexFacesRequest =new IndexFacesRequest()
.withCollectionId(mFacesCollection)
.withImage(image)
.withExternalImageId(mUUID)
.withDetectionAttributes("ALL");
mAmazonRekognitionClient.indexFaces(indexFacesRequest);
这是我访问 Rekognition 的 iOS 代码:
func uploadToCollection(img: UIImage)
{
let myIdentityPoolId="us-east-2:xbxfxexf-x5x5-xax7-x9xf-x5x0xexfx1xb"
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USEast2, identityPoolId: myIdentityPoolId)
//store photo in s3()
let configuration = AWSServiceConfiguration(region: .USEast2, credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
rekognitionClient = AWSRekognition.default()
guard let request = AWSRekognitionIndexFacesRequest() else
{
puts("Unable to initialize AWSRekognitionindexFaceRequest.")
return
}
var go=false
request.collectionId = "i_faces" + self.firebaseID.lowercased() //here iosCollection will be replaced by firebase Current UserID
request.detectionAttributes = ["ALL", "DEFAULT"]
request.externalImageId = self.UUID //this should be mUUID, passed as parameter to this function
let sourceImage = img
let image = AWSRekognitionImage()
image!.bytes = sourceImage.jpegData(compressionQuality: 0.7)
request.image = image
self.rekognitionClient.indexFaces(request) { (response:AWSRekognitionIndexFacesResponse?, error:Error?) in
if error == nil
{
print("Upload to Collection Complete")
}
go=true
return
}
while(go==false){}
}
【问题讨论】:
标签: android ios amazon-web-services aws-sdk amazon-rekognition