Ask Your Question

Revision history [back]

Thumbor's smart detection might help you do that - https://github.com/thumbor/thumbor/wiki/Detection-algorithms

Thumbor is a HTTP Service that helps you do anything with images. The Focal Points are provided provided by the Good Features to Track Algorithm in OpenCV (in case no faces are Detected, in the cases of Faces, it will use Face Detection to detect the Focal Points)

To get the Focal Points you will need to use the smart detection algorithm, usually used in the crop service, but you can use it if you don't even crop.

Example:

To smart crop a image and center in a 720x720 box:

localhost:8888/unsafe/720x720/smart/yourimage.jpg

but you can exclude the crop dimensions and get just the meta:

localhost:8888/unsafe/meta/smart/yourimage.jpg

That will give you something like this:

{ "thumbor": 
  {
  "operations":[],
  "source":{
     "url":"yourimage.jpg",
     "width":1280,
     "frameCount":1,
     "height":720
  },
  "focal_points":[
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":235.0,
        "x":708.0,
        "z":1.0
     },
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":263.0,
        "x":663.0,
        "z":1.0
     },
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":235.0,
        "x":573.0,
        "z":1.0
     },
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":263.0,
        "x":618.0,
        "z":1.0
     },
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":324.0,
        "x":654.0,
        "z":1.0
     },
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":373.0,
        "x":653.0,
        "z":1.0
     },
     {
        "origin":"alignment",
        "height":1.0,
        "width":1.0,
        "y":280.0,
        "x":654.0,
        "z":1.0
     }
  ],
  "target":{
     "width":1280,
     "height":720
      }
   }
 }

Hope this helps :D