Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Bounding Box onto an Image

Bounding boxes are often used to highlight specific regions within an image, such as a face. Here we use the MLHub package azcv to obtain the bounding box of a face and to then annotate the image appropriately.

$ wget -O img.jpg \
https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/\
Laurence_Freeman11.JPG/800px-Laurence_Freeman11.JPG

$ ml faces azcv img.jpg 
263 205 529 471,Male,58

$ ml faces azcv img1.jpg | tee img1.bb
263 205 529 471,Male,58

$ cat img.bb |
  cut -d, -f1 |
  xargs printf '-draw "rectangle %s,%s %s,%s" ' |
  awk '{print "img.jpg -fill none -stroke blue -strokewidth 3 " $0 "img_faces.png"}' |
  xargs convert

$ display img_faces.png

Figure 36.4: Using imagemagick to draw a bounding box onto an image.
Image imagemagick_bb

The photo used here was taken by Eugenio Hansen, OFS, CC BY-SA 3.0.


Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © Togaware Pty Ltd. . Creative Commons ShareAlike V4.