smartcrop.py icon indicating copy to clipboard operation
smartcrop.py copied to clipboard

Using face detection possible?

Open jaapiyo opened this issue 5 years ago • 6 comments

What would be an easy way to incorporate face detection using openCV or something similair? The original smartcrop.js library has some examples to do this but I can't find anything similair for the Python-port.

jaapiyo avatar Apr 08 '20 21:04 jaapiyo

Hello,

I personally have no time to implement this feature. However, I am ready to help you integrating this criteria to the heuristic.

Thank you.

davidfischer-ch avatar Apr 12 '20 20:04 davidfischer-ch

Regarding your question, I will investigate it promptly.

davidfischer-ch avatar Apr 12 '20 20:04 davidfischer-ch

OK https://github.com/jwagner/smartcrop.js/commit/afc15fd5831a890ce7c97fd7a21f4a5df71cfadb is using the alpha channel to store what they call the "boost" value.

  • The alpha channel is probably zeroed (default).
  • The regions (pixels in alpha channel) with faces are set to a positive value (the weight).
  • Finally, the alpha channel / boost is integrated to the scoring heuristic.

So in summary, integrating a similar feature requires some boilerplate code. I am ready to implement such a skeleton hosting an extra criteria to scoring (boost).

Then I will let you, @jaapiyo, implement a particular boost method (e.g. based on OpenCV face detection).

Do you agree with my proposal?

davidfischer-ch avatar Apr 16 '20 22:04 davidfischer-ch

can anyone help me to integrate face detection?

Abhi5hekk avatar Sep 14 '21 14:09 Abhi5hekk

It has been quite some time, so rebump this issue.

@davidfischer-ch is it possible to detect faces now?

afeezaziz avatar Jul 07 '23 06:07 afeezaziz

I add face detection to the lib. You may have a try: https://github.com/eeyrw/smartcrop.py The OpenCV>=4.8.0 is required due to face detection.

eeyrw avatar Dec 14 '23 02:12 eeyrw