Addind species tag and count tag to camera trap images

Started by Emeline, June 03, 2022, 01:40:48 AM

Previous topic - Next topic

Emeline

Hi,

I am currently working on big dataset of camera trap images and I would like to use Exiftool to add species tag and count tag to my images. All images were manually classified by putting the images in the appropriate species folder and then the appropriate count subfolder based on the number of individual in the image.
Here is an example for the directory of my file: E:\Other\A 25\Long-tailed macaque\1 (species recorded long-tailed macaque and 1 individual on the image).
I will like to use Exiftool to tag my images and then use CamTrapR to be able to extract the metadata to create a record table.
I have managed to add a hierarchical subject tag will all the information and can easily manipulate the data with R to get the right column (one column Species and one column Count). But I think that I can get the same information by manipulating the directory path and extract species and count. I actually would need to create a correct from the start Species tag with the species information as this column is needed to then filter at the same time the independent events. When I use the following exiftool code and then CamTrapR, my species column is not correct for folders with count subfolders, the species being the number of individuals instead.
exiftool "-HierarchicalSubject<Species|${directory;my @a=split m(/);$_=$a[-2]};Count|${directory;my @a=split m(/);$_=$a[-1]}" -r -overwrite_original -P -ext JPG "E:\Other"

I tried this code:
exiftool "-Species<${directory;my @a=split m(/);$_=$a[-2]}"-r -overwrite_original -P -ext JPG "E:\Other"

But it does not detect any files in the directory when I use this code.

Do I need to create a new tag or is there already a species tag that exist that I could modify ?

Thank you for your help,

Emeline

StarGeek

Quote from: Emeline on June 03, 2022, 01:40:48 AMWhen I use the following exiftool code and then CamTrapR, my species column is not correct for folders with count subfolders, the species being the number of individuals instead.
exiftool "-HierarchicalSubject<Species|${directory;my @a=split m(/);$_=$a[-2]};Count|${directory;my @a=split m(/);$_=$a[-1]}" -r -overwrite_original -P -ext JPG "E:\Other"

Using your example path, this creates a single HierarchicalSubject entry with the value of
Species|Long-tailed macaque;Count|1
when what I think you want is two entries with the values of
Species|Long-tailed macaque
Count|1

If that's the case, you need to add the -sep option, specifically -sep ; so exiftool knows to separate the list on the semicolon character.  See also FAQ #17.

Try
exiftool -sep ; "-HierarchicalSubject<Species|${directory;my @a=split m(/);$_=$a[-2]};Count|${directory;my @a=split m(/);$_=$a[-1]}" -r -overwrite_original -P -ext JPG "E:\Other"

QuoteI tried this code:
exiftool "-Species<${directory;my @a=split m(/);$_=$a[-2]}"-r -overwrite_original -P -ext JPG "E:\Other"

When you run that, you should get this warning
Warning: Tag 'species' is not defined

That's because this "tag" doesn't exist.  You can't just make up a tag name and expect exiftool to know how to write it.  To create your own tag, take a look at the example.config file.

QuoteDo I need to create a new tag or is there already a species tag that exist that I could modify ?

If you want a "Species" tag, then yes, you have to create one.  But I recommend against it, as no program other than exiftool is going to be able to read that tag.

Technically, you probably want to look at the Darwin Core tags, as they are meant to "facilitate the sharing of information about biological diversity".  See the Darwin Core standard for details.

But the Darwin Core standard doesn't have much support outside of programs specifically designed for it.  So you still might end up not having easy access to the data.

My suggestion would be to continue using HierarchicalSubject as it is readily supported by most programs and look into the Darwin Core as a long-term goal.

I know that there are several people in these forums who are more familiar with the Darwin Core and use it regularly.  Hopefully one of them will chime in.
"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