detect_faces resize

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
FurrySilver
Posts: 2
Joined: 2018-06-11T19:26:41-07:00
Authentication code: 1152

detect_faces resize

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: detect_faces resize

Post by fmw42 »

BoundingBoxHeight BoundingBoxLeft BoundingBoxTop BoundingBoxWidth

try using the values as

convert input -crop BoundingBoxWidthxBoundingBoxHeight+BoundingBoxLeft+BoundingBoxTop +repage output
FurrySilver
Posts: 2
Joined: 2018-06-11T19:26:41-07:00
Authentication code: 1152

Re: detect_faces resize

Post by FurrySilver »

That doesn't crop the photo

magick c:\image.jpg -crop 0.061538461595774000x0.082051284611225000+0.602564096450806000+0.697435915470123000 +repage c:\final.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: detect_faces resize

Post 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.
Post Reply