Bug 453060 - MWG regions with Type != "Face" are treated as faces
Summary: MWG regions with Type != "Face" are treated as faces
Status: REOPENED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Xmp (show other bugs)
Version: 7.6.0
Platform: Flatpak Linux
: NOR minor
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-26 16:16 UTC by Paul Krause
Modified: 2023-10-11 14:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Image with a "Barcode" MWG region (1.34 KB, image/png)
2022-04-26 16:16 UTC, Paul Krause
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Krause 2022-04-26 16:16:26 UTC
Created attachment 148393 [details]
Image with a "Barcode" MWG region

SUMMARY
MWG regions with Type != "Face", i.e., which are not faces, are nevertheless treated as faces.
"Type" refers to the tag that exiv2 calls:
Xmp.mwg-rs.Regions/mwg-rs:RegionList/mwg-rs:Type


STEPS TO REPRODUCE
1. Get some image with a MWG region which has Type != "Face", e.g. attachment.
2. Move into a collection/folder used by Digikam
3. Read its metadata into the database (e.g., trigger a scan for new items, automatically at startup, or Item -> read metadata from image)
4. Rewrite metadata of the image (e.g. Item -> write metadata to image)


OBSERVED RESULT
The non-face region is treated as a face. This includes
Step 3: A facetag with its name is created (if it did not exist before), the region is added there, the region is shown in the preview area and the region participates in face recognition.
Step 4: It is erroneously written back to the image metadata with Type == "Face".


EXPECTED RESULT
The region is not treated as a face (step 3) but is retained, in its original state, whenever the image metadata is written (step 4).




Many Thanks!
Comment 1 Maik Qualmann 2022-04-26 20:53:09 UTC
Git commit 359bfc1bdce248d796893ed8feea459d2d4eb63e by Maik Qualmann.
Committed on 26/04/2022 at 20:52.
Pushed by mqualmann into branch 'qt5-maintenance'.

only accept MWG regions with "Face" as type
FIXED-IN: 7.7.0

M  +2    -1    NEWS
M  +24   -14   core/libs/metadataengine/dmetadata/dmetadata_faces.cpp

https://invent.kde.org/graphics/digikam/commit/359bfc1bdce248d796893ed8feea459d2d4eb63e
Comment 2 Paul Krause 2022-04-27 15:37:49 UTC
Dear Maik,

thanks you and sorry if that should go into a new bug report, or not at all.

Unfortunately that fix removes all non-face regions if the metadata is rewritten.
I tested that with the latest appimage (digiKam-7.7.0-20220427T043335-x86-64.appimage).

Many Thanks! Paul



For what I understand from the source code and might suggest:

The problem is in DMetadata::setItemFacesMap at

// Remove face metadata before writing new ones to prevent problems (bug 436286).
removeItemFacesMap();

This unconditionally removes the whole Xmp.mwg-rs.Regions/mwg-rs:RegionList tag, but there is no copy of the non-face regions in the database, memory or somewhere else.

So either one of the following should be a fix:
A) Read all non-face regions from the image metadata before removeItemFacesMap and write them to the image metadata afterwards.
B) Save the non-face regions too in the database (just not as faces) and write them to the image metadata after removeItemFacesMap.
C) Instead of unconditionally removing the whole Xmp.mwg-rs.Regions/mwg-rs:RegionList tag with removeItemFacesMap, remove just the regions with Type == "Face". (I do not know if this conflicts Bug 436286. But, for example, the writing of AppliedToDimensions has to be changed, probably.)

For either of that, probably the code which checks if the RegionList tag is empty, and should be deleted, or should not be written at all, needs an update too.
Comment 3 Maik Qualmann 2022-04-27 17:20:35 UTC
Git commit 4881ccee0ec4f9af1031c1935503c46582c317c3 by Maik Qualmann.
Committed on 27/04/2022 at 17:19.
Pushed by mqualmann into branch 'qt5-maintenance'.

revert "only accept MWG regions with "Face" as type"

M  +1    -1    NEWS
M  +0    -8    core/libs/metadataengine/dmetadata/dmetadata_faces.cpp

https://invent.kde.org/graphics/digikam/commit/4881ccee0ec4f9af1031c1935503c46582c317c3
Comment 4 caulier.gilles 2023-10-11 05:49:22 UTC
Paul,

What's about this file using current 8.2.0 AppImage Linux bundle ? It's
reproducible ?

https://files.kde.org/digikam/

Thanks in advance

Gilles Caulier
Comment 5 Paul Krause 2023-10-11 14:15:53 UTC
Still reproducible.
Please see comment 1 and 2 for how to fix.