if (FALSE) # the examples take too long to pass CRAN tests
# set directory with camera trap images in station directories
wd_images_ID_species <- system.file("pictures/sample_images_species_dir",
package = "camtrapR")
if (Sys.which("exiftool") != ""){ # only run these examples if ExifTool is available
rec_table1 <- recordTable(inDir = wd_images_ID_species,
IDfrom = "directory",
minDeltaTime = 60,
deltaTimeComparedTo = "lastRecord",
writecsv = FALSE,
additionalMetadataTags = c("EXIF:Model", "EXIF:Make")
)
# note argument additionalMetadataTags: it contains tag names as returned by function exifTagNames
rec_table2 <- recordTable(inDir = wd_images_ID_species,
IDfrom = "directory",
minDeltaTime = 60,
deltaTimeComparedTo = "lastRecord",
exclude = "UNID",
writecsv = FALSE,
timeZone = "Asia/Kuala_Lumpur",
additionalMetadataTags = c("EXIF:Model", "EXIF:Make", "NonExistingTag"),
eventSummaryColumn = "EXIF:Make",
eventSummaryFunction = "unique"
)
# note the warning that the last tag in "additionalMetadataTags" ("NonExistingTag") was not found
any(rec_table1$Species == "UNID") # TRUE
any(rec_table2$Species == "UNID") # FALSE
# here's how the removeDuplicateRecords argument works
rec_table3a <- recordTable(inDir = wd_images_ID_species,
IDfrom = "directory",
minDeltaTime = 0,
exclude = "UNID",
timeZone = "Asia/Kuala_Lumpur",
removeDuplicateRecords = FALSE
)
rec_table3b <- recordTable(inDir = wd_images_ID_species,
IDfrom = "directory",
minDeltaTime = 0,
exclude = "UNID",
timeZone = "Asia/Kuala_Lumpur",
removeDuplicateRecords = TRUE
)
anyDuplicated(rec_table3a[, c("Station", "Species", "DateTimeOriginal")]) # got duplicates
anyDuplicated(rec_table3b[, c("Station", "Species", "DateTimeOriginal")]) # no duplicates
# after removing duplicates, both are identical:
whichAreDuplicated <- which(duplicated(rec_table3a[,c("Station", "Species", "DateTimeOriginal")]))
all(rec_table3a[-whichAreDuplicated,] == rec_table3b)
### extracting species IDs from metadata
wd_images_ID_species_tagged <- system.file("pictures/sample_images_species_tag",
package = "camtrapR")
rec_table4 <- recordTable(inDir = wd_images_ID_species_tagged,
IDfrom = "metadata",
metadataSpeciesTag = "Species",
exclude = "unidentified")
### Including videos
# sample videos are not included in package
# with videos, IDfrom = "directory", not extracting digiKam metadata
rec_table4 <- recordTable(inDir = wd_images_ID_species,
IDfrom = "directory",
video = list(file_formats = c("jpg", "mp4"),
dateTimeTag = "QuickTime:CreateDate")
)
# with videos, IDfrom = "metadata", extracting digiKam metadata
rec_table5 <- recordTable(inDir = wd_images_ID_species,
IDfrom = "metadata",
metadataSpeciesTag = "Species",
video = list(file_formats = c("jpg", "mp4", "avi", "mov"),
dateTimeTag = "QuickTime:CreateDate",
db_directory = "C:/Users/YourName/Pictures",
db_filename = "digikam4.db")
)
} else {
# show function output if ExifTool is not available
message("ExifTool is not available. Cannot test function. Loading recordTableSample instead")
data(recordTableSample)
}
Run the code above in your browser using DataLab