Posting an update on the solution we opted for to move forward until it's clarified by the Meraki product team. We have to crop an image received by the Snapshot API endpoint based on the MQTT person detection coordinates. Below is a sample code function we are using to not rely on the assumption, but instead implement the logic of how image coordinates work. from PIL import Image
def img_crop(img_path, box):
img = Image.open(img_path)
# note img.size in PIL returns width first
w, h = img.size
# here we find the min/max of image coordinates to avoid ambiguity
xmin=min(box['x0'], box['x1'])
xmax=max(box['x0'], box['x1'])
ymin=min(box['y0'], box['y1'])
ymax=max(box['y0'], box['y1'])
# calculate the crop_region based on image dimensions (width, height)
crop_region = (xmin*w, ymin*h, xmax*w, ymax*h)
# we found MV detects the body to identify a person but in our case
# it is crucial to have a face so we scale the region using below
# this could be applied based on your requirements
# crop_region = (xmin*w*0.75, ymin*h*0.75, xmax*w*1.25, ymax*h*1.25)
# crop expects (left, upper, right, lower)
return img.crop(crop_region)
if __name__ == '__main__':
box = {
'x0': 1.0,
'x1': 0.89,
'y0': 0.861,
'y1': 0.546
}
croped = img_crop(img_path='test_img12.jpg',box=box)
croped.save('croped.jpg')
... View more