diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2006-12-17 12:21:59 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2006-12-17 12:21:59 +0100 |
commit | 0043004652720b9b726b96151db2946def6fd6b6 (patch) | |
tree | da9ad2ade43bd8b1b3d6799333213b221d74de52 /src | |
parent | e6ce5c34e610f27a6b0f7810918bf638c49c72d7 (diff) |
fix warnings
remove guess stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/GipfelWidget.H | 4 | ||||
-rw-r--r-- | src/GipfelWidget.cxx | 39 | ||||
-rw-r--r-- | src/ImageMetaData.H | 2 | ||||
-rw-r--r-- | src/ImageMetaData.cxx | 4 | ||||
-rw-r--r-- | src/OutputImage.H | 2 | ||||
-rw-r--r-- | src/Panorama.H | 2 | ||||
-rw-r--r-- | src/Panorama.cxx | 81 | ||||
-rw-r--r-- | src/ProjectionTangentialLSQ.H | 6 | ||||
-rw-r--r-- | src/ProjectionTangentialLSQ.cxx | 92 | ||||
-rw-r--r-- | src/Stitch.cxx | 4 | ||||
-rw-r--r-- | src/TIFFOutputImage.cxx | 2 | ||||
-rw-r--r-- | src/gipfel.cxx | 23 |
12 files changed, 31 insertions, 230 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index d8b08fe..d504de0 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -114,10 +114,6 @@ class GipfelWidget : public Fl_Widget { int comp_params(); - int guess(); - - int update(); - int get_pixel(double a_alph, double a_nick, uchar *r, uchar *g, uchar *b); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 939eccc..3b70b3a 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -62,7 +62,6 @@ int GipfelWidget::load_image(char *file) { Fl_Image *new_img; ImageMetaData *md; - int ret; new_img = new Fl_JPEG_Image(file); @@ -254,7 +253,7 @@ GipfelWidget::draw() { /* track */ if (track_points && track_points->get_num() > 0) { - int last_x, last_y, last_initialized = 0; + int last_x = 0, last_y = 0, last_initialized = 0; for (i=1; i<track_points->get_num(); i++) { m = mnts->get(i); @@ -334,7 +333,7 @@ GipfelWidget::set_labels(Hills *v) { overlap(m->y + m->label_y - height, m->y + m->label_y, n->y + n->label_y - height, n->y + n->label_y)) || (overlap(m->x, m->x + m->label_x, n->x - 2, n->x + 2) && overlap(m->y + m->label_y - height, m->y + m->label_y, n->y - 2, n->y + 2))) { - m->label_y = n->y + n->label_y - m->y - height - 1; + m->label_y = (int) rint(n->y + n->label_y - m->y - height - 1); } } } @@ -417,8 +416,8 @@ GipfelWidget::set_mountain(int m_x, int m_y) { return 1; } - old_x = cur_mountain->x; - old_y = cur_mountain->y; + old_x = (int) rint(cur_mountain->x); + old_y = (int) rint(cur_mountain->y); old_label_y = cur_mountain->label_y; cur_mountain->x = m_x - center_x; @@ -429,8 +428,9 @@ GipfelWidget::set_mountain(int m_x, int m_y) { center_y + y() + old_y + old_label_y - 2*CROSS_SIZE - 20, MAX(20, cur_mountain->label_x) + 2*CROSS_SIZE + 2, MAX(20, old_label_y) + 22 ); - damage(4, center_x + x() + cur_mountain->x - 2*CROSS_SIZE - 1, - center_y + y() + cur_mountain->y + cur_mountain->label_y - 2*CROSS_SIZE - 20, + damage(4, + (int) rint(center_x + x() + cur_mountain->x - 2*CROSS_SIZE - 1), + (int) rint(center_y + y() + cur_mountain->y + cur_mountain->label_y - 2*CROSS_SIZE - 20), MAX(20, cur_mountain->label_x) + 2*CROSS_SIZE + 2, MAX(20, cur_mountain->label_y) + 22 ); @@ -598,41 +598,26 @@ GipfelWidget::get_mountains() { int GipfelWidget::comp_params() { + int ret; + if (known_hills->get_num() < 2) { fprintf(stderr, "Position m1 and m2 first.\n"); return 1; } fl_cursor(FL_CURSOR_WAIT); - pan->comp_params(known_hills); - set_labels(pan->get_visible_mountains()); - redraw(); - fl_cursor(FL_CURSOR_DEFAULT); -} - -int -GipfelWidget::guess() { - if (known_hills->get_num() < 1) { - fprintf(stderr, "Position m1 first.\n"); - return 1; - } - fl_cursor(FL_CURSOR_WAIT); - pan->guess(marker, known_hills->get(0)); + ret = pan->comp_params(known_hills); set_labels(pan->get_visible_mountains()); redraw(); fl_cursor(FL_CURSOR_DEFAULT); -} -int -GipfelWidget::update() { - redraw(); - Fl::wait(1.0); + return ret; } int GipfelWidget::get_rel_track_width(Hill *m) { double dist = pan->get_real_distance(m); - return MAX((pan->get_scale() * track_width) / (dist * 10.0), 1.0); + return (int) rint(MAX((pan->get_scale()*track_width)/(dist*10.0), 1.0)); } void diff --git a/src/ImageMetaData.H b/src/ImageMetaData.H index da63db6..aa85c15 100644 --- a/src/ImageMetaData.H +++ b/src/ImageMetaData.H @@ -17,8 +17,6 @@ class ImageMetaData { double tilt; double k0; double k1; - double u0; - double v0; double focal_length_35mm; double scale; int projection_type; diff --git a/src/ImageMetaData.cxx b/src/ImageMetaData.cxx index d59db9d..007d7b9 100644 --- a/src/ImageMetaData.cxx +++ b/src/ImageMetaData.cxx @@ -26,8 +26,6 @@ ImageMetaData::ImageMetaData() { tilt = 0.0; k0 = 0.0; k1 = 0.0; - u0 = 0.0; - v0 = 0.0; focal_length_35mm = 35.0; scale = NAN; projection_type = 0; @@ -236,7 +234,7 @@ ImageMetaData::save_image_jpgcom(char *in_img, char *out_img) { tilt, focal_length_35mm, projection_type, - k0, k1, u0, v0); + k0, k1); // try to save gipfel data in JPEG comment section args[0] = "wrjpgcom"; diff --git a/src/OutputImage.H b/src/OutputImage.H index 9be72c5..7c9f0fd 100644 --- a/src/OutputImage.H +++ b/src/OutputImage.H @@ -15,7 +15,7 @@ class OutputImage { public: OutputImage(); - ~OutputImage(); + virtual ~OutputImage(); virtual int init(int w1, int h1); diff --git a/src/Panorama.H b/src/Panorama.H index 60ccb8e..ca000f3 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -125,8 +125,6 @@ class Panorama { int comp_params(Hills *h); - int guess(Hills *p1, Hill *m1); - Projection::Projection_t get_projection(); void set_projection(Projection::Projection_t p); diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 521a4ab..948d2f4 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -131,7 +131,6 @@ Panorama::get_visible_mountains() { double Panorama::get_value(Hills *p) { int i, j; - Hill *m; double v = 0.0, d_min, d; if (isnan(parms.scale) || isnan(parms.a_center) || isnan(parms.a_tilt) || isnan(parms.a_nick) || @@ -157,72 +156,6 @@ Panorama::get_value(Hills *p) { return v; } -int -Panorama::guess(Hills *p, Hill *m1) { - Hill *p2, *m_tmp1, *m_tmp2; - Hill *m2; - Hills h; - double best = 100000000.0, v; - double a_center_best, a_nick_best, a_tilt_best, scale_best; - double x1_sav, y1_sav; - int i, j; - - if (m1 == NULL) { - fprintf(stderr, "Position one mountain first.\n"); - return 1; - } - - m_tmp1 = m1; - x1_sav = m1->x; - y1_sav = m1->y; - - for (i=0; i<p->get_num(); i++) { - p2 = p->get(i); - for (j=0; j<close_mountains->get_num(); j++) { - m_tmp2 = close_mountains->get(j); - - m1 = m_tmp1; - m1->x = x1_sav; - m1->y = y1_sav; - - if (m_tmp2->flags & Hill::TRACK_POINT || - m1 == m_tmp2 || fabs(m1->alph - m_tmp2->alph) > pi_d *0.7) { - continue; - } - - m2 = m_tmp2; - m2->x = p2->x; - m2->y = p2->y; - - h.clear(); - h.add(m1); - h.add(m2); - comp_params(&h); - - v = get_value(p); - - if (v < best) { - best = v; - a_center_best = parms.a_center; - a_nick_best = parms.a_nick; - a_tilt_best = parms.a_tilt; - scale_best = parms.scale; - } - } - } - - if (best < 4000.0) { - parms.a_center = a_center_best; - parms.a_nick = a_nick_best; - parms.a_tilt = a_tilt_best; - parms.scale = scale_best; - } else { - fprintf(stderr, "No solution found.\n"); - } - update_visible_mountains(); - return 0; -} - int Panorama::comp_params(Hills *h) { int ret; @@ -361,25 +294,19 @@ Panorama::get_projection() { Hill * Panorama::get_pos(const char *name) { int i; - int found = 0; - double p, l, h; - Hill *m, *ret; + Hill *m, *ret = NULL; for (i=0; i<mountains->get_num(); i++) { m = mountains->get(i); if (strcmp(m->name, name) == 0) { ret = m; - fprintf(stderr, "Found matching entry: %s (%fm)\n", m->name, m->height); - found++; + fprintf(stderr, "Found matching entry: %s (%fm)\n", + m->name, m->height); } } - if (found == 1) { - return ret; - } - - return NULL; + return ret; } void diff --git a/src/ProjectionTangentialLSQ.H b/src/ProjectionTangentialLSQ.H index dea10ea..f0fa837 100644 --- a/src/ProjectionTangentialLSQ.H +++ b/src/ProjectionTangentialLSQ.H @@ -12,13 +12,8 @@ class ProjectionTangentialLSQ : public Projection { private: - double comp_center_angle(double alph_a, double alph_b, - double d1, double d2); - double comp_scale(double alph_a, double alph_b, double d1, double d2); - double angle_dist(double a1, double a2); - int lsq(const Hills *m, ViewParams *parms); public: @@ -26,6 +21,5 @@ class ProjectionTangentialLSQ : public Projection { const ViewParams *parms, double *x, double *y); int comp_params(const Hills *h, ViewParams *parms); - }; #endif diff --git a/src/ProjectionTangentialLSQ.cxx b/src/ProjectionTangentialLSQ.cxx index 1a2f0f9..4235980 100644 --- a/src/ProjectionTangentialLSQ.cxx +++ b/src/ProjectionTangentialLSQ.cxx @@ -22,19 +22,12 @@ static double sec(double a) { return 1.0 / cos(a); } -static double pi_d = asin(1.0) * 2.0, deg2rad = pi_d / 180.0; - #include "lsq_funcs.c" -static double -comp_tilt(double tan_nick_view, double tan_dir_view, double n_scale, - double tan_nick_m, double tan_dir_m, - double x, double y, double pi_d); - int ProjectionTangentialLSQ::comp_params(const Hills *h, ViewParams *parms) { const Hill *tmp, *m1, *m2; - double a_center_tmp, scale_tmp, a_nick_tmp; + double scale_tmp; if (h->get_num() < 2) { fprintf(stderr, "Please position at least 2 hills\n"); @@ -73,27 +66,6 @@ ProjectionTangentialLSQ::comp_params(const Hills *h, ViewParams *parms) { } } -double -ProjectionTangentialLSQ::angle_dist(double a1, double a2) { - double ret; - - a1 = fmod(a1, 2.0 * pi_d); - if (a1 < 0.0) { - a1 = a1 + 2.0 * pi_d; - } - a2 = fmod(a2, 2.0 * pi_d); - if (a2 < 0.0) { - a2 = a2 + 2.0 * pi_d; - } - - ret = fabs(a1 - a2); - if (ret > pi_d) { - ret = 2.0 * pi_d - ret; - } - - return ret; -} - struct data { const Hills *h; const ViewParams *old_params; @@ -104,7 +76,7 @@ struct data { static int lsq_f (const gsl_vector * x, void *data, gsl_vector * f) { struct data *dat = (struct data *) data; - double c_view, c_nick, c_tilt, scale, k0, k1, u0, v0; + double c_view, c_nick, c_tilt, scale, k0, k1; c_view = gsl_vector_get (x, 0); c_nick = gsl_vector_get (x, 1); @@ -135,7 +107,7 @@ lsq_f (const gsl_vector * x, void *data, gsl_vector * f) { static int lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) { struct data *dat = (struct data *) data; - double c_view, c_nick, c_tilt, scale, k0, k1, u0, v0; + double c_view, c_nick, c_tilt, scale, k0, k1; c_view = gsl_vector_get (x, 0); c_nick = gsl_vector_get (x, 1); @@ -257,33 +229,6 @@ ProjectionTangentialLSQ::get_coordinates(double alph, double a_nick, } double -ProjectionTangentialLSQ::comp_center_angle(double a1, double a2, double d1, double d2) { - double sign1 = 1.0; - double tan_acenter, tan_a1, tan_a2, a_center; - - tan_a1 = tan(a1); - tan_a2 = tan(a2); - - tan_acenter = (((pow(((pow((1.0 + (tan_a1 * tan_a2)), 2.0) * ((d1 * d1) + (d2 * d2))) + (2.0 * d1 * d2 * ((2.0 * ((tan_a2 * tan_a1) - (tan_a2 * tan_a2))) - ((tan_a1 * tan_a1) * (2.0 + (tan_a2 * tan_a2))) - 1.0))), (1.0 / 2.0)) * sign1) + ((1.0 - (tan_a1 * tan_a2)) * (d1 - d2))) / (2.0 * ((d2 * tan_a2) - (d1 * tan_a1)))); - - a_center = atan(tan_acenter); - - if (a_center > 2.0 * pi_d) { - a_center = a_center - 2.0 * pi_d; - } else if (a_center < 0.0) { - a_center = a_center + 2.0 * pi_d; - } - - // atan(tan_dir_view) is not the only possible solution. - // Choose the one which is close to m1->alph. - if (fabs(a_center - a1) > pi_d/2.0) { - a_center = a_center + pi_d; - } - - return a_center; -} - -double ProjectionTangentialLSQ::comp_scale(double a1, double a2, double d1, double d2) { double sign1 = 1.0; double sc, tan_a1, tan_a2; @@ -295,34 +240,3 @@ ProjectionTangentialLSQ::comp_scale(double a1, double a2, double d1, double d2) return sc; } - -static double -comp_tilt(double tan_nick_view, double tan_dir_view, double n_scale, - double tan_nick_m, double tan_dir_m, - double x, double y, double pi_d) { - double y_tmp, x_tmp, sin_a_tilt1, sin_a_tilt2, sin_a_tilt, res; - - y_tmp = - (((tan_nick_view - tan_nick_m) * n_scale) / - (tan_nick_m * tan_nick_view + 1)); - x_tmp = - (((tan_dir_view - tan_dir_m) * n_scale) / - (tan_dir_m * tan_dir_view + 1)); - - - sin_a_tilt1 = - (y * - pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / - (x*x + y*y); - - sin_a_tilt2 = - (y * pow(x*x + y*y - y_tmp*y_tmp, 0.5) - x * y_tmp) / - (x*x + y*y); - - sin_a_tilt = fabs(sin_a_tilt1) < fabs(sin_a_tilt2)?sin_a_tilt1:sin_a_tilt2; - - res = asin(sin_a_tilt); - - if (res > pi_d / 4.0) { - res = res - pi_d / 2.0; - } else if (res < -pi_d / 4.0) { - res = res + pi_d / 2.0; - } - - return res; -} diff --git a/src/Stitch.cxx b/src/Stitch.cxx index d749aff..6fd0d84 100644 --- a/src/Stitch.cxx +++ b/src/Stitch.cxx @@ -49,7 +49,7 @@ Stitch::load_image(char *file) { } } - + return 0; } OutputImage* @@ -138,4 +138,6 @@ Stitch::resample(int w, int h, single_images[i]->done(); } } + + return 0; } diff --git a/src/TIFFOutputImage.cxx b/src/TIFFOutputImage.cxx index cc1b289..397caac 100644 --- a/src/TIFFOutputImage.cxx +++ b/src/TIFFOutputImage.cxx @@ -72,8 +72,6 @@ TIFFOutputImage::set_pixel_internal(int x, char r, char g, char b) { int TIFFOutputImage::next_line_internal() { - int ret; - TIFFWriteEncodedStrip(tiff, line -1 , row, W * 4); memset(row, 0, sizeof(char) * 4 * W); diff --git a/src/gipfel.cxx b/src/gipfel.cxx index de5d748..89a5f26 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -163,11 +163,6 @@ void comp_cb(Fl_Widget *, void *) { set_values(); } -void guess_cb(Fl_Widget *, void *) { - gipf->guess(); - set_values(); -} - void about_cb() { fl_message("gipfel -- and you know what you see.\n" "Version %s\n\n" @@ -227,11 +222,10 @@ create_control_window() { s_center->angles(180, 540); s_center->callback((Fl_Callback*)angle_cb); - Fl_Box *north = new Fl_Box(95, 40, 40, 20, "North"); - Fl_Box *south = new Fl_Box(95, 210, 40, 20, "South"); - Fl_Box *east = new Fl_Box(190, 125, 40, 20, "East"); - Fl_Box *west = new Fl_Box(0, 125, 40, 20, "West"); - + win->add(new Fl_Box(95, 40, 40, 20, "North")); + win->add(new Fl_Box(95, 210, 40, 20, "South")); + win->add(new Fl_Box(190, 125, 40, 20, "East")); + win->add(new Fl_Box(0, 125, 40, 20, "West")); s_focal_length = new Fl_Value_Slider(235, 60, 160, 15, "Focal Length in 35mm"); s_focal_length->type(1); @@ -311,23 +305,20 @@ create_control_window() { Fl_Button *b = new Fl_Button(240, 210, 60, 20, "comp"); b->color(FL_RED); b->callback(comp_cb); - Fl_Button *b1 = new Fl_Button(320, 210, 60, 20, "guess"); - b1->callback(guess_cb); - b1->color(FL_GREEN); win->end(); return win; } int main(int argc, char** argv) { - char c, *sep, *tmp, **my_argv; + char c, **my_argv; char *view_point = NULL; - int err, bflag = 0, dflag = 0, my_argc; + int err, my_argc; int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; int jpeg_flag = 0, tiff_flag = 0, distortion_flag = 0; double stitch_from = 0.0, stitch_to = 380.0; double dist_k0 = 0.0, dist_k1 = 0.0; - char *outpath; + char *outpath = "/tmp"; Fl_Scroll *scroll; |