(Newbie question) Rearranging RegionPersonDisplayName and RegionRectangle

Started by Iwonder, April 22, 2024, 12:51:13 PM

Previous topic - Next topic

Iwonder

Hello !
I am asking my question using an example.

In my pictures, there are such data (that I can see with XnView):
Exiftool XMP tags :
Region Rectangle     0.331250, 0.171192, 0.022656, 0.034238, 0.188269, 0.333333, 0.077578, 0.117310, 0.634816, 0.253219, 0.096500, 0.145923   
Region Person Display Name     PERSON1, PERSON2
(In this example there are three rectangles, and two person names)

My current command line is:
exiftool.exe -T -RegionPersonDisplayName -RegionRectangle *.jpg > Extraction.txt

Which gives this kind of result in the output file:
PERSON1, PERSON2, 0.331250, 0.171192, 0.022656, 0.034238, 0.188269, 0.333333, 0.077578, 0.117310, 0.634816, 0.253219, 0.096500, 0.145923
But this is the output I'd like to get:
PERSON1, 0.331250, 0.171192, 0.022656, 0.034238, PERSON2, 0.188269, 0.333333, 0.077578, 0.117310, NONAME, 0.634816, 0.253219, 0.096500, 0.145923
Is there a way to reorganize/rearrange the output with command line ?
Browsing the home page and forum, I couldn't find how.
(Sorry if the soluce is there, but I couln't find it)
Bernard
French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en

StarGeek

The Microsoft regions are structured data, which is very complex. When using the flattened tags like this, they get separated into two different tags and you can't intertwine them.

The best you could do would be to add the -struct option and then parse out the groups from there

Example, this may not be completely correct, as I only copy/pasted your output
C:\>exiftool -G1 -a -s -RegionInfoMP -struct y:\!temp\Test4.jpg
[XMP-MP]        RegionInfoMP                    : {Regions=[{PersonDisplayName=PERSON1,Rectangle=0.331250|, 0.171192|, 0.022656|, 0.034238},{PersonDisplayName=PERSON2,Rectangle=0.188269|, 0.333333|, 0.077578|, 0.117310},{Rectangle=0.634816|, 0.253219|, 0.096500|, 0.145923}]}

Making the data more human readable
{
    Regions = [{
            PersonDisplayName = PERSON1,
            Rectangle = 0.331250 | ,
            0.171192 | ,
            0.022656 | ,
            0.034238
        }, {
            PersonDisplayName = PERSON2,
            Rectangle = 0.188269 | ,
            0.333333 | ,
            0.077578 | ,
            0.117310
        }, {
            Rectangle = 0.634816 | ,
            0.253219 | ,
            0.096500 | ,
            0.145923
        }
    ]
}
"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

Iwonder

French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en

Phil Harvey

If possible, I would recommend using a structured output format like JSON.  Using StarGeek's example structure:

> exiftool -struct -j -regioninfomp a.jpg
[{
  "SourceFile": "a.jpg",
  "RegionInfoMP": {
    "Regions": [{
      "PersonDisplayName": "PERSON1",
      "Rectangle": "0.331250, 0.171192, 0.022656, 0.034238"
    },{
      "PersonDisplayName": "PERSON2",
      "Rectangle": "0.188269, 0.333333, 0.077578, 0.117310"
    },{
      "Rectangle": "0.634816, 0.253219, 0.096500, 0.145923"
    }]
  }
}]

Alternatively it would be possible to reformat this information however you want with a user-defined Composite tag.

- 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 ($).

Iwonder

Thank you Phil
I succedded in helping my friend with the simple command line, but all this now, seems to be too hard for me : thousands of pictures, up to 18 persons recognized names on some photos...
I will not be able to achieve this.
Thanks !
French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en

StarGeek

Quote from: Iwonder on April 23, 2024, 10:00:44 AMbut all this now, seems to be too hard for me : thousands of pictures, up to 18 persons recognized names on some photos...

I'm not sure why thousands of pictures is a sticking point.  I have run exiftool on 100s of thousands of pictures before.

You do not need to specify each file individually.  You can give exiftool a directory (or multiple directories) and exiftool will extract the data for all of those files. Add the -r (-recurse) option and exiftool will extract the data from all the files in subdirectories as well.
"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

Iwonder

@StarGeek
Did you mean that I would have to rearrange the tags the way you showed, with a search and replace tool (I think I could deal this with regex in MS Word), for the pictures and pass the result (very long !) on the command line ?
French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en

StarGeek

Sorry if I misunderstood.

Yes, you would have to rearrange the data.  What I meant was that you could output the data for all the files in one command.
"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

Iwonder

@StarGeek
ok ! thanx, I will have a look at this, it would be in my capabilities  :)
French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en

Iwonder

@StarGeek
First of all I tested your commande line format with this one:
exiftool.exe -T -Filename -RegionInfoMP -struct CPH01_B7_C3_1996SEM01_I_030.jpg [XMP-MP] RegionInfoMP : {Regions=[{PersonDisplayName="AUDET Sylviane",Rectangle=0.634375| , 0.193548| , 0.111719| , 0.164747}]} > test.txt
and I get this error:
'0.193548' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

in English : '0.193548' is not recognized as an internal or external command, executable program, or batch file
What is my mistake ?
I tried things like omitting the pipes, replacing commas with semicolons, but without any success
French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en

StarGeek

The whole [XMP-MP]        RegionInfoMP... is the data that exiftool outputs, not data to include on the command line.

Maybe a better question for us to ask is what you plan on doing with your output. When you say you want your output like this
PERSON1, 0.331250, 0.171192, 0.022656, 0.034238, PERSON2, 0.188269, 0.333333, 0.077578, 0.117310, NONAME, 0.634816, 0.253219, 0.096500, 0.145923how did you plan on using it?  Because you're going to have to parse the data in some way to make it useful anyway. I was trying to show you a way to get the data in a format that would be easier to parse.
"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

Iwonder

@StarGeek
OMG ! I am so silly ! I was wrong because both codes tt and code look the same on the posts.
And it's so easy !
I juste sent the output file for a 100 pictures sample to my friend, and he (maybe with a little help of me), will be able to manage all this. He wanted the future users (searchers), to be able to get the faces coordinates for each photo. It's hard to plan what data will be needed or not for future works ; but he wanted this and with the help of both of you, he get it !
Many many Thanks !!!!

French newbie
Other work as volunteer : https://btaliercio.wixsite.com/easy-greek-buttons/en