Yesterday I played around face recognition in ColdFusion with Jviolajones and it did a good job detecting faces off an image and providing with the coordinates. The final goal of this exercise is to create thumbnails of images focusing on faces, if there are any to be found in the image.
Here is my sample image. There are two faces on them.
First I want to bring them into a single frame. I would like to include all the faces into the final thumbnail if possible.
Faces can be spread across the image and this frame won’t have a fix shape and I like my thumbnail image to be square.
Normally the face detection could be very tight. Adding bit of padding make the frame bit nicer. I’m adding extra 30% of the face size.
Adding extra space often can bring about extra problems. Now our frame goes outside the main image and we have to fix that.
Now we have a perfect crop.
And a thumbnail image
Here is the code. Please note, you have to bring in Jviolajones library first and please refer to the previous post.