简体   繁体   English

转换亚马逊AWS坐标

[英]Convert amazon aws co-ordinates

How to convert the co-ordinates of bounding box returned by amazon aws face detect into open cv co-ordinates? 怎么把亚马逊aws face detection返回的边界框的坐标转换成开放的cv坐标? As amazon aws just returns the bounding box co-ordinates not the image with box made around its face. 正如亚马逊的aws只是返回边界框坐标,而不是带有围绕其面部的框的图像。

{u'BoundingBox': {u'Height': 0.45597776770591736,
                  u'Left': 0.16144350171089172,
                  u'Top': 0.21130676567554474,
                  u'Width': 0.5840455889701843},}

Suppose these are the bounding box co-ordinates of a image. 假设这些是图像的边界框坐标。 Can Amazon aws can draw box around face ? 亚马逊aws可以在脸部周围画框吗? if yes where can i get the python code? 如果是,我在哪里可以获取python代码?

download the recognized image and do the following with opencv 下载识别的图像,然后使用opencv执行以下操作

 widtho = 717 #width of the given image
 heighto = 562 #height of the given image
 counter = 0
 facecount = 1
 s3 = boto3.resource('s3')
 bucket = s3.Bucket('rek')
 if __name__ == "__main__":
 #Choosing the file in s3 bucket
     photo = 'sl.jpg'
     bucket = 'rek'
 #Intilization of rekognition and performing detect_faces 
 client = boto3.client('rekognition', region_name='eu-west-1')
 response = client.detect_faces(
 Image={'S3Object': {'Bucket': bucket, 'Name': photo}}, Attributes=['ALL'])
 print('Detected faces for ' + photo)
 print('The faces are detected and labled from left to right')
 for faceDetail in response['FaceDetails']:
     print('Face Detected= ', i)
     #To mark a bounding box of the image using coordinates
     print('Bounding Box')
     bboxlen = len(faceDetail['BoundingBox'])
     print(bboxlen)
     width = faceDetail['BoundingBox'].get('Width')
     height = faceDetail['BoundingBox'].get('Height')
     left = faceDetail['BoundingBox'].get('Left')
     top = faceDetail['BoundingBox'].get('Top')
     w = int(width * widtho)
     h = int(height * heighto)
     x = int(left * widtho)
     y = int(top * heighto)
     imagere = cv2.imread('imagename.jpg')#the image to append rects of all faces
     cv2.rectangle(imagere, (x, y), (x + w, y + h), (255, 0, 0), 2)
     cv2.imwrite('imagename.jpg', imagere)
     facecount = facecount + 1
     abc[:] = []

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM