Compare two images by using AWS Rekognition error












0















I try to compare the two image which is in s3.
So I have completed the code by referring to the following:
https://docs.aws.amazon.com/ko_kr/rekognition/latest/dg/faces-comparefaces.html



I made the IdentityPool with Role(S3 Full Access, Rekognition Full Access).



try{

CompareFacesRequest compareFacesRequest = new CompareFacesRequest().
withSourceImage(new Image().withS3Object(new S3Object().withName(photo1).withBucket(bucket))).
withTargetImage(new Image().withS3Object(new S3Object().withName(photo2).withBucket(bucket))).withSimilarityThreshold(80F);

CompareFacesResult result = amazonRekognitionClient.compareFaces(compareFacesRequest);
List<CompareFacesMatch> list = result.getFaceMatches();

Log.d(TAG,"testing..");

if (!list.isEmpty()){

Log.d(TAG,"face match");

for (CompareFacesMatch match:list){
Log.d(TAG,match.getFace() + "" + match.getSimilarity());
}

}else{

Log.d(TAG,"face dismatch");

}

}catch (Exception e){

Log.d(TAG,"Exception occurs");
e.printStackTrace();

}


But it makes that error.
com.amazonaws.services.rekognition.model.InvalidS3ObjectException: Unable to get object metadata from S3. Check object key, region and/or access permissions. (Service: AmazonRekognition; Status Code: 400; Error Code: InvalidS3ObjectException; Request ID: 2c4720e3-0e67-11e9-a286-7761b1c828e5)



I thought if I make a mistake of IAM, the app can't upload the file.
I try to upload the file with same credentialsProvider, upload success.



I don't think that's what happened because of permission.



S3 region is in Seoul, and Cognito IdentityPool region is AP_NORTHEAST_2



is there any information to get s3 object with Rekognition?










share|improve this question



























    0















    I try to compare the two image which is in s3.
    So I have completed the code by referring to the following:
    https://docs.aws.amazon.com/ko_kr/rekognition/latest/dg/faces-comparefaces.html



    I made the IdentityPool with Role(S3 Full Access, Rekognition Full Access).



    try{

    CompareFacesRequest compareFacesRequest = new CompareFacesRequest().
    withSourceImage(new Image().withS3Object(new S3Object().withName(photo1).withBucket(bucket))).
    withTargetImage(new Image().withS3Object(new S3Object().withName(photo2).withBucket(bucket))).withSimilarityThreshold(80F);

    CompareFacesResult result = amazonRekognitionClient.compareFaces(compareFacesRequest);
    List<CompareFacesMatch> list = result.getFaceMatches();

    Log.d(TAG,"testing..");

    if (!list.isEmpty()){

    Log.d(TAG,"face match");

    for (CompareFacesMatch match:list){
    Log.d(TAG,match.getFace() + "" + match.getSimilarity());
    }

    }else{

    Log.d(TAG,"face dismatch");

    }

    }catch (Exception e){

    Log.d(TAG,"Exception occurs");
    e.printStackTrace();

    }


    But it makes that error.
    com.amazonaws.services.rekognition.model.InvalidS3ObjectException: Unable to get object metadata from S3. Check object key, region and/or access permissions. (Service: AmazonRekognition; Status Code: 400; Error Code: InvalidS3ObjectException; Request ID: 2c4720e3-0e67-11e9-a286-7761b1c828e5)



    I thought if I make a mistake of IAM, the app can't upload the file.
    I try to upload the file with same credentialsProvider, upload success.



    I don't think that's what happened because of permission.



    S3 region is in Seoul, and Cognito IdentityPool region is AP_NORTHEAST_2



    is there any information to get s3 object with Rekognition?










    share|improve this question

























      0












      0








      0








      I try to compare the two image which is in s3.
      So I have completed the code by referring to the following:
      https://docs.aws.amazon.com/ko_kr/rekognition/latest/dg/faces-comparefaces.html



      I made the IdentityPool with Role(S3 Full Access, Rekognition Full Access).



      try{

      CompareFacesRequest compareFacesRequest = new CompareFacesRequest().
      withSourceImage(new Image().withS3Object(new S3Object().withName(photo1).withBucket(bucket))).
      withTargetImage(new Image().withS3Object(new S3Object().withName(photo2).withBucket(bucket))).withSimilarityThreshold(80F);

      CompareFacesResult result = amazonRekognitionClient.compareFaces(compareFacesRequest);
      List<CompareFacesMatch> list = result.getFaceMatches();

      Log.d(TAG,"testing..");

      if (!list.isEmpty()){

      Log.d(TAG,"face match");

      for (CompareFacesMatch match:list){
      Log.d(TAG,match.getFace() + "" + match.getSimilarity());
      }

      }else{

      Log.d(TAG,"face dismatch");

      }

      }catch (Exception e){

      Log.d(TAG,"Exception occurs");
      e.printStackTrace();

      }


      But it makes that error.
      com.amazonaws.services.rekognition.model.InvalidS3ObjectException: Unable to get object metadata from S3. Check object key, region and/or access permissions. (Service: AmazonRekognition; Status Code: 400; Error Code: InvalidS3ObjectException; Request ID: 2c4720e3-0e67-11e9-a286-7761b1c828e5)



      I thought if I make a mistake of IAM, the app can't upload the file.
      I try to upload the file with same credentialsProvider, upload success.



      I don't think that's what happened because of permission.



      S3 region is in Seoul, and Cognito IdentityPool region is AP_NORTHEAST_2



      is there any information to get s3 object with Rekognition?










      share|improve this question














      I try to compare the two image which is in s3.
      So I have completed the code by referring to the following:
      https://docs.aws.amazon.com/ko_kr/rekognition/latest/dg/faces-comparefaces.html



      I made the IdentityPool with Role(S3 Full Access, Rekognition Full Access).



      try{

      CompareFacesRequest compareFacesRequest = new CompareFacesRequest().
      withSourceImage(new Image().withS3Object(new S3Object().withName(photo1).withBucket(bucket))).
      withTargetImage(new Image().withS3Object(new S3Object().withName(photo2).withBucket(bucket))).withSimilarityThreshold(80F);

      CompareFacesResult result = amazonRekognitionClient.compareFaces(compareFacesRequest);
      List<CompareFacesMatch> list = result.getFaceMatches();

      Log.d(TAG,"testing..");

      if (!list.isEmpty()){

      Log.d(TAG,"face match");

      for (CompareFacesMatch match:list){
      Log.d(TAG,match.getFace() + "" + match.getSimilarity());
      }

      }else{

      Log.d(TAG,"face dismatch");

      }

      }catch (Exception e){

      Log.d(TAG,"Exception occurs");
      e.printStackTrace();

      }


      But it makes that error.
      com.amazonaws.services.rekognition.model.InvalidS3ObjectException: Unable to get object metadata from S3. Check object key, region and/or access permissions. (Service: AmazonRekognition; Status Code: 400; Error Code: InvalidS3ObjectException; Request ID: 2c4720e3-0e67-11e9-a286-7761b1c828e5)



      I thought if I make a mistake of IAM, the app can't upload the file.
      I try to upload the file with same credentialsProvider, upload success.



      I don't think that's what happened because of permission.



      S3 region is in Seoul, and Cognito IdentityPool region is AP_NORTHEAST_2



      is there any information to get s3 object with Rekognition?







      amazon-s3 amazon-cognito amazon-rekognition






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 1:48









      Polaris NationPolaris Nation

      213321




      213321
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I think you have to use rekognitionClient.setRegion() operation.



          E.g: amazonrekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_1));



          Hope it might Helps.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015378%2fcompare-two-images-by-using-aws-rekognition-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I think you have to use rekognitionClient.setRegion() operation.



            E.g: amazonrekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_1));



            Hope it might Helps.






            share|improve this answer




























              1














              I think you have to use rekognitionClient.setRegion() operation.



              E.g: amazonrekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_1));



              Hope it might Helps.






              share|improve this answer


























                1












                1








                1







                I think you have to use rekognitionClient.setRegion() operation.



                E.g: amazonrekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_1));



                Hope it might Helps.






                share|improve this answer













                I think you have to use rekognitionClient.setRegion() operation.



                E.g: amazonrekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_1));



                Hope it might Helps.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 5 at 4:11









                Deependra DangalDeependra Dangal

                3177




                3177
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015378%2fcompare-two-images-by-using-aws-rekognition-error%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith