用于Amazon Rekognition的Junit测试用例

时间:2018-10-16 10:18:34

标签: junit amazon-rds

如何在Junit中编写一个用于亚马逊Rekognition的测试用例。

public class SearchFaceMatchingImageCollection {
    public static final String collectionId = "MyCollection";
    public static final String bucket = "bucket";
    public static final String photo = "input.jpg";
    public static void main(String[] args) throws Exception {
        AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient();
        ObjectMapper objectMapper = new ObjectMapper();

        // Get an image object from S3 bucket.
        Image image=new Image()
                      .withS3Object(new S3Object()
                      .withBucket(bucket)
                      .withName(photo));

      // Search collection for faces similar to the largest face in the image.
         SearchFacesByImageRequest searchFacesByImageRequest = new SearchFacesByImageRequest()
                .withCollectionId(collectionId)
                .withImage(image)
                .withFaceMatchThreshold(70F)
                .withMaxFaces(2);
         SearchFacesByImageResult searchFacesByImageResult = 
           rekognitionClient.searchFacesByImage(searchFacesByImageRequest);

         System.out.println("Faces matching largest face in image from" + photo);
         List < FaceMatch > faceImageMatches = searchFacesByImageResult.getFaceMatches();
         for (FaceMatch face: faceImageMatches) {
             System.out.println(objectMapper.writerWithDefaultPrettyPrinter()
              .writeValueAsString(face));
             System.out.println();
  }
}
}

对于上述程序,我想编写一个Junit测试用例。请同样帮助我

0 个答案:

没有答案