forked from ahojnnes/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 easyexif library and unit test. openMVG#134
- Loading branch information
Showing
11 changed files
with
909 additions
and
4 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,2 +1,2 @@ | ||
ADD_DEFINITIONS(-DTHIS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") | ||
UNIT_TEST(openMVG exif_IO "${EXIV2_LIBRARIES};OpenExif;stlplus") | ||
UNIT_TEST(openMVG exif_IO "${EXIV2_LIBRARIES};OpenExif;easyexif;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,140 @@ | ||
#ifndef EXIF_IO_EASYEXIF_HPP | ||
#define EXIF_IO_EASYEXIF_HPP | ||
|
||
#include "exif_IO.hpp" | ||
#include "third_party/easyexif/exif.h" | ||
|
||
#include <fstream> | ||
#include <string> | ||
#include <sstream> | ||
|
||
class Exif_IO_EasyExif : public Exif_IO | ||
{ | ||
public: | ||
Exif_IO_EasyExif() | ||
{ | ||
} | ||
|
||
Exif_IO_EasyExif( const std::string & sFileName ) | ||
{ | ||
open(sFileName); | ||
} | ||
|
||
bool open( const std::string & sFileName ) | ||
{ | ||
// Read the file into a buffer | ||
FILE *fp = fopen(sFileName.c_str(), "rb"); | ||
if (!fp) { | ||
return false; | ||
} | ||
fseek(fp, 0, SEEK_END); | ||
unsigned long fsize = ftell(fp); | ||
rewind(fp); | ||
std::vector<unsigned char> buf(fsize); | ||
if (fread(&buf[0], 1, fsize, fp) != fsize) { | ||
return false; | ||
} | ||
fclose(fp); | ||
|
||
// Parse EXIF | ||
int code = exifInfo_.parseFrom(&buf[0], fsize); | ||
if (code) | ||
bHaveExifInfo_ = false; | ||
else | ||
bHaveExifInfo_ = true; | ||
|
||
return bHaveExifInfo_; | ||
} | ||
|
||
size_t getWidth() const | ||
{ | ||
return exifInfo_.ImageWidth; | ||
} | ||
|
||
size_t getHeight() const | ||
{ | ||
return exifInfo_.ImageHeight; | ||
} | ||
|
||
float getFocal() const | ||
{ | ||
return static_cast<float>(exifInfo_.FocalLength); | ||
} | ||
|
||
std::string getBrand() const | ||
{ | ||
std::string sbrand = exifInfo_.Make; | ||
// remove leading and trailing spaces | ||
sbrand.erase(0, sbrand.find_first_not_of(' ')); | ||
sbrand.erase(sbrand.find_last_not_of(' ')); | ||
return sbrand; | ||
} | ||
|
||
std::string getModel() const | ||
{ | ||
std::string smodel = exifInfo_.Model; | ||
// remove leading and trailing spaces | ||
smodel.erase(0, smodel.find_first_not_of(' ')); | ||
smodel.erase(smodel.find_last_not_of(' ')); | ||
return smodel; | ||
} | ||
|
||
std::string getLensModel() const | ||
{ | ||
return ""; | ||
} | ||
|
||
/**Verify if the file has metadata*/ | ||
bool doesHaveExifInfo() const | ||
{ | ||
return bHaveExifInfo_; | ||
} | ||
|
||
/** Print all data*/ | ||
std::string allExifData() const | ||
{ | ||
std::ostringstream os; | ||
os | ||
<< "Camera make : " << exifInfo_.Make | ||
<< "Camera model : " << exifInfo_.Model | ||
<< "Software : " << exifInfo_.Software | ||
<< "Bits per sample : " << exifInfo_.BitsPerSample | ||
<< "Image width : " << exifInfo_.ImageWidth | ||
<< "Image height : " << exifInfo_.ImageHeight | ||
<< "Image description : " << exifInfo_.ImageDescription | ||
<< "Image orientation : " << exifInfo_.Orientation | ||
<< "Image copyright : " << exifInfo_.Copyright | ||
<< "Image date/time : " << exifInfo_.DateTime | ||
<< "Original date/time: " << exifInfo_.DateTimeOriginal | ||
<< "Digitize date/time: " << exifInfo_.DateTimeDigitized | ||
<< "Subsecond time : " << exifInfo_.SubSecTimeOriginal | ||
<< "Exposure time : 1/time " << (unsigned) (1.0/exifInfo_.ExposureTime) | ||
<< "F-stop : " << exifInfo_.FNumber | ||
<< "ISO speed : " << exifInfo_.ISOSpeedRatings | ||
<< "Subject distance : " << exifInfo_.SubjectDistance | ||
<< "Exposure bias : EV" << exifInfo_.ExposureBiasValue | ||
<< "Flash used? : " << exifInfo_.Flash | ||
<< "Metering mode : " << exifInfo_.MeteringMode | ||
<< "Lens focal length : mm\n" << exifInfo_.FocalLength | ||
<< "35mm focal length : mm\n" << exifInfo_.FocalLengthIn35mm | ||
<< "GPS Latitude : deg ( deg, min, sec )\n" << "(" | ||
<< exifInfo_.GeoLocation.Latitude << ", " | ||
<< exifInfo_.GeoLocation.LatComponents.degrees << ", " | ||
<< exifInfo_.GeoLocation.LatComponents.minutes << ", " | ||
<< exifInfo_.GeoLocation.LatComponents.seconds << ", " | ||
<< exifInfo_.GeoLocation.LatComponents.direction << ")" | ||
<< "GPS Longitude : deg ( deg, min, sec )\n" << "(" | ||
<< exifInfo_.GeoLocation.Longitude << ", " | ||
<< exifInfo_.GeoLocation.LonComponents.degrees << ", " | ||
<< exifInfo_.GeoLocation.LonComponents.minutes << ", " | ||
<< exifInfo_.GeoLocation.LonComponents.seconds << ", " | ||
<< exifInfo_.GeoLocation.LonComponents.direction << ")" | ||
<< "GPS Altitude : m" << exifInfo_.GeoLocation.Altitude; | ||
return os.str(); | ||
} | ||
|
||
private: | ||
EXIFInfo exifInfo_; | ||
bool bHaveExifInfo_; | ||
}; | ||
#endif //EXIF_IO_EASYEXIF_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
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,5 @@ | ||
PROJECT (easyexif CXX) | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) | ||
|
||
ADD_LIBRARY (easyexif exif.h exif.cpp) |
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,9 @@ | ||
The following people have contributed patches or issues to EasyEXIF: | ||
|
||
Seth Fowler | ||
Val Malykh | ||
Carlos Apablaza Brito | ||
Simon Fuhrmann | ||
Toshiaki Ohkuma | ||
pet.b.hunt | ||
Jason Moey |
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,24 @@ | ||
Copyright (c) 2010 Mayank Lahiri | ||
[email protected] | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
-- Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
-- Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESS | ||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
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,5 @@ | ||
Project: easyexif | ||
URL: https://code.google.com/p/easyexif/ | ||
License: New BSD License | ||
Upstream version: version 2.1 https://code.google.com/p/easyexif/source/browse/trunk/ | ||
|
Oops, something went wrong.