Author Topic: Face detection  (Read 8832 times)

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13669
    • ExifTool Home Page
Face detection
« on: March 01, 2011, 08:03:24 AM »
Attached is a script I wrote to test the face detection information written by Canon, FujiFilm, Nikon, Olympus, Panasonic, Pentax and Sony cameras.

The script draws a box around each face, and outputs a set of reduced-size JPEG images (see sample below).  It works well with all of my test images, but I haven't tested it with all models.  It requires ExifTool 8.53 or later.

I am providing this script to serve as an example of how to use the face detection information, since I thought it might be useful for other developers.

The following makes are supported:

Canon, Casio, FujiFilm, Nikon, Olympus, Panasonic, Pentax, Ricoh, Sanyo and Sony.

- Phil



P.S.  Thanks to Jeffrey Friedl for the sample images.

PH 2011-03-27: Updated to add support for more makes.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

evilaro

  • Sr. Member
  • ****
  • Posts: 114
    • EvilFOTO
Re: Face detection
« Reply #1 on: March 03, 2011, 06:15:55 PM »
Phil:

This seems very very very interesting...  ;) but I really do not
know anythig regarding Perl...

So... would it be posible just to have a parameter using Exiftool
that detects if a file has one ore more of this squares, boxes, faces or whatever.

Then it will be simple just to look at the images that has faces.

Thanks

Emilio


www.evilfoto.eu
*************

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13669
    • ExifTool Home Page
Re: Face detection
« Reply #2 on: March 03, 2011, 07:00:53 PM »
Hi Emilio,

For 90% of the models you can just check to see if FacesDetected exists and is non-zero.

The 10% are newer Canon models which use the AF areas to store the face positions.  For these you must check AFAreaMode to see if it is "Face Detect AF", then check ValidAFPoints to see if it is non-zero.

- Phil

Edit: But note that this will only work for images where the camera was set to face detection mode.
« Last Edit: March 03, 2011, 07:08:47 PM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

evilaro

  • Sr. Member
  • ****
  • Posts: 114
    • EvilFOTO
Re: Face detection
« Reply #3 on: March 04, 2011, 06:37:16 AM »
Hi Phil:

I have scaned 60 000 images ;) in order to find
some faces. Very few anyway found... I do not use it to much

The compact cameras are the ones that have it most.

I use this format which show the file wanted code

      run(false, 'exiftool.exe -r -FacesDetected "&DIR"  > result.csv' )    

But the result is always (when there is a face) Face Detected = 0
And I never get more than 0.


But if I look at that file, there is a face

I understood reading your comment that it should state at least 1...

Am I doing something wrong?

This is what I see on the exif file

Face Detect Frame Width         : 0
Face Detect Frame Height        : 0
Faces Detected                       : 0



-other point
Also while doing this big scanning, on the CMD (DOS) windows, there was many errors showing,
regarding to printing or problems with the file....

I would like in order to see what are this errors to see them on the result.csv file
is this possible?


Thanks

« Last Edit: March 04, 2011, 06:59:01 AM by evilaro »
www.evilfoto.eu
*************

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13669
    • ExifTool Home Page
Re: Face detection
« Reply #4 on: March 04, 2011, 07:15:43 AM »
You can use the -T option to generate a tab-delimited output file, and extract the Error and Warning tags if you want too:

exiftool -r -T -FacesDetected -Warning -Error "&DIR" > out.csv

It is not surprising that FacesDetected is always zero.  As I said, the camera must be in face detect mode, and with random sample images I find that most people do not seem to use this mode.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

evilaro

  • Sr. Member
  • ****
  • Posts: 114
    • EvilFOTO
Re: Face detection
« Reply #5 on: March 07, 2011, 10:59:33 AM »
Phil:

This week-nd I have taken 2 compact camera with the Face mode detection activated

Canon G11 (2 years old) and Casio Exilin EX-H20G (the one that comes with GPS) its a this year camera.

When I am taking pictures I see the Boxes around the faces, moving and following the faces.
So all is as expected ;)

a) The Canon camera comes with the Face information on The exif.

Using
exiftool.exe -r -AFAreaMode "&DIR"  > resultado.csv


I get this on the images that have faces...

AF Area Mode                : Face Detect AF


which is near perfect.
But there is one image that has Faces but is not detected with this tag

But looking at the AF Point shows this.
AF Point                        : Face Detect

How can I get this AF Point ? .... or to make the question more general, if using Exiftool I get
a tag, on the list How can get the -  value to put on the equation

-AFPoint  doe not work.

b) On the Casio Images I have tried the previos system and this one

    'exiftool.exe -r -FacesDetected "&DIR"  > resultado.csv


Unfourtunatelly the result is Nill.

I have looked at the exif of the images that I know have faces and there is nothing that would indicate that
data regarding faces has been addedto the exifdata.
Comparing this exif with one of a image without faces seemsequal..

So I do not know if this data is placed some other place or Casio only uses the face boxes to
focus the image but does not add the exif data.

I could send you a few files if yo want.

Thanks

Emilio

www.evilfoto.eu
*************

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13669
    • ExifTool Home Page
Re: Face detection
« Reply #6 on: March 07, 2011, 12:14:20 PM »
Hi Emilio,

But looking at the AF Point shows this.
AF Point                        : Face Detect

How can I get this AF Point ?

I think this is what happens if face detection is on but the camera doesn't detect any faces (which can happen even if there are faces in the image).

Quote
So I do not know if this data is placed some other place or Casio only uses the face boxes to
focus the image but does not add the exif data.

I could send you a few files if yo want.

Yes, the Casio faces are not yet decoded.  I have some samples but need more to be able to decode this (if it exists).  If you could send samples it would be great (send them to phil at owl.phy.queensu.ca).  Samples with different numbers and multiple faces would be best.  Also, some with the camera rotated.

Thanks

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

evilaro

  • Sr. Member
  • ****
  • Posts: 114
    • EvilFOTO
Re: Face detection
« Reply #7 on: March 16, 2011, 11:40:45 AM »
Phil:

I have visited some friends that had
2 cameras with face detection... (not activated.. of course)

Image Description               : OLYMPUS DIGITAL CAMERA
Make                                : OLYMPUS IMAGING CORP.
Camera Model Name            : E-P2

and

Make                                  : Panasonic
Camera Model Name              : DMC-GH1



After activating the face mode detection we took a few pictures.

I run
         exiftool.exe -r -FacesDetected -AFAreaMode "&DIR"  > resultado.csv

and did not find anythig

I looked into the EXIF... and in all cases there was a FACE wording... so Exif has the
information but -FacesDetected -AFAreaMode   does not find it.

I understand that this camera would requiere ANOTHER parameter... but this is getting complicated (I should not tell you this.. you know it already)
if you have to have a special parameter for each cámera...


So I have done another aproach... LIST all the EXif and search for the Word FACE, it takes longer
but it seems FACE is the word used, and is not used in any other context...
So the faces are found


I can send you if you want the files if you want

Any other suggestion?

Emilio




www.evilfoto.eu
*************

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13669
    • ExifTool Home Page
Re: Face detection
« Reply #8 on: March 16, 2011, 01:23:36 PM »
Hi Emilio,

Please send me the files and I'll take a look.  It sounds like my script may not work for these models.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13669
    • ExifTool Home Page
Re: Face detection
« Reply #9 on: March 16, 2011, 02:18:41 PM »
Hi Emilio,

I got the samples, thanks.

Perhaps you are using an old version of ExifTool (before 8.50), because the current version returns FacesDetected, and my script works just fine for all of the samples you sent.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

evilaro

  • Sr. Member
  • ****
  • Posts: 114
    • EvilFOTO
Re: Face detection
« Reply #10 on: March 16, 2011, 04:41:53 PM »
Phil:

Yes.... Sorry, since It was working with my Canon Camara I did not think
it was a Exiftool version problem.

Now its working

Thanks

Emilio


Hi Emilio,

I got the samples, thanks.

Perhaps you are using an old version of ExifTool (before 8.50), because the current version returns FacesDetected, and my script works just fine for all of the samples you sent.

- Phil
www.evilfoto.eu
*************