Skip to content

Commit

Permalink
Use generic getMetadataDateTime function
Browse files Browse the repository at this point in the history
avoid duplication of metadata string keys
  • Loading branch information
fabiencastan committed Sep 7, 2020
1 parent 8a96cfb commit a05d8ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/aliceVision/sfmData/View.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ class View
return static_cast<EEXIFOrientation>(orientation);
}

const bool hasMetadataDateTimeOriginal() const
{
return hasMetadata(
{"Exif:DateTimeOriginal", "DateTimeOriginal", "DateTime", "Date Time", "Create Date", "ctime"});
}

const std::string& getMetadataDateTimeOriginal() const
{
return getMetadata({"Exif:DateTimeOriginal", "DateTimeOriginal", "DateTime", "Date Time", "Create Date", "ctime"});
Expand Down
4 changes: 2 additions & 2 deletions src/aliceVision/sfmData/uid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ std::size_t computeViewUID(const View& view)
stl::hash_combine(uid, imagePath.parent_path().generic_string());
}

if(view.hasMetadata({"Exif:DateTimeOriginal", "DateTimeOriginal", "DateTime", "Date Time", "Create Date"}))
if(view.hasMetadataDateTimeOriginal())
{
stl::hash_combine(uid, view.getMetadata({"Exif:DateTimeOriginal", "DateTimeOriginal", "DateTime", "Date Time", "Create Date"}));
stl::hash_combine(uid, view.getMetadataDateTimeOriginal());
stl::hash_combine(uid, view.getMetadata({"Exif:SubsecTimeOriginal", "SubsecTimeOriginal"}));
}
else if(view.hasMetadata({"imageCounter"}))
Expand Down
12 changes: 2 additions & 10 deletions src/software/export/main_exportAnimatedCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,9 @@ int aliceVision_main(int argc, char** argv)
isSequence = true;
}

std::string dateTimeMetadata = view.getMetadata({"Exif:DateTimeOriginal", "DateTimeOriginal"});

if(!dateTimeMetadata.empty()) // picture
if(view.hasMetadataDateTimeOriginal()) // picture
{
dateTimeMetadata.erase(std::remove_if(dateTimeMetadata.begin(),dateTimeMetadata.end(), ::isspace), dateTimeMetadata.end());
dateTimeMetadata.erase(std::remove_if(dateTimeMetadata.begin(),dateTimeMetadata.end(), ::ispunct), dateTimeMetadata.end());

std::size_t key = std::numeric_limits<unsigned char>::max();

if(!dateTimeMetadata.empty())
key = std::stoul(dateTimeMetadata);
const std::size_t key = view.getMetadataDateTimestamp();

dslrViewPerKey[cameraName].push_back({key, view.getViewId()});
}
Expand Down

0 comments on commit a05d8ee

Please sign in to comment.