Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
/ py_save_face_xmp Public archive

Python tool to detect or select faces on jpg images and save the position in the XMP metadata of the image file

Notifications You must be signed in to change notification settings

cvzi/py_save_face_xmp

Repository files navigation

py_save_face_xmp

Python tool to detect or select faces on jpg images and save the position in the XMP metadata of the image file.

The faces are stored in the JPG metadata in XMP tags. The standard is defined by the Metadata Working Group Regions schema. These tags are for example supported by Picasa which can also read and write them. An example path looks like this: Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Name

The script uses the GExiv2 python API to read the XMP tags and exiv2 in the command line to write the tags (because writing XMP arrays/bags is not possible with GExiv2).

The images are displayed using opencv and the face detection is also done with opencv

Tested with/required software:

Run with pythonw setFaceByHand.pyw in the directory of the jpg files.

Controls:

  • Left mouse: draw rectangle around face
  • Right mouse: reset rectangle
  • Middle mouse: select detected face
  • Enter: save face to image metadata
  • Left arrow: previous image
  • Right arrow: skip image
  • q or Ctrl-c: quit

Currently the name for the faces is taken from the filename like this: Thomas,Peter,Jake.jpg results in the first face beeing named Thomas, the second named Peter and the third face named Jake.

This software is licensed under GPLv3, except for the files haarcascade_profileface.xml and haarcascade_frontalface_alt.xml which were taken from opencv. Look into the files for details on their licenses.