How to convert the co-ordinates of bounding box returned by amazon aws face detect into open cv co-ordinates? As amazon aws just returns the bounding box co-ordinates not the image with box made around its face.
{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 ? if yes where can i get the python code?
download the recognized image and do the following with 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[:] = []
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.