Troubles Importing Face Regions from CSV Files

Started by Tveloso, February 05, 2020, 03:01:36 AM

Previous topic - Next topic

Tveloso

I have been experimenting with importing Face Region Info, as Data (using the Import CSV Files App), which could be written directly to the MWG Region Info Tags. 

I planned to perform the import, and then use the Re-create face annotations from XMP data command (Commands->Image->Face Annotations->Re-create face annotations from XMP data) to get the IMatch Face Annotations created.

However I ran into an issue that I think may be related to "de-duping" of the Region Info tags, after the data has been imported.

I first added some Face Annotations to an image, and then used the Text Export App to export that data to a CSV File (in order to see what the format of my Import File would need to be).

So after adding the Face Annotations, and writing back, the Region Info in the Metadata Panel looked like this:

   

...and the file contained these Tags:

    [XMP-mwg-rs]        - Region Applied To Dimensions H  : 3024.000000
    [XMP-mwg-rs]        - Region Applied To Dimensions Unit: pixel
    [XMP-mwg-rs]        - Region Applied To Dimensions W  : 4032.000000
    [XMP-mwg-rs]        - Region Area H                   : 0.142222, 0.122355, 0.218254
    [XMP-mwg-rs]        - Region Area Unit                : normalized, normalized, normalized
    [XMP-mwg-rs]        - Region Area W                   : 0.106667, 0.079365, 0.129843
    [XMP-mwg-rs]        - Region Area X                   : 0.633333, 0.349702, 0.830416
    [XMP-mwg-rs]        - Region Area Y                   : 0.217778, 0.272818, 0.281085
    [XMP-mwg-rs]        - Region Type                     : Face, Face, Face

The Export File created by the Text Export App looked like this:

   
    (*Note: Column-A contained the FileName, and Columns H-J contained the "Region Applied To Dimensions..." Tags)

...(the "pixel coordinates" had been rounded to just 2 decimal places, becuase I did not format the variables - more on that in "example-2" below).

After exporting (to create my test Import File), I removed the image from my Test Database, replaced it with a backup copy (that didn't have any Region Info in it), and then re-scanned the folder, to get the image back into the database.  I then imported the file that had been created by the Text Export App, using the Import CSV Files App. 

On one attempt (let's call this "example-1") everything looked good, but when I tried the Re-create face annotations from XMP data command, only one Face Annotation was created (even though three Face Regions had been imported).  After reviewing the Region Info Tags, I guessed that this might have been because the Region Type Tag was not repeated in the file (it contained only one instance of the value "Face", even though it was repeated in the Import file).  After this import, the Metadata Panel looked like this:

   

...and the file contained these Tags (the Region Type and Region Area Unit Tags were not repeated, as they were when the Region Info was originally created by the IMatch Face Annotations):

    [XMP-mwg-rs]        - Region Applied To Dimensions H  : 3024.0000
    [XMP-mwg-rs]        - Region Applied To Dimensions Unit: pixel
    [XMP-mwg-rs]        - Region Applied To Dimensions W  : 4032.0000
    [XMP-mwg-rs]        - Region Area H                   : 0.14, 0.12, 0.22
    [XMP-mwg-rs]        - Region Area Unit                : normalized
    [XMP-mwg-rs]        - Region Area W                   : 0.11, 0.08, 0.13
    [XMP-mwg-rs]        - Region Area X                   : 0.63, 0.35, 0.83
    [XMP-mwg-rs]        - Region Area Y                   : 0.22, 0.27, 0.28
    [XMP-mwg-rs]        - Region Type                     : Face

On another attempt ("example-2"), I hit upon "pixel coordinates":

    [XMP-mwg-rs]        - Region Area Y                   : 0.217778, 0.277778, 0.281085

...that when rounded to 2 digits, wound up having the same value for the Y-coordinate in two of the Face Regions in the Export File (again, because I had failed to format the variables used in the Text Export App):

   
    (*Note: Column-A contained the FileName, and Columns H-J contained the "Region Applied To Dimensions..." Tags)

...and here too, that data was "de-duped" when Imported, so this resulted in missing "pixel coordinates":

   

    [XMP-mwg-rs]        - Region Applied To Dimensions H  : 3024.0000
    [XMP-mwg-rs]        - Region Applied To Dimensions Unit: pixel
    [XMP-mwg-rs]        - Region Applied To Dimensions W  : 4032.0000
    [XMP-mwg-rs]        - Region Area H                   : 0.14, 0.11, 0.22
    [XMP-mwg-rs]        - Region Area Unit                : normalized
    [XMP-mwg-rs]        - Region Area W                   : 0.11, 0.08, 0.13
    [XMP-mwg-rs]        - Region Area X                   : 0.63, 0.35, 0.83
    [XMP-mwg-rs]        - Region Area Y                   : 0.22, 0.28
    [XMP-mwg-rs]        - Region Type                     : Face

That same "de-duping" occurs even when the data is entered manually in the Metadata Panel (no Import involved).  I will create a bug report for this.

I am now looking into using Exiftool's -csv option to perform this import, and initial tests look good (and IMatch detects the updated Metadata upon re-scan, and creates the Face Annotations automatically).
--Tony