Bug 432048 - XMP People/Face tags with no associated regions are ignored [patch]
Summary: XMP People/Face tags with no associated regions are ignored [patch]
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Maintenance-Faces (show other bugs)
Version: 7.1.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-24 20:14 UTC by José Oliver-Didier
Modified: 2021-02-06 18:40 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.2.0


Attachments
Sample image jpg and xmp file. (ignore) (523.65 KB, application/x-zip-compressed)
2021-01-24 20:14 UTC, José Oliver-Didier
Details
Sample image and xmp (updated) (523.66 KB, application/x-zip-compressed)
2021-01-24 21:09 UTC, José Oliver-Didier
Details
xmp.png (160.15 KB, image/png)
2021-01-24 21:19 UTC, Maik Qualmann
Details
Windows File Explorer Details pane showing People Tags (54.42 KB, image/png)
2021-01-24 22:40 UTC, José Oliver-Didier
Details
Picasa File Properties pane showing MS People Tags and IPTC Person Shown (218.39 KB, image/png)
2021-01-24 22:41 UTC, José Oliver-Didier
Details
MWG Face - Test Files (1.53 MB, application/x-zip-compressed)
2021-01-28 00:44 UTC, José Oliver-Didier
Details
WPG/MS People Tags roundtrip scenario (560.54 KB, application/pdf)
2021-02-01 00:41 UTC, José Oliver-Didier
Details
writeMSPhotoRegion.patch (6.27 KB, patch)
2021-02-01 21:04 UTC, Maik Qualmann
Details
writeMSPhotoRegion2.patch (6.71 KB, patch)
2021-02-02 06:55 UTC, Maik Qualmann
Details
writeMSPhotoRegion3.patch (6.73 KB, patch)
2021-02-02 11:37 UTC, Maik Qualmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description José Oliver-Didier 2021-01-24 20:14:19 UTC
Created attachment 135139 [details]
Sample image jpg and xmp file. (ignore)

SUMMARY
Photos containing People Tags, MWG Face, and xmp-IPTC Person Shown In Image with no associated face regions are not read as "People" nor "Tags"

STEPS TO REPRODUCE
1. Open attached test image in Digikam.
2. Ensure metadata is read by Digikam by selecting the image and from the menu select Item | Reread Metadata from Selected Files.
3. Click on the "People" tab and search for any of the following names: "Joseph Stallin", "Harry Truman".
4.  Click on the "Tags" tab and search for any of the following names: "Joseph Stallin", "Harry Truman".

OBSERVED RESULT
- Names are not found.

EXPECTED RESULT
- Names should appear as Tags, and in Faces - albeit missing face region.
- When applicable and metadata is written back to file (Ex. Names should be added to digikam tag list (Ex. People/<name>)), without any associated face region.
- Such names should be treated as if they appear if they where added to the digiKam:TagsList XMP block.

SOFTWARE/OS VERSIONS
Windows: 10

ADDITIONAL INFORMATION
- Related to BUG 431964.
- Refer to attached TestImage.xmp file and observe that for the image XMP blocks for MS People Tags, MWG Faces and IPTC Person Shown in Image - "Joseph Stallin", "Harry Truman" dot not have any associated face region assigned.
- Windows Photo Gallery as well as Microsoft Windows File Explorer will display/search on People Tags without any associated face regions. 
- IPTC People Shown In Image tag list initially did not have any associated face regions, the new updated 2019.1 IPTC Standard introduces Image Regions which allow for face regions to be added. Per IPTC: "An IPTC Image Region can frame people in an image, using associated metadata from other fields in the standard attached to only that region, such as Person Shown." https://iptc.org/news/announcing-the-iptc-photo-metadata-standard-2019-1-introducing-iptc-image-regions/
Comment 1 Maik Qualmann 2021-01-24 20:25:48 UTC
You could have commented in BUG 431964 as well. I already wrote that the current intent is not to add face tags if no region exists. I tested the behavior with Picasa. How do programs like Lightroom behave with this image? The IPTC standard does not apply here, there is no IPTC metadata in your image.

Maik
Comment 2 Maik Qualmann 2021-01-24 20:41:48 UTC
Your test image has an XMP file but the name does not match the image. To read the IPTC areas, they must be renamed and reading of XMP files activated.

Maik
Comment 3 José Oliver-Didier 2021-01-24 21:09:12 UTC
Created attachment 135141 [details]
Sample image and xmp (updated)
Comment 4 Maik Qualmann 2021-01-24 21:19:53 UTC
Created attachment 135142 [details]
xmp.png

You can easily add support for "Xmp.Iptc4xmpExt.PersonInImage" in digiKam, see screenshot. In digiKam Setup under Advanced, just add the entry for Tags.

Maik
Comment 5 José Oliver-Didier 2021-01-24 22:16:31 UTC
Oh, my mistake. I added the correct sample attachment.

I opened another bug thinking the other issue was closed. 

I am not sure about Lightroom as I do not use it and I last used it years ago. Windows Photo Gallery and Windows File Explorer read MS People Tags even if they have no regions attached making them searchable as well. They are also shown in the Windows File Properties dialog. The MS People Tags Spec marks the rectangle (face region) as "optional" (https://docs.microsoft.com/en-us/windows/win32/wic/-wic-people-tagging#people-rectangles).

You are correct that Picasa does ignore MWG Face and People Tags with no associated Face Regions. Curiously, Picasa does read IPTC "People Shown" displaying the values in the Properties panel as well as making the values searchable, but that is it. Only People Tags with associated regions are shown in the Picasa Properties panel. Then again, Picasa is no longer supported (as WPG) and has not been updated in years.

I was trying out Photo Supreme and it does read and write to Person in Image, unfortunately the trial ran out and I am unable to investigate further.

Yeah, I guess Person Shown could be added using Digikam's metadata settings as you commented.

Still feels odd that such information is not added to Digikam's People tab. I can easily envision a scenario in which the people names have been added to the People Shown or MS People Tags using other applications and lacking a face region. Then spotting these photos in Digikam's Peoples tab and easily manually adding the missing face region.
Comment 6 José Oliver-Didier 2021-01-24 22:40:46 UTC
Created attachment 135145 [details]
Windows File Explorer Details pane showing People Tags
Comment 7 José Oliver-Didier 2021-01-24 22:41:39 UTC
Created attachment 135146 [details]
Picasa File Properties pane showing MS People Tags and IPTC Person Shown
Comment 8 José Oliver-Didier 2021-01-25 15:35:36 UTC
The more I look at it- it seems like it is a bug when Picasa does not display the People Tags with no associated face rectangles in the Properties pane compared to how it reads the Person Shown values which have no face rectangles associated.
Comment 9 Maik Qualmann 2021-01-25 17:54:37 UTC
I can certainly implement that names are created for which no facial regions exist. But I don't know if it complies with the metadata standard. Microsoft is known to implement something that is off-standard. I will try to find information.

Maik
Comment 10 Maik Qualmann 2021-01-25 20:15:56 UTC
Git commit c3b746c08e53e0dc083903c864a9e054932d27bc by Maik Qualmann.
Committed on 25/01/2021 at 20:14.
Pushed by mqualmann into branch 'master'.

add person tags from invalid MWG face regions
FIXED-IN: 7.2.0

M  +2    -1    NEWS
M  +11   -0    core/libs/database/item/scanner/itemscanner_photo.cpp
M  +3    -0    core/libs/metadataengine/dmetadata/dmetadata_faces.cpp

https://invent.kde.org/graphics/digikam/commit/c3b746c08e53e0dc083903c864a9e054932d27bc
Comment 11 Maik Qualmann 2021-01-25 20:24:08 UTC
I can't find a standard for this, if there is one please give a link. I implemented it. But we won't write it back in images.

Maik
Comment 12 José Oliver-Didier 2021-01-26 00:42:49 UTC
Thanks Maik.

Reading the names and adding them to the People view in Digikam, sounds good.

Would this also read the xmp "IPTC Person Shown In Image" and add them to the People view?
Comment 13 Maik Qualmann 2021-01-26 06:49:45 UTC
Support for the IPTC Person Tag will no longer come in digiKam-7.2.0. I am planning it for the next version.

Maik
Comment 14 José Oliver-Didier 2021-01-26 21:13:35 UTC


Thanks Maik. From the specs and applications which I have encountered here are some thoughts:

1. Microsoft People Tags Schema Spec - "Relaxed" in the sense that regions are optional as well as names. The examples included in BUG 431964 were made using Microsoft Windows Photo Gallery which you will notice the application writes names with no rectangles, rectangles with no names, as well as rectangles with names. https://docs.microsoft.com/en-us/windows/win32/wic/-wic-people-tagging

2. MWG Face Tags – More “stricter”, according to the MWG Version 2.0 Spec published in 2010 page 53 - the regions are required, but the names are optional and interestingly the type- whether it is a "face", "pet", “barcode” or other object is optional. So according to MWG a list of names with no regions is not allowed. Still, I have photos which have been converted from People tags to MWG which leave the names with no regions. I could test around this to see how Digikam handles these cases. I believe that if Digikam encounters a name with type “face” and no region it should still add it to the People view but not write it back as it would not be compliant with the MWG Spec. Worst thing for a user is dedicating hours of work in adding tags only to find out it is not read by other applications.

Something which MWG was "smart" was assuming that some applications may be non-compliant and added the "Applied To" State. Last November, I opened a Bug 429219 pertaining to this, which is something Digikam does not write to the MWG and thus is not fully compliant. 

3. IPTC People Shown / new Image Regions - Image regions are new in the 2019 IPTC Spec supports more complex shapes as you can see from the example: https://www.iptc.org/std/photometadata/examples/image-region-examples/?b=2
For People, it seems to build upon the 2008 Spec "Person Shown", from what can be read here: https://iptc.org/news/announcing-the-iptc-photo-metadata-standard-2019-1-introducing-iptc-image-regions/
"An IPTC Image Region can frame people in an image, using associated metadata from other fields in the standard attached to only that region, such as Person Shown."

Given than it extends from the 2008 Spec Person Shown list, it would be nice for Digikam’s People view in a future version.

ID Imager Photo Supreme, supports the new IPTC regions schema. I will need to read further on this Spec.

For the previous 3 schema specs, I can see certain benefits of allowing regions with no names assigned. A scenario which comes to mind of an app specialized in face detection or a user which simply identifies and writes the face regions to the file metadata. Then leaves it to another application or user to recognize and tag the faces in an image.
Comment 15 José Oliver-Didier 2021-01-28 00:43:13 UTC
Testing on 7.2.0-rc Build 1/26/2021 
Commit:https://invent.kde.org/graphics/digikam/commit/5ed02b509f99d270ec84bc0c6883126ebba00b2c

- WPGL (MS People Tag) photos with no face rectangle read as tags OK.
- MWG Face Regions fail - refer to attached "Test Images MWG.zip".
Comment 16 José Oliver-Didier 2021-01-28 00:44:26 UTC
Created attachment 135248 [details]
MWG Face - Test Files
Comment 17 Maik Qualmann 2021-01-28 06:55:39 UTC
Git commit ba8886be4fab53919021da057efe51c5fc73338b by Maik Qualmann.
Committed on 28/01/2021 at 06:54.
Pushed by mqualmann into branch 'master'.

fix read MWG Faces
FIXED-IN: 7.2.0

M  +9    -10   core/libs/metadataengine/dmetadata/dmetadata_faces.cpp

https://invent.kde.org/graphics/digikam/commit/ba8886be4fab53919021da057efe51c5fc73338b
Comment 18 José Oliver-Didier 2021-01-31 23:18:51 UTC
Testing on 7.2.0-rc Build 1/30/2021 
Commit:https://invent.kde.org/graphics/digikam/commit/d75ec77d8538e10af8c02340e227835c2ee67896

- WPGL (MS People Tag) photos with no face rectangle read as tags OK.
- MWG Face Regions photos with no face rectangle read as tags OK.

Maik: Works great reading the face metadata! Thanks.

----

However, Since Windows Photo Gallery (application) as well as the MS People Tag Spec allows writing People Tags with no face regions. Would it be possible to write WPG (MS) People Tags without the face region back to the file metadata in order to support this? In other words, write the People names to MPReg:PersonDisplayName when they are present in Digikam's People/<name tag> even when no regions have been added.

This is the scenario which I encountered with WPG: Say there is a photo with two people win People Tags and face rectangles added in Windows Photo Gallery. If in Digikam one of the two faces a region is added and the other is not, upon writeback to the file metadata the People tag will be erased and therefore not present if the image is read in WPG or in Windows File Explorer.

Again, this would only be applicable on WPG (MS) People Tag regions.
Comment 19 José Oliver-Didier 2021-02-01 00:41:36 UTC
Created attachment 135341 [details]
WPG/MS People Tags roundtrip scenario

Including PDF explaining the People Tag roundtrip scenario from my previous comment.
Comment 20 Maik Qualmann 2021-02-01 08:32:39 UTC
I see a breach of the standard in writing people names without facial regions. If you show me an official document that describes this, we will implement it. Just because Microsoft does it that way, we won't implement it. Even if digiKam attaches great importance to sharing metadata with other programs, we should adhere to standards. DigiKam puts all options in your hands to correct your images (YOLO face recognition for the smallest faces, etc.) and to write back standard-compliant metadata. I plan to support the new People Shown tag in digiKam-7.3.0. That should solve your problem with Windows Photo Gallery.

Maik
Comment 21 José Oliver-Didier 2021-02-01 09:51:15 UTC
Excuse my persistence, but the People Tags Schema 1.2 is Microsoft's own creation you can find the specification here:
https://docs.microsoft.com/en-us/windows/win32/wic/-wic-people-tagging#schema-reference

Per the specification the face area (rectangle they call it) is marked as optional:
MPReg:Rectangle "optional : Stores the rectangle that identifies the person within the photo. The rectangle is stored as four comma-delimited decimal values. The first two values specify the top left coordinate; the final two specify the height and width of the rectangle. The decimal values must be normalized to 1."

Again, this is for Microsoft's People Tags only. As the Metadata Working Group last Specification requires a face region.

Unfortunately, Windows Photo Gallery does not read "People Shown" tag.
Comment 22 Maik Qualmann 2021-02-01 21:04:03 UTC
Created attachment 135357 [details]
writeMSPhotoRegion.patch

Patch #1

maik
Comment 23 Maik Qualmann 2021-02-02 06:55:58 UTC
Created attachment 135359 [details]
writeMSPhotoRegion2.patch

Patch #2

Maik
Comment 24 Maik Qualmann 2021-02-02 11:37:25 UTC
Created attachment 135365 [details]
writeMSPhotoRegion3.patch

Patch #3

Maik
Comment 25 Maik Qualmann 2021-02-06 18:40:38 UTC
Git commit dc7d7b1dde199386fa1943b9fe1342369c9e3112 by Maik Qualmann.
Committed on 06/02/2021 at 18:39.
Pushed by mqualmann into branch 'master'.

write face tag names in Microsoft People Tags if there is no face region
FIXED-IN: 7.2.0

M  +22   -2    core/libs/fileactionmanager/metadatahub.cpp
M  +4    -0    core/libs/fileactionmanager/metadatahub.h
M  +24   -14   core/libs/metadataengine/dmetadata/dmetadata_faces.cpp

https://invent.kde.org/graphics/digikam/commit/dc7d7b1dde199386fa1943b9fe1342369c9e3112