Beispiel #1
0
 def _get_saliency_matrix(self, position):
     client = AWSClient.get_client('s3')
     response = client.get_object(
         Bucket=Constants.S3_BUCKETS['SALIENCY_MAPS'],
         Key="{}_{}.json".format(self.hit_id, position))
     data = json.load(response['Body'])
     return np.array(data["saliencyMatrix"], np.uint8)
Beispiel #2
0
 def _get_streetview_image(self, position):
     client = AWSClient.get_client('s3')
     response = client.get_object(
         Bucket=Constants.S3_BUCKETS['STREETVIEW_IMAGES'],
         Key="{}_{}.jpg".format(self.hit_id, position))
     img = Image.open(response['Body'])
     # img.show()
     return np.array(img)
Beispiel #3
0
 def _delete_s3_objects(bucket, keys):
     client = AWSClient.get_client('s3')
     key_dict = dict(('Key', keyName) for keyName in keys)
     try:
         client.delete_objects(Bucket=bucket,
                               Delete={'Objects': [key_dict]})
     except Exception:
         print "Couldn't delete the given S3 object."
Beispiel #4
0
 def _read_streetview_img_from_s3(self, position):
     client = AWSClient.get_client('s3')
     response = client.get_object(
         Bucket=Constants.S3_BUCKETS['STREETVIEW_IMAGES'],
         Key="{}_{}.jpg".format(self.ep_id, position)
     )
     img = Image.open(response['Body'])
     # img.show()
     img = np.array(img)
     img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
     return img
Beispiel #5
0
    def _put_marked_streetview_image(img_file, landmark_id):
        client = AWSClient.get_client('s3')

        # Make sure file is "rewound"
        img_file.seek(0)

        # Put cropped image
        client.put_object(
            Body=img_file,
            Bucket=Constants.S3_BUCKETS['MARKED_LANDMARK_IMAGES'],
            Key="{0}.png".format(landmark_id))
Beispiel #6
0
    def _put_cropped_image(img, landmark_id):
        img_file = StringIO()
        img.save(img_file, 'PNG')

        client = AWSClient.get_client('s3')

        # Put cropped image
        client.put_object(
            Body=img_file,
            Bucket=Constants.S3_BUCKETS['TRANSPARENT_CROPPED_IMAGES'],
            Key="{0}.png".format(landmark_id))
Beispiel #7
0
    def _put_cropped_images(candidate):
        img_file = BytesIO()
        transparent_img_file = BytesIO()
        candidate['image'].save(img_file, 'PNG')
        candidate['image_transparent'].save(transparent_img_file, 'PNG')
        img_file.seek(0)
        transparent_img_file.seek(0)

        client = AWSClient.get_client('s3')

        # Put cropped image
        client.put_object(Body=img_file,
                          ContentType='image/png',
                          Bucket=Constants.S3_BUCKETS['CROPPED_IMAGES'],
                          Key="{0}.png".format(candidate['id']))

        # Put transparent cropped image
        client.put_object(
            Body=transparent_img_file,
            ContentType='image/png',
            Bucket=Constants.S3_BUCKETS['TRANSPARENT_CROPPED_IMAGES'],
            Key="{0}.png".format(candidate['id']))