GNU/Linux Desktop Survival Guide
by Graham Williams |
|||||
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 |
The photo used here was taken by Eugenio Hansen, OFS, CC BY-SA 3.0.