PersonInImage to ACDsee

Started by mulu, January 13, 2020, 09:47:03 PM

Previous topic - Next topic

StarGeek

Cool.  I should have caught that first one but I guess I became code blind from looking over it so much.  I'm not sure I would have figured out the last one.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

The last change wasn't necessary, but I did it for consistency.

- 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

mulu, you can now copy the XMP-iptcExt:PersonInImage tags to the ACDSee name tags with this:
exiftool -config acdsee-rs.config "-RegionInfoACDSeeRegionListName<XMP-iptcExt:PersonInImage" /path/to/dir

Now that it's working, I'll probably tweak it a bit and add some additional useful abilities.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

Since I wanted to see what the actual difference between the ALG and DLY groups were, I created a tag to output those dimensions so they could be used in ImageMagick extract the regions.  The new tags are ImageMagickThumbDLY and ImageMagickThumbALG.

Using the sample file, this is the output
C:\>exiftool -config acdsee-rs.config -ImageMagickThumb* -a -s -G1 "Y:\!temp\mm\ACDsee-Regions_JSilva_092517_8623.jpg"
[Composite]     ImageMagickThumbALG             : 129x129+234+40, 126x126+539+199, 128x128+363+156
[Composite]     ImageMagickThumbDLY             : 109x133+244+40, 107x130+549+199, 109x132+373+156, 113x141+455+50, 151x178+686+101


Plugging those into a command like this
magick "Y:\!temp\mm\ACDsee-Regions_JSilva_092517_8623.jpg" -crop 129x129+234+40 thumb1a.jpg
and these are the thumbs it extracted








ALGDLY

The noticable thing about the ALG regions is that they are square.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Wow, StarGeek.  You seriously go one step beyond in your support.

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

mulu

#20
Phil, thanks for the GREAT tool and helping StarGeek out. StarGeek, I very much appreciate your help including getting this started and providing the sample how to move the tags. It does transfer the names but unfortunately ACDsee ignores them because at the minimum it requires:

One at the beginning:
RegionsAppliedToDimensionsH
RegionsAppliedToDimensionsUnit
RegionsAppliedToDimensionsW

For each image:
RegionsRegionListDLYAreaH
RegionsRegionListDLYAreaW
RegionsRegionListDLYAreaX
RegionsRegionListDLYAreaY
RegionsRegionListName
RegionsRegionListNameAssingType
RegionsRegionListType

So

1) somehow I need to get the dimensions of the image into the first section.
2) We obviously don't know the location of the face but it's fine to just define some fixed area like the top left corner.

I am not sure how to do 1) I tried "exiftool(-k).exe" -config acdsee-rs.config "-XMP-acdsee-rs:RegionsAppliedToDimensionsH<ExifImageHeight" [Filename] but that gives me the error "Tag 'xmp-acdsee-rs:regionsappliedtodimensionsh' is not defined" I see that StarGeek used RegionInfoACDSeeRegionListName. I looked in the config file and tried to determine how that name is determined but didn't really see anything.

Regarding 2), we obviously don't know the coordinates where the faces are. Hence, I am trying to just define some default values like a small area in the upper left corner. However, I couldn't find any info how to set default values in a config file.

Edit 1:
I got 1) solved with
"exiftool(-k).exe" -config acdsee-rs.config "-RegionInfoACDSeeAppliedToDimensionsw<ExifImageHeight" [Filename]
"exiftool(-k).exe" -config acdsee-rs.config "-RegionInfoACDSeeAppliedToDimensionsh<ExifImageWidth" [Filename]
"exiftool(-k).exe" -config acdsee-rs.config "-RegionInfoACDSeeAppliedToDimensionsunit=pixel" [Filename]
"exiftool(-k).exe" -config acdsee-rs.config "-RegionInfoACDSeeRegionListName<XMP-iptcExt:PersonInImage" [Filename]

I still don't know how I can get 2) done. And if I defined default values in the config file will it write multiple copies of those default values because above I am calling exiftool 3 times to define the image hight, widht and dimension?

Edit 2:
Never mind, I can combine all those commands into one with

"exiftool(-k).exe" -config acdsee-rs.config "-RegionInfoACDSeeAppliedToDimensionsw<ExifImageHeight" "-RegionInfoACDSeeAppliedToDimensionsh<ExifImageWidth" "-RegionInfoACDSeeAppliedToDimensionsunit=pixel" "-RegionInfoACDSeeRegionListName<XMP-iptcExt:PersonInImage"

So the remaining issue is how to define default values for the DLYArea.

StarGeek

You can get all the tag names by running
exiftool -config acdsee-rs.config  -a -s -XMP-acdsee-rs:all FILE
This will output all the tag names
RegionInfoACDSeeAppliedToDimensionsH
RegionInfoACDSeeAppliedToDimensionsUnit
RegionInfoACDSeeAppliedToDimensionsW
RegionInfoACDSeeRegionListDLYAreaH
RegionInfoACDSeeRegionListDLYAreaW
RegionInfoACDSeeRegionListDLYAreaX
RegionInfoACDSeeRegionListDLYAreaY
RegionInfoACDSeeRegionListALGAreaH
RegionInfoACDSeeRegionListALGAreaW
RegionInfoACDSeeRegionListALGAreaX
RegionInfoACDSeeRegionListALGAreaY
RegionInfoACDSeeRegionListName
RegionInfoACDSeeRegionListType
RegionInfoACDSeeRegionListNameAssignType


Here's a command example to set everything
exiftool -config acdsee-rs.config "-RegionInfoACDSeeAppliedToDimensionsH<ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsW<ImageWidth" -RegionInfoACDSeeAppliedToDimensionsUnit=pixel -RegionInfoACDSeeRegionListDLYAreaH=.1 -RegionInfoACDSeeRegionListDLYAreaW=.1 -RegionInfoACDSeeRegionListDLYAreaX=.2 -RegionInfoACDSeeRegionListDLYAreaY=.2 -RegionInfoACDSeeRegionListName="Austin Powers" -RegionInfoACDSeeRegionListType=Face -RegionInfoACDSeeRegionListNameAssignType=manual <FileOrDir>

Quote from: mulu on January 31, 2020, 08:36:39 PM
I see that StarGeek used RegionInfoACDSeeRegionListName. I looked in the config file and tried to determine how that name is determined but didn't really see anything.

Exiftool builds that out of the names set for each structure that is used. The first part is defined by the line
Name => 'RegionInfoACDSee',
Which renames it from the orignal name of "Regions" just above it in order to avoid a name collision with the MWG Regions (I think)
Then below is the "AppliedToDimensions" part
AppliedToDimensions => { Struct => \%sACDSeeDimensions },
and the AppliedToDimensions structure, way back at the beginning of the file, has the "H", "W", and "Unit" parts.

Some FlatName commands need to be added in to make it more managable, but I can't get back to this project until Sunday (off to see friends in LA that I haven't seen in 6 months). 

I'm also working on a way to allow conversion between MWG regions and ACDSee regions because in researching this stuff, I saw several posts on the ACDSee forum that was asking for a way to read the MWG regions.  Finally got my head wrapped around how to do it.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mulu

StarGeek, thanks for the response. I guess my edits and your post kind of overlapped. In any case, I see the command that you are suggesting. I think the problem with that is that it only writes one region & name but many of my pictures have many names. Your previous proposal did write a tag for each name which is exactly what I need. But for each of those I also need to write the region, i.e. 3 face -> 3 regions. So how can I do that?

StarGeek

The flattened tags here are basically list type tags like Keywords.  You can do it any of the ways mentioned in FAQ #17.  The "AppliedToDimensions" tags are only supposed to appear once, so don't double up on them, though.

For example, using a comma as a separated with -sep ","
exiftool -config acdsee-rs.config -sep "-RegionInfoACDSeeAppliedToDimensionsH<ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsW<ImageWidth" -RegionInfoACDSeeAppliedToDimensionsUnit=pixel -RegionInfoACDSeeRegionListDLYAreaH=".1,.2" -RegionInfoACDSeeRegionListDLYAreaW=".1,.2" -RegionInfoACDSeeRegionListDLYAreaX=".2,.3" -RegionInfoACDSeeRegionListDLYAreaY=".2,.3" -RegionInfoACDSeeRegionListName="Austin Powers,Shrek" -RegionInfoACDSeeRegionListType="Face,Face" -RegionInfoACDSeeRegionListNameAssignType="manual,manual" FILE

You might also be careful what you supply for the ListType and AssignType.  No telling what might happen if they are values that ACDSee doesn't normally set.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mulu

Ok, so it seems there isn't a way to 'automate' this in the sense of the command below which creates an entry for each person in PersonInImage.

"-RegionInfoACDSeeRegionListName<XMP-iptcExt:PersonInImage"

Instead, I will have to extract all the people from XMP-iptcExt:PersonInImage and then create a new (long) command with all the required field multiplied by the number of people in the image.

I probably will write some C# program to scan through all the images in the directories and sub directories, call exiftool to extract the names of the people in the picture (XMP-iptcExt:PersonInImage), compose a (long) exiftool command with the area/name/assignType/etc repeated for each person and then run exiftool on that. I will give this a try.

StarGeek

Quote from: mulu on February 01, 2020, 01:03:26 AM
Ok, so it seems there isn't a way to 'automate' this in the sense of the command below which creates an entry for each person in PersonInImage.

It can be done, but it'd be messy and as long as you don't mind the overlapping region areas.  Try this:
exiftool -config acdsee-rs.config -sep "," "-RegionInfoACDSeeAppliedToDimensionsH<ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsW<ImageWidth" -RegionInfoACDSeeAppliedToDimensionsUnit=pixel -RegionInfoACDSeeRegionListDLYAreaH<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" -RegionInfoACDSeeRegionListDLYAreaW<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" -RegionInfoACDSeeRegionListDLYAreaX<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" -RegionInfoACDSeeRegionListDLYAreaY<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" -RegionInfoACDSeeRegionListName<PersonInImage -RegionInfoACDSeeRegionListType<${PersonInImage;$_='Face,'x ((()=/, /g)+1);s/,$//}" -RegionInfoACDSeeRegionListNameAssignType<${PersonInImage;$_='manual,'x ((()=/, /g)+1);s/,$//}" FILE

Though it might be worth creating user-defined tags at that point.

The key part is this
${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}"
It uses Phil's keyword count post to get the number of names in PersonInImage, then the perl x repetition operator to duplicate the item and a comma that many times, then regex to strip away any trailing commas.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mulu

#26
StarGeek, I did some programming last night and this morning but it seems this actually can be done without any programming. I had to modify your command a little bit, i.e. add some quotation marks. This is what I ended up with:

"Exiftool(-k).exe" -config acdsee-rs.config -sep "," "-RegionInfoACDSeeAppliedToDimensionsH<ImageHeight" "-RegionInfoACDSeeAppliedToDimensionsW<ImageWidth" -RegionInfoACDSeeAppliedToDimensionsUnit=pixel "-RegionInfoACDSeeRegionListDLYAreaH<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" "-RegionInfoACDSeeRegionListDLYAreaW<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" "-RegionInfoACDSeeRegionListDLYAreaX<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" "-RegionInfoACDSeeRegionListDLYAreaY<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" "-RegionInfoACDSeeRegionListName<PersonInImage" "-RegionInfoACDSeeRegionListType<${PersonInImage;$_='Face,'x ((()=/, /g)+1);s/,$//}" "-RegionInfoACDSeeRegionListNameAssignType<${PersonInImage;$_='manual,'x ((()=/, /g)+1);s/,$//}"

This indeed creates the RegionsRegionListDLYAreahH/W/X/Y tags. However, it only creates them once. It doesn't create them for the second, third, etc. person. I will try to dig a bit further into the 'keyword count post' to see what is going on or in this case what isn't...

Edit 1:
Ok, looking at this it seems the calculated tags are always written to fixed tags like RegionInfoACDSeeRegionListDLYAreaH/W/X/Y. So I think they are just getting overwritten rather than duplicated. I am just guessing. This perl syntax is not easy to understand...

mulu

#27
Attached is what exiftoolgui shows. As can be seen, there is only one of the RegionsRegionListDL... tags. However, the RegionsRegioniListName tag is repeated as expected. I have to dig in why that tag is repeated but the other ones are not. Just thinking out loud...

Edit 1:
It seems a command like

    RegionInfoACDSeeRegionListDLYAreaH<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}

is overwriting an existing RegionInfoACDSeeRegionListDLYAreaH value but a command like

    RegionInfoACDSeeRegionListName<PersonInImage

is producing another/duplicate entry of RegionInfoACDSeeRegionListName. The latter is what I need.

In both examples the left side of the '<' is identical but in the former the right side is some kind of function whereas in the second case the right side is a 'variable'. So maybe Perl is treating this differently and doesn't produce duplicate entries in the first case (but I need duplicate entries).

mulu

Attached is one more screenshot. It seems to confirm my assumption that the tags with the function write into the same tag (or only write once) while the one without the function (the name of the person) repeats. I read that ' and " makes a difference so I replaced the ' with \" but that didn't change anything. Is that for loop Perl? I checked the Perl syntax and it doesn't show anything like that.

StarGeek

Quote from: mulu on February 01, 2020, 03:20:55 PM
StarGeek, I did some programming last night and this morning but it seems this actually can be done without any programming. I had to modify your command a little bit, i.e. add some quotation marks.

Ooops, sorry, I was doing this just seconds before heading out the door and wasn't careful enough double checking what I had done.

Quote"-RegionInfoACDSeeRegionListDLYAreaH<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}" "-RegionInfoACDSeeRegionListDLYAreaW<${PersonInImage;$_='.1,'x ((()=/, /g)+1);s/,$//}"

Careful, you're getting some fancy quotes in there.

As to why it isn't getting properly duplicated, I'm not sure what's happening there.  Something else might be wrong, as I can also duplicate the problem with other tags.  If I don't use -sep, then the whole thing is copied as a single string.  Adding -sep and only one thing is copied.

It even does it when just trying to print duplicates.

C:\>exiftool -P -overwrite_original -sep ", " -PersonInImage="John Doe, Jane Doe, Mike Miller, Austin Powers, Mini Me" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -PersonInImage y:\!temp\Test4.jpg
---- XMP-iptcExt ----
PersonInImage                   : John Doe, Jane Doe, Mike Miller, Austin Powers, Mini Me

C:\>exiftool  -sep "," -p "${PersonInImage;$_='Word,'x ((()=/, /g)+1);s/,$//}" y:\!temp\Test4.jpg
Word

C:\>exiftool   -p "${PersonInImage;$_='Word,'x ((()=/, /g)+1);s/,$//}" y:\!temp\Test4.jpg
Word,Word,Word,Word,Word
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).