Мне нужно сохранить и распечатать данные из ответа ResponseMetadata о распознавании AWS, но у меня возникла ошибка. Я пишу код с python.
Ошибка:
File "example_eguest_search_V6.py", line 32, in <module>
data = match['HTTPHeaders']['date']
TypeError: string indices must be integers, not str
Код:
import boto3
import io
from PIL import Image
rekognition = boto3.client('rekognition', region_name='eu-west-1')
dynamodb = boto3.client('dynamodb', region_name='eu-west-1')
image = Image.open("sample.jpeg")
stream = io.BytesIO()
image.save(stream,format="JPEG")
image_binary = stream.getvalue()
response = rekognition.search_faces_by_image(
CollectionId='test_Colction',
Image={'Bytes':image_binary}
)
print(response)
for match in response['ResponseMetadata']:
data = match['HTTPHeaders']['date']
print(data)
Ответ AWS Rekognition:
{u'SearchedFaceBoundingBox': {u'Width': 0.4403832256793976, u'Top': 0.3041895925998688, u'Left': 0.22959817945957184, u'Height': 0.3375910222530365}, u'SearchedFaceConfidence': 99.99995422363281, u'FaceMatches': [{u'Face': {u'BoundingBox': {u'Width': 0.27068600058555603, u'Top': 0.2908029854297638, u'Left': 0.3772050142288208, u'Height': 0.3391779959201813}, u'FaceId': u'965d9272-c16b-4055-ab3c-02e70d5a59af', u'Confidence': 100.0, u'ImageId': u'7397f3a2-f38c-38f9-8f96-4a059aa56635'}, u'Similarity': 99.8473892211914}, {u'Face': {u'BoundingBox': {u'Width': 0.3872449994087219, u'Top': 0.3262610137462616, u'Left': 0.279092013835907, u'Height': 0.40818700194358826}, u'FaceId': u'384e2cdd-e0f5-4768-8365-aa01369b8394', u'Confidence': 100.0, u'ImageId': u'c0239570-285b-3ac0-9614-be6f2ec872c1'}, u'Similarity': 94.60191345214844}, {u'Face': {u'BoundingBox': {u'Width': 0.38614898920059204, u'Top': 0.4011250138282776, u'Left': 0.5023319721221924, u'Height': 0.4669739902019501}, u'FaceId': u'08f5570f-bd57-48ee-bc3e-8ae6bd7dfd66', u'Confidence': 99.9999008178711, u'ImageId': u'996a26ce-d9dc-3f9d-bb0d-d61b78ad4422'}, u'Similarity': 94.2291488647461}], u'FaceModelVersion': u'4.0', 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': 'b0b35916-9db9-45db-810d-45b19153d4de', 'HTTPHeaders': {'date': 'Sun, 27 Oct 2019 14:36:14 GMT', 'x-amzn-requestid': 'b0b35916-9db9-45db-810d-45b19153d4de', 'content-length': '1071', 'content-type': 'application/x-amz-json-1.1', 'connection': 'keep-alive'}}}