forked from openMVG/openMVG
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OpenExif submodule. And add JPEG Exif data reader openMVG module. o…
- Loading branch information
Showing
10 changed files
with
550 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "src/dependencies/glfw"] | ||
path = src/dependencies/glfw | ||
url = git://github.com/elmindreda/glfw.git | ||
[submodule "src/dependencies/OpenExif"] | ||
path = src/dependencies/OpenExif | ||
url = https://github.com/pmoulon/OpenExif.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ADD_DEFINITIONS(-DTHIS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") | ||
UNIT_TEST(openMVG exif_IO "${EXIV2_LIBRARIES};OpenExif;stlplus") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef EXIF_IO_HPP | ||
#define EXIF_IO_HPP | ||
|
||
#include <string> | ||
|
||
class Exif_IO | ||
{ | ||
public: | ||
virtual size_t getWidth() const = 0; | ||
|
||
virtual size_t getHeight() const = 0; | ||
|
||
virtual float getFocal() const = 0; | ||
|
||
virtual std::string getBrand() const = 0; | ||
|
||
virtual std::string getModel() const = 0; | ||
|
||
virtual std::string getLensModel() const = 0; | ||
|
||
/** Open the file for checking and parsing */ | ||
virtual bool open( const std::string & sFileName ) = 0; | ||
|
||
/**Verify if the file has metadata*/ | ||
virtual bool doesHaveExifInfo() const = 0; | ||
|
||
/** Print all data*/ | ||
virtual std::string allExifData() const = 0; | ||
|
||
}; | ||
#endif //EXIF_IO_HPP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
#ifndef EXIF_IO_EXIV2_HPP | ||
#define EXIF_IO_EXIV2_HPP | ||
|
||
#include "exif_IO.hpp" | ||
|
||
#include <exiv2/exiv2.hpp> | ||
|
||
#include <fstream> | ||
#include <string> | ||
#include <sstream> | ||
|
||
class Exif_IO_Exiv2 : public Exif_IO | ||
{ | ||
public: | ||
Exif_IO_Exiv2() | ||
{ | ||
} | ||
|
||
Exif_IO_Exiv2( const std::string & sFileName ) | ||
{ | ||
open( sFileName ); | ||
} | ||
|
||
size_t getWidth() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "Exif.Photo.PixelXDimension"; | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
try | ||
{ | ||
std::stringstream ss; | ||
ss << exifData[oss.str()].value().toString(); | ||
size_t width; | ||
ss >> width; | ||
return width; | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return -1; | ||
} | ||
} | ||
|
||
size_t getHeight() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "Exif.Photo.PixelYDimension"; | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
try | ||
{ | ||
std::stringstream ss; | ||
ss << exifData[oss.str()].value().toString(); | ||
size_t height; | ||
ss >> height; | ||
return height; | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return -1; | ||
} | ||
} | ||
|
||
float getFocal() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "Exif.Photo.FocalLength"; | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
try | ||
{ | ||
return exifData[oss.str()].value().toFloat(); | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return -1; | ||
} | ||
} | ||
|
||
std::string getBrand() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "Exif.Image.Make"; | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
try | ||
{ | ||
return exifData[oss.str()].value().toString(); | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return ""; | ||
} | ||
} | ||
|
||
std::string getModel() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "Exif.Image.Model"; | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
try | ||
{ | ||
return exifData[oss.str()].value().toString(); | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return ""; | ||
} | ||
} | ||
|
||
std::string getLensModel() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "Exif." << getBrand() << ".LensModel"; | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
try | ||
{ | ||
return exifData[oss.str()].value().toString(); | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return ""; | ||
} | ||
} | ||
|
||
/** Open the file for checking and parsing */ | ||
bool open( const std::string & sFileName ) | ||
{ | ||
bool isOpen = false; | ||
image = Exiv2::ImageFactory::open( sFileName.c_str() ); | ||
Exiv2::IptcData &iptcData = image->iptcData(); | ||
if (!iptcData.empty()) | ||
isOpen = true; | ||
|
||
image->readMetadata(); | ||
return isOpen; | ||
} | ||
|
||
/**Verify if the file has metadata*/ | ||
bool doesHaveExifInfo() const | ||
{ | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
return !exifData.empty(); | ||
} | ||
/** Print all data*/ | ||
std::string allExifData() const | ||
{ | ||
try | ||
{ | ||
Exiv2::ExifData &exifData = image->exifData(); | ||
Exiv2::ExifData::const_iterator end = exifData.end(); | ||
|
||
std::ostringstream oss; | ||
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) | ||
{ | ||
const char* tn = i->typeName(); | ||
oss << std::setw(44) << std::setfill(' ') << std::left | ||
<< i->key() << " " | ||
<< "0x" << std::setw(4) << std::setfill('0') << std::right | ||
<< std::hex << i->tag() << " " | ||
<< std::setw(9) << std::setfill(' ') << std::left | ||
<< (tn ? tn : "Unknown") << " " | ||
<< std::dec << std::setw(3) | ||
<< std::setfill(' ') << std::right | ||
<< i->count() << " " | ||
<< std::dec << i->value() | ||
<< "\n"; | ||
} | ||
return oss.str(); | ||
} | ||
catch (Exiv2::AnyError& e) | ||
{ | ||
std::cout << "Caught Exiv2 exception '" << e << "'\n"; | ||
return ""; | ||
} | ||
} | ||
|
||
private : | ||
Exiv2::Image::AutoPtr image; | ||
}; | ||
#endif //EXIF_IO_EXIV2_HPP |
Oops, something went wrong.