summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-03-07 22:25:03 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-03-07 22:25:03 +0100
commitc00e603b4bfe336683c713cca80cbba47e639678 (patch)
tree514319bb2090b458eb253129033ccc32188e3450 /src
parent4671827b2408eccd6e457660b5817b5f9ae81569 (diff)
add GUI stuff for x0
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.H4
-rw-r--r--src/GipfelWidget.cxx14
-rw-r--r--src/ImageMetaData.H5
-rw-r--r--src/ImageMetaData.cxx14
-rw-r--r--src/Panorama.H4
-rw-r--r--src/Panorama.cxx8
-rw-r--r--src/gipfel.cxx51
7 files changed, 62 insertions, 38 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index 3671a87..a17009a 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -115,9 +115,9 @@ class GipfelWidget : public Fl_Widget {
void set_projection(ProjectionLSQ::Projection_t p);
- void get_distortion_params(double *k0, double *k1);
+ void get_distortion_params(double *k0, double *k1i, double *x0);
- void set_distortion_params(double k0, double k1);
+ void set_distortion_params(double k0, double k1, double x0);
Hills *get_mountains();
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 53fc25b..eb40590 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -99,7 +99,7 @@ GipfelWidget::load_image(char *file) {
// 1. gipfel data in JPEG comment
// 2. matching distortion profile
// 3. set the to 0.0, 0.0
- md->get_distortion_params(&pan->parms.k0, &pan->parms.k1);
+ md->get_distortion_params(&pan->parms.k0, &pan->parms.k1, &pan->parms.x0);
if (isnan(pan->parms.k0)) {
char buf[1024];
get_distortion_profile_name(buf, sizeof(buf));
@@ -138,7 +138,7 @@ GipfelWidget::save_image(char *file) {
md->set_tilt(get_tilt_angle());
md->set_focal_length_35mm(get_focal_length_35mm());
md->set_projection_type((int) get_projection());
- md->set_distortion_params(pan->parms.k0, pan->parms.k1);
+ md->set_distortion_params(pan->parms.k0, pan->parms.k1, pan->parms.x0);
ret = md->save_image(img_file, file);
delete md;
@@ -473,13 +473,13 @@ GipfelWidget::set_projection(ProjectionLSQ::Projection_t p) {
}
void
-GipfelWidget::get_distortion_params(double *k0, double *k1) {
- pan->get_distortion_params(k0, k1);
+GipfelWidget::get_distortion_params(double *k0, double *k1, double *x0) {
+ pan->get_distortion_params(k0, k1, x0);
}
void
-GipfelWidget::set_distortion_params(double k0, double k1) {
- pan->set_distortion_params(k0, k1);
+GipfelWidget::set_distortion_params(double k0, double k1, double x0) {
+ pan->set_distortion_params(k0, k1, x0);
redraw();
}
@@ -802,7 +802,7 @@ GipfelWidget::load_distortion_params(const char *prof_name) {
Fl_Preferences prof(dist_prefs, prof_name);
ret += prof.get("k0", pan->parms.k0, pan->parms.k0);
ret += prof.get("k1", pan->parms.k1, pan->parms.k1);
- ret += prof.get("x0", pan->parms.k1, pan->parms.x0);
+ ret += prof.get("x0", pan->parms.x0, pan->parms.x0);
return !ret;
}
diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H
index 27cbbd8..b7a5959 100644
--- a/src/ImageMetaData.H
+++ b/src/ImageMetaData.H
@@ -19,6 +19,7 @@ class ImageMetaData {
double tilt;
double k0;
double k1;
+ double x0;
double focal_length;
double focal_length_35mm;
double scale;
@@ -47,7 +48,7 @@ class ImageMetaData {
double get_focal_length();
double get_focal_length_35mm();
int get_projection_type();
- void get_distortion_params(double *_k0, double *_k1);
+ void get_distortion_params(double *_k0, double *_k1, double *_x0);
void set_longitude(double v);
void set_latitude(double v);
@@ -57,6 +58,6 @@ class ImageMetaData {
void set_tilt(double v);
void set_focal_length_35mm(double v);
void set_projection_type(int v);
- void set_distortion_params(double _k0, double _k1);
+ void set_distortion_params(double _k0, double _k1, double _x0);
};
#endif
diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx
index e9a1241..368a9ba 100644
--- a/src/ImageMetaData.cxx
+++ b/src/ImageMetaData.cxx
@@ -38,6 +38,7 @@ ImageMetaData::clear() {
tilt = NAN;
k0 = NAN;
k1 = NAN;
+ x0 = NAN;
focal_length = NAN;
focal_length_35mm = NAN;
scale = NAN;
@@ -159,7 +160,7 @@ ImageMetaData::load_image_exif(char *name) {
#define GIPFEL_FORMAT_1 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf, projection type %d"
-#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focal_length_35mm %lf, projection type %d, k0 %lf, k1 %lf"
+#define GIPFEL_FORMAT_2 "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, focal_length_35mm %lf, projection type %d, k0 %lf, k1 %lf, x0 %lf"
int
ImageMetaData::load_image_jpgcom(char *name) {
@@ -168,7 +169,7 @@ ImageMetaData::load_image_jpgcom(char *name) {
pid_t pid;
int status;
char buf[1024];
- double lo, la, he, dir, ni, ti, fr, _k0, _k1;
+ double lo, la, he, dir, ni, ti, fr, _k0, _k1, _x0 = 0.0;
int pt = 0;
int n, ret = 1;
@@ -181,7 +182,7 @@ ImageMetaData::load_image_jpgcom(char *name) {
if (p) {
while (fgets(buf, sizeof(buf), p) != NULL) {
if ((n = sscanf(buf, GIPFEL_FORMAT_2,
- &lo, &la, &he, &dir, &ni, &ti, &fr, &pt, &_k0, &_k1)) >= 8) {
+ &lo, &la, &he, &dir, &ni, &ti, &fr, &pt, &_k0, &_k1, &_x0)) >= 8) {
longitude = lo;
latitude = la;
@@ -195,6 +196,7 @@ ImageMetaData::load_image_jpgcom(char *name) {
if (n >= 10) {
k0 = _k0;
k1 = _k1;
+ x0 = _x0;
}
ret = 0;
@@ -395,13 +397,15 @@ ImageMetaData::set_projection_type(int v) {
}
void
-ImageMetaData::get_distortion_params(double *_k0, double *_k1) {
+ImageMetaData::get_distortion_params(double *_k0, double *_k1, double *_x0) {
*_k0 = k0;
*_k1 = k1;
+ *_x0 = x0;
}
void
-ImageMetaData::set_distortion_params(double _k0, double _k1) {
+ImageMetaData::set_distortion_params(double _k0, double _k1, double _x0) {
k0 = _k0;
k1 = _k1;
+ x0 = _x0;
}
diff --git a/src/Panorama.H b/src/Panorama.H
index 3d5b260..d5ebb37 100644
--- a/src/Panorama.H
+++ b/src/Panorama.H
@@ -124,9 +124,9 @@ class Panorama {
void set_projection(ProjectionLSQ::Projection_t p);
- void get_distortion_params(double *k0, double *k1);
+ void get_distortion_params(double *k0, double *k1, double *x0);
- void set_distortion_params(double k0, double k1);
+ void set_distortion_params(double k0, double k1, double x0);
int get_coordinates(double a_alph, double a_nick, double *x, double *y);
};
diff --git a/src/Panorama.cxx b/src/Panorama.cxx
index 839d70c..7b1529b 100644
--- a/src/Panorama.cxx
+++ b/src/Panorama.cxx
@@ -166,15 +166,17 @@ Panorama::set_scale(double s) {
}
void
-Panorama::get_distortion_params(double *k0, double *k1) {
+Panorama::get_distortion_params(double *k0, double *k1, double *x0) {
*k0 = parms.k0;
*k1 = parms.k1;
+ *x0 = parms.x0;
}
void
-Panorama::set_distortion_params(double k0, double k1) {
+Panorama::set_distortion_params(double k0, double k1, double x0) {
parms.k0 = k0;
parms.k1 = k1;
+ parms.x0 = x0;
update_coordinates();
}
@@ -451,7 +453,7 @@ Panorama::get_earth_radius(double phi) {
double b = 6356752.315;
double r;
double ata = tan(phi);
-
+return EARTH_RADIUS;
r = a*pow(pow(ata,2)+1,1.0/2.0)*fabs(b)*pow(pow(b,2)+pow(a,2)*pow(ata,2),-1.0/2.0);
return r;
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index bb58586..5807ae5 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -46,7 +46,7 @@ Fl_Window *control_win, *view_win;
Fl_Dial *s_center = NULL;
Fl_Slider *s_nick, *s_focal_length, *s_tilt, *s_height_dist, *s_track_width;
Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height;
-Fl_Value_Input *i_distortion_k0, *i_distortion_k1;
+Fl_Value_Input *i_distortion_k0, *i_distortion_k1, *i_distortion_x0;
Fl_Box *b_viewpoint;
Fl_Menu_Bar *mb;
@@ -58,7 +58,7 @@ static int stitch(GipfelWidget::sample_mode_t m ,int stitch_w, int stitch_h,
double from, double to, int type, const char *path, int argc, char **argv);
void set_values() {
- double k0 = 0.0, k1 = 0.0;
+ double k0 = 0.0, k1 = 0.0, x0 = 0.0;
s_center->value(gipf->get_center_angle());
s_nick->value(gipf->get_nick_angle());
@@ -77,9 +77,10 @@ void set_values() {
mb->mode(8, FL_MENU_RADIO);
}
- gipf->get_distortion_params(&k0, &k1);
+ gipf->get_distortion_params(&k0, &k1, &x0);
i_distortion_k0->value(k0);
i_distortion_k1->value(k1);
+ i_distortion_x0->value(x0);
}
void quit_cb() {
@@ -174,12 +175,12 @@ void comp_cb(Fl_Widget *, void *) {
void save_distortion_cb(Fl_Widget *, void *) {
char buf[1024];
const char * prof_name;
- double k0, k1;
+ double k0, k1, x0;
- gipf->get_distortion_params(&k0, &k1);
+ gipf->get_distortion_params(&k0, &k1, &x0);
gipf->get_distortion_profile_name(buf, sizeof(buf));
- prof_name = fl_input("Save Distortion Profile (k0=%f, k1=%f)",
- buf, k0, k1);
+ prof_name = fl_input("Save Distortion Profile (k0=%f, k1=%f, x0=%f)",
+ buf, k0, k1, x0);
if (prof_name == NULL) {
return;
@@ -208,8 +209,10 @@ void load_distortion_cb(Fl_Widget *, void *) {
}
void distortion_cb(Fl_Value_Input*, void*) {
- gipf->set_distortion_params(i_distortion_k0->value(),
- i_distortion_k1->value());
+ gipf->set_distortion_params(
+ i_distortion_k0->value(),
+ i_distortion_k1->value(),
+ i_distortion_x0->value());
}
void about_cb() {
@@ -355,23 +358,31 @@ create_control_window() {
i_view_height->when(FL_WHEN_ENTER_KEY);
i_view_height->callback((Fl_Callback*)view_height_cb);
- i_distortion_k0 = new Fl_Value_Input(235, 220, 80, 20, "Distortion (k0)");
+ i_distortion_k0 = new Fl_Value_Input(250, 200, 80, 20, "k0");
i_distortion_k0->labelsize(10);
i_distortion_k0->textsize(10);
- i_distortion_k0->align(FL_ALIGN_TOP);
+ i_distortion_k0->align(FL_ALIGN_LEFT);
i_distortion_k0->when(FL_WHEN_ENTER_KEY);
i_distortion_k0->callback((Fl_Callback*)distortion_cb);
- i_distortion_k1 = new Fl_Value_Input(315, 220, 80, 20, "Distortion (k1)");
+ i_distortion_k1 = new Fl_Value_Input(250, 225, 80, 20, "k1");
i_distortion_k1->labelsize(10);
i_distortion_k1->textsize(10);
- i_distortion_k1->align(FL_ALIGN_TOP);
+ i_distortion_k1->align(FL_ALIGN_LEFT);
i_distortion_k1->when(FL_WHEN_ENTER_KEY);
i_distortion_k1->callback((Fl_Callback*)distortion_cb);
+ i_distortion_x0 = new Fl_Value_Input(250, 250, 80, 20, "x0");
+ i_distortion_x0->labelsize(10);
+ i_distortion_x0->textsize(10);
+ i_distortion_x0->align(FL_ALIGN_LEFT);
+ i_distortion_x0->when(FL_WHEN_ENTER_KEY);
+ i_distortion_x0->callback((Fl_Callback*)distortion_cb);
+
+
// Buttons
- Fl_Button *b = new Fl_Button(260, 260, 100, 20, "comp");
+ Fl_Button *b = new Fl_Button(280, 280, 100, 20, "comp");
b->color(FL_RED);
b->tooltip("compute view parameter from given mountains");
b->callback(comp_cb);
@@ -388,7 +399,7 @@ int main(int argc, char** argv) {
int jpeg_flag = 0, tiff_flag = 0, distortion_flag = 0;
int bilinear_flag = 0;
double stitch_from = 0.0, stitch_to = 380.0;
- double dist_k0 = 0.0, dist_k1 = 0.0;
+ double dist_k0 = 0.0, dist_k1 = 0.0, dist_x0 = 0.0;
char *outpath = "/tmp";
Fl_Scroll *scroll;
@@ -419,11 +430,17 @@ int main(int argc, char** argv) {
}
break;
case 'u':
+ char *c;
distortion_flag++;
if (optarg && strcmp(optarg, ":")) {
dist_k0 = atof(optarg);
- if (strchr(optarg, ',')) {
+ c = strchr(optarg, ',');
+ if (c) {
dist_k1 = atof(strchr(optarg, ',') + 1);
+ c = strchr(c + 1, ',');
+ if (c) {
+ dist_x0 = atof(strchr(optarg, ',') + 1);
+ }
}
}
break;
@@ -501,7 +518,7 @@ int main(int argc, char** argv) {
}
if (distortion_flag) {
- gipf->set_distortion_params(dist_k0, dist_k1);
+ gipf->set_distortion_params(dist_k0, dist_k1, dist_x0);
}
view_win->size(gipf->w(), gipf->h());