camtrapR not accepting the date & time in our images

342 views
Skip to first unread message

Tom D

unread,
Oct 31, 2017, 10:25:02 AM10/31/17
to camtrapR

Hi Jürgen,

 

We’re just doing a small camera trap study, for which your excellent cameratrapR package seems the perfect analysis tool. Though we are having some problems getting the package to read the date & time from our image.

 

I’ve tagged all 4000 of our sample images in digiKam, but don’t seem to be able to get the package to accept the images – whenever I try to do a timeshift or recordTable errors appear (below). The images are stored at e.g. G:\rawImages\stationA\camera1 and the code I used is below:

 

testimages <- ("G:/test")

 

## image shift time

 

timeShiftTabletest = read.csv("timeShiftTable_test.csv")

 

timeshift_run <- timeShiftImages(inDir             )

timeshift_run   = testimages,

                                 timeShiftTable       = timeShiftTabletest,

                                 stationCol           = "station",

                                 hasCameraFolders     = TRUE,

                                 cameraCol = "camera",

                                 timeShiftColumn      = "timeshift",

                                 timeShiftSignColumn  = "sign"

 

Which results in the following:

 

G:/rawImages/stationA/camera1

Warning messages:

1: running command 'exiftool -r "-DateTimeOriginal+=0:0:0 0:0:1" "G:/rawImages/stationA/camera1"' had status 1

 

> timeshift_run

 

1            G:/rawImages/stationA/camera1     0 image files updated

1            8 files weren't updated due to errors

 

Similarly, after when trying to export the data, the following happens:

 

export <- recordTable(inDir  = images,

                                 IDfrom = "metadata",

                                  metadataSpeciesTag = "Species",

                                 stationCol = "station",

                                 camerasIndependent = F,

                                 cameraID = "directory",

                                              )

 

Warning: timeZone is not specified. Assuming UTC

stationA : 117 images

Error in `$<-.data.frame`(`*tmp*`, "DateTimeOriginal", value = numeric(0)) :

  replacement has 0 rows, data has 117

 

I’ve attached an image, one of our 4000 camera trap images that causes the above errors. Could you please help us get the images into a form the package will find acceptable as input?


Best regards,


Tom

IMAG0001.JPG

Tom D

unread,
Nov 6, 2017, 3:22:27 PM11/6/17
to camtrapR
Hi Jurgen, it seems I uploaded some strange image with no datetime. Here is another one that should make it possible to answer the question.
Tagged - not working.jpg

Juergen Niedballa

unread,
Nov 7, 2017, 12:18:27 AM11/7/17
to camt...@googlegroups.com
Hi Tom,
the second picture also does not contain date and time. I suspect that in uploading to the google group the image is stripped of its metadata. 

To answer the question, the errors arose because images don't store the date/time tag correctly (telling from images emailed to me, not the images uploaded to the google group). The date/time information is not in the Exif metadata slot DateTimeOriginal, but instead in XMP:DateTimeOriginal. This can be checked with exiftool like this (the -G argument makes exiftool return the tag group name):

exiftool -G "C:\Path\to\your\images\Tagged - not working.jpg"

I don't know how and why this happened. It is weird because it should be saved in the right place by default (except for some specific reconyx camera models).

Anyways, here is a method for fixing this problem. Please be sure to make a backup first. And replace  "C:\Path\to\your\images" with the path to your images (only the images with this date/time problem!).  Run the lines beginning with exiftool in the command line (cmd.exe in Windows)

1. Fix the metadata problems (this does not yet work on the DateTimeOriginal tag)

exiftool -all= -tagsfromfile @ -all:all -unsafe -icc_profile  "C:\Path\to\your\images"


2. Create an Exif:DateTimeOriginal tag from the XMP:DateTimeOriginal tag

exiftool "-EXIF:DateTimeOriginal<XMP:DateTimeOriginal" "C:\Path\to\your\images"

# then delete the jpg_original files if the result is ok (manually or with this line)
exiftool -delete_original "C:\Path\to\your\images"

For 4000 images it may take a while.
If you want to run it recursively (including all subdirectories of the directory you give, add "-r", e.g.:

exiftool -all= -tagsfromfile @ -all:all -unsafe -icc_profile -r "C:\Path\to\your\images"

Best regards,
Jürgen
Reply all
Reply to author
Forward
0 new messages