Lightroom face region metadata

Started by asielen, January 01, 2021, 08:44:03 PM

Previous topic - Next topic

asielen

I have been digging into Regions in the xmp metatdata of my photos edited by lightroom. I am trying to pull that data out and use it. I came across an issue though with photos that lightroom "auto tags" faces, as faces but without names. So these are face outlines that have no name.

I have a photo with 5 names listed in XMP:RegionName
BUT there are 6 coordinates in each of XMP:RegionArea[x,y,w,h]
Also XMP:RegionType has face listed 6 times.

I was thinking I could just take the first 5 coordinates but the unnamed one is actually in the middle of the other coordinates. So I am not sure how lightroom knows which one belongs to the unnamed region.

I was also thinking that Lightroom stored the info elsewhere because it is able to correctly line up the coordinates with the faces. However I also exported the photo renamed it and reimported it and it still identified the faces correctly.

Anyone have any insight?
My current thought is that maybe the raw metadata has a Null value in the XMP:RegionNames that exiftool is ignoring and stripping out, not sure how I would validate that though.

Phil Harvey

Quote from: asielen on January 01, 2021, 08:44:03 PM
I was thinking I could just take the first 5 coordinates but the unnamed one is actually in the middle of the other coordinates. So I am not sure how lightroom knows which one belongs to the unnamed region.

Take a look at the ExifTool output when using the -struct option.

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

StarGeek

The regions are saved as Structured data.  Exiftool will flatten the data to present it in an easy to view format, but the actual data is much more complex.  If you're familiar with programming language, in Perl it's basically set up like a Hash.  In Python, it's like a Dictionary (I think, I don't know Python).

If you extract the actual tag using the -struct option, you'll get something like this.
exiftool -g1 -a -s -struct -regioninfo y:\!temp\Test4.jpg
---- XMP-mwg-rs ----
RegionInfo                      : {AppliedToDimensions={H=3000.000000,Unit=pixel,W=2233.000000},RegionList=[{Area=
{H=0.086000,Unit=normalized,W=0.115591,X=0.595430,Y=0.155000},Name=John Doe,Type=Face},{Area=
{H=0.087000,Unit=normalized,W=0.115591,X=0.376344,Y=0.193500},Name=Jane Doe,Type=Face}]}


Here's what it looks like formatted in a more readable fashion
{
AppliedToDimensions=
{
H=3000.000000,
Unit=pixel,
W=2233.000000
},
RegionList=[
{
Area={
H=0.086000,
Unit=normalized,
W=0.115591,
X=0.595430,
Y=0.155000
},
Name=John Doe,
Type=Face
},
{
Area={
H=0.087000,
Unit=normalized,
W=0.115591,
X=0.376344,
Y=0.193500
},
Name=Jane Doe,
Type=Face
}
]
}


So you have the AppliedToDimensions section which is made up of three KEY:VALUE pairs.  Then you have the RegionList, which is an array of all the face regions.  Each Region is further broken down into an Area, which further breaks down to the X,Y center point of the region and the Width/Height of the region.  Then there are additional KEY:VALUE pairs.  In this case, Name and Type, though there are a few others.  As you've discovered, the Name can be optional.  The Area is defined, but not named. You'll find more details on the MWG tags page.


"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

asielen

Thank you Phil and StarGeek! That solved my issue. Thank you for the in-depth explanation.
I am using python so I will need to figure out how to adjust my code to work with this data. The structured data may actually be easier to work with.