ListCollections在Android App中未列出正确的集合-AWS Rekognition [英] ListCollections is not listing correct collections in Android App - AWS Rekognition

查看:65
本文介绍了ListCollections在Android App中未列出正确的集合-AWS Rekognition的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我已经在这里停留了一个多星期,我知道它有些愚蠢的错误。只是想不通。我正在开发一个项目,该项目有两个平台,即Android& iOS。它是一种面部识别应用程序。
当我尝试从iOS应用程序和python脚本创建/访问集合时,它们都从我的AWS账户访问同一集合。

Ok so I have been stuck here for about more than a week now and I know its some dumb mistake. Just can't figure it out. I am working on a project that is available of two platforms, Android & iOS. Its sort of a facial recognition app. When I try to create/access collections from iOS application and python script, they both access the same collection from my AWS account.

但是当我尝试从Android应用程序访问,它会创建/访问自己的收藏集。 Android应用程序创建的集合只能在此Android应用程序以外的任何地方访问,该Android应用程序也不能访问iOS应用程序或python脚本创建的集合。

But when I try to access from Android application, it creates/accesses it's own collections. The collections created by Android app are neither accessible anywhere other than this Android app nor this android app can access collections created by iOS app or python script.

我尝试列出集合在所有这三个平台上。 iOS和Python列出的集合完全相同,而Android应用列出的集合仅是由android应用创建的集合。

I have tried listing collections on all these three platforms. iOS and Python list exact same collections while the collections listed by Android app are the ones created by an android app only.

这是我用来列出集合的代码android:

Here is the code I am using to list collections on android:

        mCredentialsProvider = new CognitoCachingCredentialsProvider(
                mContext.getApplicationContext(),
                "us-east-2:4xbx0x6x-9xbx-xax7-x9xf-x5x0xexfx1xb", // Identity pool ID
                Regions.US_EAST_2 // Region
        );

        mAmazonRekognitionClient = new AmazonRekognitionClient(mCredentialsProvider);

        ListCollectionsResult listCollectionsResult = mAmazonRekognitionClient.listCollections(new ListCollectionsRequest().withMaxResults(20));
        Log.i(TAG, listCollectionsResult.getCollectionIds().toString());

这是日志结果:


[i_facesbxyxuxqxbxvxlxwx6x7xex5xmxfx,i_facestxnxaxoxoxqxaxwx4xtxuxwxoxrx,root_faces_data]

[i_facesbxyxuxqxbxvxlxwx6x7xex5xmxfx, i_facestxnxaxoxoxqxaxwx4xtxuxwxoxrx, root_faces_data]

p>

This is the python code I using to list collections:

import boto3
client = boto3.client('rekognition')
response = client.list_collections()
print(response['CollectionIds'])

这是结果:


['i_facesbxyxuxqxbxvxlxwx6x7xex5xmxfx','root_faces_data']

['i_facesbxyxuxqxbxvxlxwx6x7xex5xmxfx', 'root_faces_data']

而已。没有其他的。仅此代码。您可以看到一个显示3个集合,而另一个显示两个。
我在iOS应用中使用的区域和身份池ID完全相同,并且列出了与python中相同的集合。
之所以我认为iOS应用很好,是因为iOS和python列出的集合是相同的。
我需要更改什么吗?我需要做任何其他设置才能使其正常工作吗?
请让我知道。谢谢。

That's it. Nothing else. Just this code. You can see that one is showing 3 collections while other is showing two. I am using the exact same region and identity pool ID in iOS app and it's listing same collections as in python. The reason I think iOS app is fine because the collections listed by both iOS and python are same. Is there anything I need to change? Is there any additional setup I need to do to make it work? Please let me know. Thanks.

推荐答案

所以像大多数时候一样,我救了自己。
事实证明,当我们将Cognito凭据传递给Android中的Rekognition客户端时,它没有使用与Cognito相同的区域。因此,我们还必须显式设置Rekognition客户端的区域。像这样:

So like most of the time, I saved myself. Turns out when we pass cognito credentials to Rekognition client in Android, it does not use the same region as that of Cognito. So we have to explicitly set region of Rekognition client as well. Like this:

mAmazonRekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_2));

仅此而已。

这篇关于ListCollections在Android App中未列出正确的集合-AWS Rekognition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆