Page 1 of 1

detect_faces resize

Posted: 2018-06-11T19:30:16-07:00
by FurrySilver
I am using Amazon Face Detection, and they return me data that looks like this.

BoundingBoxHeight BoundingBoxLeft BoundingBoxTop BoundingBoxWidth
0.082051284611225000 0.602564096450806000 0.697435915470123000 0.061538461595774000

How do I pass this data to ImageMagick to create a thubnail of the face?

Re: detect_faces resize

Posted: 2018-06-11T20:28:17-07:00
by fmw42
BoundingBoxHeight BoundingBoxLeft BoundingBoxTop BoundingBoxWidth

try using the values as

convert input -crop BoundingBoxWidthxBoundingBoxHeight+BoundingBoxLeft+BoundingBoxTop +repage output

Re: detect_faces resize

Posted: 2018-06-11T20:55:03-07:00
by FurrySilver
That doesn't crop the photo

magick c:\image.jpg -crop 0.061538461595774000x0.082051284611225000+0.602564096450806000+0.697435915470123000 +repage c:\final.jpg

Re: detect_faces resize

Posted: 2018-06-11T21:02:44-07:00
by fmw42
Your numbers are not in pixel units. What units are they? How are they measured? What are the pixel dimensions of the full image as width and height. Are these numbers in the range 0 to 1 relative to the pixel width and height of the input image? Are they in inches or centimeters? Please clarify the coordinate system for your measurements.

From https://docs.aws.amazon.com/rekognition ... ngBox.html, it looks like they are fractions of the width and height. So multiply your numbers by with width and height of the input in pixels and put those numbers in.

Or put your numbers in the following

Code: Select all

magick input.jpg -crop "%[fx:w*BoundingBoxWidth]x%[fx:h* BoundingBoxHeight]+%[fx:w*BoundingBoxLeft]+$[fx:h*BoundingBoxTop]" +repage output.jpg
where w,h will be determined from the input image automatically, so leave as w and h.