summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-12-18 20:09:32 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-12-18 20:09:32 +0100
commit7872b3cd1f6d1ee55f9b5fc772fe5463bd3c647e (patch)
tree378d60afb2dc69dfb269d522734677fcb106847a
parent2bb6b0766cbc941fa3bfc1b5ed17cf530c841ba3 (diff)
add manufacturer model and focal_length to ImageMetaData
-rw-r--r--src/ImageMetaData.H7
-rw-r--r--src/ImageMetaData.cxx65
2 files changed, 59 insertions, 13 deletions
diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H
index aa85c15..f9baf75 100644
--- a/src/ImageMetaData.H
+++ b/src/ImageMetaData.H
@@ -9,6 +9,8 @@
class ImageMetaData {
private:
+ char *manufacturer;
+ char *model;
double longitude;
double latitude;
double height;
@@ -17,6 +19,7 @@ class ImageMetaData {
double tilt;
double k0;
double k1;
+ double focal_length;
double focal_length_35mm;
double scale;
int projection_type;
@@ -27,16 +30,20 @@ class ImageMetaData {
public:
ImageMetaData();
+ ~ImageMetaData();
int load_image(char *name, int img_width);
int save_image(char *in_img, char *out_img);
+ const char *get_manufacturer();
+ const char *get_model();
double get_longitude();
double get_latitude();
double get_height();
double get_direction();
double get_nick();
double get_tilt();
+ double get_focal_length();
double get_focal_length_35mm();
int get_projection_type();
void get_distortion_params(double *_k0, double *_k1);
diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx
index 007d7b9..0e2c03b 100644
--- a/src/ImageMetaData.cxx
+++ b/src/ImageMetaData.cxx
@@ -18,19 +18,26 @@
#include "ImageMetaData.H"
ImageMetaData::ImageMetaData() {
+ manufacturer = NULL;
+ model = NULL;
longitude = NAN;
latitude = NAN;
- height = 0.0;
- direction = 0.0;
- nick = 0.0;
- tilt = 0.0;
- k0 = 0.0;
- k1 = 0.0;
- focal_length_35mm = 35.0;
+ height = NAN;
+ direction = NAN;
+ nick = NAN;
+ tilt = NAN;
+ k0 = NAN;
+ k1 = NAN;
+ focal_length = NAN;
+ focal_length_35mm = NAN;
scale = NAN;
projection_type = 0;
}
+ImageMetaData::~ImageMetaData() {
+ if (manufacturer) free(manufacturer);
+ if (model) free(model);
+}
int
ImageMetaData::load_image(char *name, int img_width) {
@@ -39,10 +46,16 @@ ImageMetaData::load_image(char *name, int img_width) {
ret = load_image_jpgcom(name);
if (ret == 2) { // old format
focal_length_35mm = scale * 35.0 / (double) img_width;
- } else if (ret == 1) { // get reasonable defaults from exif data
- ret = load_image_exif(name);
}
+ load_image_exif(name); // fill missing values from exif data
+
+ if (isnan(direction)) direction = 0.0;
+ if (isnan(nick)) nick = 0.0;
+ if (isnan(tilt)) tilt = 0.0;
+ if (isnan(k0)) k0 = 0.0;
+ if (isnan(k1)) k1 = 0.0;
+
return ret;
}
@@ -69,6 +82,9 @@ degminsecstr2double(char *val) {
return ret;
}
+#define EXIF_MANUFACTURER 0x010f
+#define EXIF_MODEL 0x0110
+#define EXIF_FOCAL_LENGTH 0x920a
#define EXIF_FOCAL_LENGTH_IN_35MM_FILM 0xa405
#define EXIF_GPS_LATIITUDE 0x0002
#define EXIF_GPS_LONGITUDE 0x0004
@@ -99,17 +115,26 @@ ImageMetaData::load_image_exif(char *name) {
}
switch(id) {
+ case EXIF_MANUFACTURER:
+ if (!manufacturer) manufacturer = strdup(val);
+ break;
+ case EXIF_MODEL:
+ if (!model) model = strdup(val);
+ break;
+ case EXIF_FOCAL_LENGTH:
+ if (isnan(focal_length)) focal_length = atof(val);
+ break;
case EXIF_FOCAL_LENGTH_IN_35MM_FILM:
- focal_length_35mm = atof(val);
+ if (isnan(focal_length_35mm)) focal_length_35mm = atof(val);
break;
case EXIF_GPS_LONGITUDE:
- longitude = degminsecstr2double(val);
+ if (isnan(longitude)) longitude = degminsecstr2double(val);
break;
case EXIF_GPS_LATIITUDE:
- latitude = degminsecstr2double(val);
+ if (isnan(latitude)) latitude = degminsecstr2double(val);
break;
case EXIF_GPS_ALTITUDE:
- height = atof(val);
+ if (isnan(height)) height = atof(val);
break;
}
}
@@ -266,6 +291,15 @@ ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) {
return 0;
}
+const char*
+ImageMetaData::get_manufacturer() {
+ return manufacturer;
+}
+
+const char*
+ImageMetaData::get_model() {
+ return model;
+}
double
ImageMetaData::get_longitude() {
@@ -298,6 +332,11 @@ ImageMetaData::get_tilt() {
}
double
+ImageMetaData::get_focal_length() {
+ return focal_length;
+}
+
+double
ImageMetaData::get_focal_length_35mm() {
return focal_length_35mm;
}