auduno/clmtrackr

Detect "face" in picture and crop it

Closed this issue · 1 comments

Hi ,

Can you make an example of this script to detect the face from an image and then crop it in a new canvas?
Or please give me some hints.. i am struggling.... :)

Thanks for your time.

I know this was a minute ago, but I think a solid way of approaching this would be to use simple Haar Face Detection and then ROI (Region of interest). It seems to me using this face tracking is overkill for simply cropping a face out of an image. That said it would here is how I would do it using this face tracker. I would use p5.js as it will make the code simpler. Here is a piece of starter code using p5 and the clm tracker. Here are the steps I would follow:

  1. Iterate through the points to find the rough bounding box. As you go through the points keep track of the left most, right most, highest, and lowest positions to create the bounding box.
  2. Use the p5 copy function to crop out this bounding box.
  3. render this roi to an offscreen buffer using the p5 createGraphics function.
  4. save the image using save frame if that is what you are trying to do.