Skip to content

Detection algorithms

heynemann edited this page Mar 25, 2011 · 23 revisions

If the smart mode of thumbor has been specified in the uri (by the /smart portion of it), thumbor will use it's smart detectors to find focal points.

thumbor comes pre-packaged with two focal-point detection algorithms: facial and feature. First it tries to identify faces and if it can't find any, it tries to identify features (more on that below).

Facial Detection

thumbor uses OpenCV to detect faces. OpenCV returns the rectangle coordinates for the faces it identifies. Thumbor supports changing the file that OpenCV uses for identifying faces. Below is a comparison of three different algorithms:

original.png facial_detection_1.png facial_detection_2.png facial_detection_3.png

After retrieving these squares from OpenCV, thumbor calculates the center of mass of the image using weighted average.

Consider that OpenCV returned 3 squares at (10, 10, 100, 100), (150, 100, 100, 100), (300, 300, 80, 50), being (x, y, width, height), as such:

Faces at 10, 10 - 150, 100 - 300, 300Faces at 10, 10 - 150, 100 - 300, 300

In order to find the center of mass for all the faces, we must first find the center of each square and

Clone this wiki locally