Commit 360eb591 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

improving fitting

parent 24a92f5c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4509,8 +4509,8 @@ public class GpuQuad{ // quad camera description
					double [][] cxy = new double [2][2]; // image number, {x,y}
					int [][] icxy = new int [2][2];
					for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
						int tileY = nTile / tiles_woi.width + tiles_woi.x;
						int tileX = nTile % tiles_woi.width + tiles_woi.y;
						int tileY = nTile / tiles_woi.width + tiles_woi.y;
						int tileX = nTile % tiles_woi.width + tiles_woi.x;
						double [] cxy0 = {
								(tileX + 0.5) * GPUTileProcessor.DTT_SIZE,
								(tileY + 0.5) * GPUTileProcessor.DTT_SIZE};
+101 −36
Original line number Diff line number Diff line
@@ -59,8 +59,8 @@ public class ComboMatch {
//		String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_08_november.data";
//		String files_list_path =          "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_10_short.list";
//		String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_10_short.data";
		String files_list_path =          "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13.list";
		String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13.data";
		String files_list_path =          "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.list";
		String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.data";
//maps_19_sep13.list		
		//maps_09_short.list
//maps_08_november.list		
@@ -76,21 +76,30 @@ public class ComboMatch {
//		String [] gpu_spair = {"1697877465_672024", "1697877528_776377"};
//		String [] gpu_spair = {"1694564245_111645", "1694564701_230240"}; // Morning Sep, 13
//		String [] gpu_spair = {"1694564245_111645", "1694564822_637346"}; // Morning Sep, 13
		String [] gpu_spair = {"1694564248_145989", "1694564819_336247"}; // Morning Sep, 13

//		String [] gpu_spair = {"1694564248_145989", "1694564819_336247"}; // Morning Sep, 13
//		String [] gpu_spair = {"1694564269_536448", "1694564822_637346"}; // Morning Sep, 13 50m, 75m
//		String [] gpu_spair = {"1694564269_536448", "1694565541_040640"};  // Morning Sep, 13 50m, 100m
//		String [] gpu_spair = {"1694564822_637346", "1694565541_040640"};  // Morning Sep, 13 75m, 100m
//		String [] gpu_spair = {"1694564263_701171", "1694564816_468625"};  // Morning Sep, 13 50m, 75m
//		String [] gpu_spair = {"1694564266_568793", "1694564819_336247"};  // Morning Sep, 13 50m, 75m
//		String [] gpu_spair = {"1694564270_086631", "1694564822_637346"};  // Morning Sep, 13 50m, 75m
//		String [] gpu_spair = {"1694564272_770858", "1694564778_589341"};  // Morning Sep, 13 50m, 75m #13-#63
//		String [] gpu_spair = {"1694564275_538447", "1694564744_411290"};  // Morning Sep, 13 50m, 75m #14-#58
		String [] gpu_spair = {"1694564270_086631", "1694563011_045597"};  // Morning Sep, 13 50m, 25m #88-#68
//		
		
		double [][][] image_enuatr = {{{0,0,0},{0,0,0}},{{0,0,0},{0,0,0}}};
		int gpu_width=  clt_parameters.imp.rln_gpu_width; // 3008;
		int gpu_height= clt_parameters.imp.rln_gpu_height; // 3008;
		int zoom_lev = -3; // 0; // +1 - zoom in twice, -1 - zoom out twice
		boolean show_combo_map = false; // true;
		boolean use_alt = false;
		boolean show_centers = true;
		boolean use_saved_collection = true; // false;
		boolean save_collection = true;
		boolean process_correlation = true; // use false to save new version of data
		boolean restore_temp        = true;
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,800);
		double           frac_remove  =        0.25;
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,900);
		gd.addStringField ("Image list full path",  files_list_path, 180, "Image list full path.");
		gd.addStringField ("Maps collection save path",  orthoMapsCollection_path, 180, "Save path for serialized map collection data.");
		gd.addCheckbox    ("Use saved maps collection", use_saved_collection, "If false - use files list.");
@@ -118,9 +127,11 @@ public class ComboMatch {
		gd.addNumericField("GPU image height",             gpu_height,  0,4,"",
				"GPU image height");
		gd.addCheckbox    ("Show transformation centers", show_centers, "Mark verticals from the UAS on the ground.");
		gd.addCheckbox    ("Process altitude images", use_alt, "Load and process altitude maps.");
		gd.addCheckbox    ("Show combo image map",      show_combo_map, "Load and process altitude maps.");
		gd.addCheckbox    ("Show altitude combo image", use_alt, "Load and process altitude maps.");
		gd.addStringField ("First matching timestamp",  gpu_spair[0], 20, "First GPU-matching timestamp with '_' for decimal point.");
		gd.addStringField ("Second matching timestamp", gpu_spair[1], 20, "First GPU-matching timestamp with '_' for decimal point.");
		gd.addNumericField("Remove fraction of worst matches",   frac_remove,  3,7,"",	"When fitting scenes remove this fraction of worst match.");

		gd.showDialog();
		if (gd.wasCanceled()) return false;
@@ -146,10 +157,12 @@ public class ComboMatch {
		OrthoMap.setGPUWidthHeight(gpu_width,gpu_height);
		
		show_centers =              gd.getNextBoolean();
		show_combo_map =            gd.getNextBoolean();
		use_alt =                   gd.getNextBoolean();

		gpu_spair[0] =              gd.getNextString();
		gpu_spair[1] =              gd.getNextString();
		frac_remove =               gd.getNextNumber();
		
		OrthoMapsCollection maps_collection=null;
		if (use_saved_collection) {
@@ -160,7 +173,7 @@ public class ComboMatch {
				e.printStackTrace();
			}
		} else {
			maps_collection = new OrthoMapsCollection(files_list_path); // should have ".list" extensiohn
			maps_collection = new OrthoMapsCollection(files_list_path); // should have ".list" extension
		}
		String [] names = maps_collection.getNames();
		
@@ -172,13 +185,16 @@ public class ComboMatch {
        // which pair to compare
//		String [] gpu_spair = {names[gpu_ipair[0]],names[gpu_ipair[1]]}; 
		int [] origin = new int[2];
		ImagePlus imp_img = 	maps_collection.renderMulti (
		ImagePlus imp_img = null;
		if (show_combo_map) {
			imp_img = 	maps_collection.renderMulti (
					"multi_"+zoom_lev, // String      title,
					false,             // boolean     use_alt,
					show_centers,      // boolean     show_centers,
					zoom_lev,          // int         zoom_level,
					origin);           // int []      origin){
			imp_img.show();
		}
		ImagePlus imp_alt = null;
		if (use_alt) {
			imp_alt =maps_collection.renderMulti (
@@ -234,15 +250,28 @@ public class ComboMatch {
//        	affine1[0][2] =-1.08;  affine1[1][2] =  3.267;  //{"1697877465_672024", "1697877528_776377"};        	
//        	affine1[0][2] =-1.2;   affine1[1][2] = -0.9066; //{"1694564245_111645", "1694564701_230240"};
//        	affine1[0][2] = 0.933; affine1[1][2] = -2.2667; //{"1694564245_111645", "1694564822_637346"};
        	affine1[0][2] = 2.08;  affine1[1][2] = -0.093;  //{"1694564248_145989", "1694564819_336247"};
//        	affine1[0][2] = 2.08;  affine1[1][2] = -0.093;  //{"1694564248_145989", "1694564819_336247"};
//        	affine1[0][2] =-1.88;  affine1[1][2] = -2.71;   //{"1694564269_536448", "1694564822_637346"};
//        	affine1[0][2] =-2.7;   affine1[1][2] = -0.59;   //{"1694564269_536448", "1694565541_040640"}; 50m-100m
//        	affine1[0][2] =-0.78;  affine1[1][2] =  2.1;    //{"1694564822_637346", "1694565541_040640"}; 75m-100m #75-#95
//        	affine1[0][2] =-0.92;  affine1[1][2] =  2.28;   //{"1694564263_701171", "1694564816_468625"}; 50m-75m
//        	affine1[0][2] =-5.37;  affine1[1][2] = -1.53;   //{"1694564266_568793", "1694564819_336247"}; 50m-75m
//        	affine1[0][2] = 1.92;  affine1[1][2] = -1.89;   //{"1694564270_086631", "1694564822_637346"}; 50m-75m
//        	affine1[0][2] = 0.52;  affine1[1][2] = -2.387;  //{"1694564272_770858", "1694564778_589341"}; 50m-75m #13-#63
//        	affine1[0][2] =-4.75;  affine1[1][2] = 0.44;    //{"1694564275_538447", "1694564744_411290"}; 50m-75m #14-#58
        	affine1[0][2] = 2.59;  affine1[1][2] = 0.133;   //{"1694564270_086631", "1694563011_045597"}; 50m, 25m #88-#68
//		String [] gpu_spair = {"1694564270_086631", "1694563011_045597"};  // Morning Sep, 13 50m, 25m #88-#68
        	
// "1694564275_538447","1694564744_411290"       	
        	double [][][] affines = {affine0,affine1};
    		int [] gpu_pair = new int[gpu_spair.length];
    		for (int i = 0; i < gpu_pair.length; i++) {
    			gpu_pair[i] = maps_collection.getIndex(gpu_spair[i]);
    		}
    		int [] zooms = {-3,-1,1000,1000};
    		int [] zooms = {-2,0,1000,1000};
    		debugLevel = 0;
			boolean  batch_mode = true;
			boolean  batch_mode = false; //  true;
			boolean ignore_prev_rms = true;
    		for (int zi = 0; zi < zooms.length; zi++) {
    			zoom_lev = zooms[zi];
    			if (zoom_lev >=1000) {
@@ -251,12 +280,16 @@ public class ComboMatch {
    			// will modify affines[1], later add jtj, weight, smth. else?
    			double [][] corr_pair_rslt = maps_collection.correlateOrthoPair(
    					clt_parameters, // CLTParameters    clt_parameters,
    					frac_remove,    // double           frac_remove, //  =        0.25
    					ignore_prev_rms, // boolean ignore_prev_rms,
    					batch_mode,     // boolean          batch_mode,
    					gpu_pair,      // String []        gpu_spair,
    					affines,        // double [][][]    affines, // on top of GPS offsets
    					zoom_lev,       // int              zoom_lev,
    					debugLevel);    // final int        debugLevel)
    			int render_zoom_lev = maps_collection.ortho_maps[gpu_pair[0]].getOriginalZoomLevel();
    			int render_zoom_lev = Math.min(
    					maps_collection.ortho_maps[gpu_pair[0]].getOriginalZoomLevel(),
    					maps_collection.ortho_maps[gpu_pair[1]].getOriginalZoomLevel());
    			ImagePlus imp_img_pair = 	maps_collection.renderMulti (
    					"multi_"+gpu_spair[0]+"-"+gpu_spair[1]+"-zoom_"+render_zoom_lev+"_"+zoom_lev, // String      title,
    					false,             // boolean     use_alt,
@@ -302,6 +335,38 @@ adjusted affines[1] for a pair: 1694564245_111645/1694564822_637346
[[1.0148318094351692,0.01611699521114023,1.1534804399270817],
 [-0.025584298199020607,1.0182605131307008,-2.157143969635918]]
 
 correlateOrthoPair(): adjusted affines[1] {"1694564269_536448", "1694564822_637346"}
[[1.0118405178770247,0.0243306610630595,-1.6570450812227402],
 [-0.030053577777794035,1.007846539173136,-2.564940874119216]]
 
adjusted affines[1] for a pair: 1694564269_536448/1694565541_040640
[[1.032352933444291,0.012425600945003055,-2.6012366590312457],
 [-0.032390806278202705,1.045595625691147,0.4724083642132655]]

 Done
adjusted affines[1] for a pair: 1694564263_701171/1694564816_468625 (9- 73)
[[1.015002848762524,0.016906877812481423,-0.827920765016369],
 [-0.016806089590596436,1.0126951556271355,2.453634727273915]]

adjusted affines[1] for a pair: 1694564266_568793/1694564819_336247
[[1.0208243680493612,-0.007571648582186553,-5.627387091202717],
 [0.00716961393885021,1.0116421129852677,-1.4359711787904814]]
 
 adjusted affines[1] for a pair: 1694564270_086631/1694564822_637346
[[1.01553064725059,-0.004358499034078345,1.9313585652985712],
 [0.006088341815143438,1.0077680445468122,-1.7817699129643216]]

adjusted affines[1] for a pair: 1694564272_770858/1694564778_589341
[[1.0120132362035976,0.03369140870847741,0.7958782949644478],
 [-0.03200874269606805,1.0088673434818738,-2.211451677912688]]
 
Bad, even with narrow WOI:
Done
adjusted affines[1] for a pair: 1694564275_538447/1694564744_411290
[[1.016644878296508,0.004929435606711805,-4.693221236458512],
 [-0.0049692732545438024,1.0068633692157516,0.3968458715663825]]

 
         * 
         * 
        double []        offset_xy_second = {0,0};
@@ -623,7 +688,7 @@ adjusted affines[1] for a pair: 1694564245_111645/1694564822_637346
					debugLevel);     // final int           debug_level
		}
		double [][][] vector_field = new double [corr_tiles_pd.length][][];
		vector_field[0] = TDCorrTile.getMismatchVector(
		vector_field[0] = TDCorrTile.getMismatchVector( // full tiles in gpu (512*512)
				corr_tiles_pd[0], // final double[][] tiles,
				rln_sngl_rstr,    // double              rmax, 
				rln_cent_radius,  // final double        centroid_radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
+11 −4
Original line number Diff line number Diff line
package com.elphel.imagej.orthomosaic;

import java.awt.Rectangle;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;

import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.tileprocessor.ImageDtt;

public class FloatImageData {
	public int       width;
	public int       height;
@@ -66,12 +73,12 @@ public class FloatImageData {
				ze = 2.0 * pix_size_in_cm;
			}
		} else { // high resolution, pixel size < 1 
			zl--;
//			zl--;
			while (pix_size_in_cm <= (1.0-e)) {
				zl++;		
				pix_size_in_cm *= 2;
			}// exits with (2-2*e) >= pix_in_cm > (1-e)
			vz = pix_size_in_cm > (2.0 - e);
			vz = pix_size_in_cm < (1.0 + e);
			if (!vz) {
				ze = pix_size_in_cm;
			}
@@ -82,9 +89,9 @@ public class FloatImageData {
		if (zoom_in_extra != null) {
			zoom_in_extra[0] = ze;
		}


		return zl;
	}
	
	// processing altitudes to remove non-flat surfaces from fitting ortho maps
	
}
+575 −0

File changed.

Preview size limit exceeded, changes collapsed.

+92 −46
Original line number Diff line number Diff line
@@ -267,37 +267,6 @@ public class OrthoMapsCollection implements Serializable{
				show_centers, // boolean       show_centers,
				zoom_level, // int           zoom_level,
				origin); // int []        origin)
		/*
		int []     wh = new int[2];
		double [][] centers = new double [ortho_maps.length][];
		float [][] multi = renderMulti (
				use_alt,    // boolean     use_alt,
				zoom_level, // int         zoom_level,
				wh,         // int []      wh,
				origin,    // int []      origin){ // maps[0] as a reference
				centers); // double [][] centers)
		String [] map_names = new String[ortho_maps.length];
		for (int n = 0; n < ortho_maps.length; n++) { 
			map_names[n] = ortho_maps[n].getName()+"_"+ortho_maps[n].getLocalDateTime().toString().replace("T","_")+"_UTC";
		}
		
        ImageStack stack = ShowDoubleFloatArrays.makeStack( 
        		multi,
        		wh[0],
        		wh[1],
        		map_names,
        		false);
        ImagePlus imp = new ImagePlus(title, stack);
        if (show_centers) {
        	PointRoi roi = new PointRoi();
        	for (int i = 0; i < centers.length; i++) {
        		roi.addPoint(centers[i][0],centers[i][1], i+1);
        	}
        	roi.setOptions("label");
        	imp.setRoi(roi);
        }
        return imp;
        */
	}
	
	public ImagePlus renderMulti (
@@ -576,6 +545,8 @@ public class OrthoMapsCollection implements Serializable{
	
	public double [][] correlateOrthoPair(
			CLTParameters    clt_parameters,
			double           frac_remove, //  =        0.25
			boolean          ignore_prev_rms,
			boolean          batch_mode,
			String []        gpu_spair,
			double [][][]    affines, // here in meters, relative to vertical points
@@ -587,6 +558,8 @@ public class OrthoMapsCollection implements Serializable{
		}
		return correlateOrthoPair(
				clt_parameters,  // CLTParameters    clt_parameters,
				frac_remove,     // double           frac_remove, //  =        0.25
				ignore_prev_rms, // boolean          ignore_prev_rms,
				batch_mode,      // boolean          batch_mode,
				gpu_pair,        // int []           gpu_pair,
				affines,         // double [][][]    affines, // here in meters, relative to vertical points
@@ -596,6 +569,8 @@ public class OrthoMapsCollection implements Serializable{
	
	double [][] correlateOrthoPair(
			CLTParameters    clt_parameters,
			double           frac_remove, //  =        0.25
			boolean          ignore_prev_rms,
			boolean          batch_mode,
			int []           gpu_pair,
			double [][][]    affines,  // here in meters, relative to vertical points
@@ -609,6 +584,7 @@ public class OrthoMapsCollection implements Serializable{
			show_gpu_img =      false; // (debugLevel > 1);
			show_tile_centers = false; // true; // (debugLevel > 1);
		}
    	boolean show_vector_field = !batch_mode && (debugLevel>0); // true;
		double [][] bounds_overlap_meters = getOverlapMeters(
				gpu_pair[0],  // int ref_index,
				gpu_pair[1],  // int other_index)
@@ -626,7 +602,6 @@ public class OrthoMapsCollection implements Serializable{
	    for (int i = 0; i < 2; i++) {
	    	overlap_wh_pixel[i] = ((int) Math.ceil(bounds_overlap_meters[i][1]/pix_size)) - ((int) Math.floor(bounds_overlap_meters[i][0]/pix_size));
	    }
//		double [][] bounds_overlap_pixels = new double[2][2];
		// convert to pixels,shift top-left to [0,0] (remember offsets, limit w,h,
		// change to pixels last, remember TL in meters?
		// keep center where it was
@@ -646,8 +621,7 @@ public class OrthoMapsCollection implements Serializable{
			for (int i = 0; i < 2; i++) { // subtracting tl_rect_metric[n] (-1)
				tlo_src_metric[n][i] =
						tlo_rect_metric[n][0] * affines[n][i][0] +
						tlo_rect_metric[n][1] * affines[n][i][1] + affines[n][i][2]; //  -
//						tl_rect_metric[n][i];
						tlo_rect_metric[n][1] * affines[n][i][1] + affines[n][i][2];
			}
		}
		/// referenced to top-left pixel of the gpu image
@@ -699,11 +673,20 @@ public class OrthoMapsCollection implements Serializable{
    	int tilesY =  gpu_height/GPUTileProcessor.DTT_SIZE;
		
		// uses fixed_size gpu image size
//		TDCorrTile [] td_corr_tiles =
		TpTask [][] tp_tasks = new TpTask [2][];
		
		int num_tries = 5;
		double prev_rms = Double.NaN;
		double rel_improve = 1E-3;
		double [][] elevations = new double [tp_tasks.length][];
		double [][] ground_planes_metric = new double [tp_tasks.length][];
		boolean [][] ground_planes_masks = new boolean[2][];
		double    initial_above = 3; // m
		double    initial_below = 3; // m
		int       num_refine =    3;
		double    frac_above =    0.3;
		double    frac_below =    0.1;
		double     metric_error = 0.01;//  1 cm
		for (int ntry = 0; ntry < num_tries; ntry++) {
			if (!batch_mode) {
				if (debugLevel>-3) {
@@ -720,13 +703,53 @@ public class OrthoMapsCollection implements Serializable{
							tp_tasks, // TpTask [][]                  tp_tasks_o,
							batch_mode,          // final boolean                batch_mode,
							debugLevel);    // final int                    debugLevel);
			// get elevations
			int zoom_lev_tiles = zoom_lev-3;
			double [] ground_planes_weight = null;
			for (int num_elevations = 0; num_elevations < 1; num_elevations++) {
				for (int n = 0; n < gpu_pair.length; n++) {
					elevations[n] = ortho_maps[gpu_pair[n]]. getTileElevations(
							zoom_lev, // final int zoom_level,
							tp_tasks[n], // final TpTask [] tp_tasks, 
							tilesX, // final int tilesX,
							tilesY, // final int tilesY,
							debugLevel); // final int debugLevel)
					String debug_title = show_vector_field? (ortho_maps[gpu_pair[n]].getName()+"_plane"):null;
					ground_planes_metric[n] = ortho_maps[gpu_pair[n]].getPlaneMeters (
							zoom_lev_tiles, // int       zoom_lev, // of the data (3 levels down for tiles)
							elevations[n],  // double [] elev,
							tilesX,         // int       width,
							initial_above,  // double    initial_above, // from average
							initial_below,  // double    initial_below, // from average, // positive value
							num_refine,     // int       num_refine,
							frac_above,     // double    frac_above,
							frac_below,     // double    frac_below,
							debug_title);   // String    debug_title)
					ground_planes_masks[n] = ortho_maps[gpu_pair[n]].removeHighElevationMismatch (
							zoom_lev_tiles,          // int        zoom_lev, // of the data (3 levels down for tiles)
							elevations[n],           // double []  elev,
							tilesX, // int        width,
							ground_planes_metric[n], // double []  plane_metric, // tiltx,tilty, offs - in meters
							metric_error);           // double     metric_error);
				}
				ground_planes_weight = new double[ ground_planes_masks[0].length];
				int num_left = 0; // , num_was = tp_tasks[0].length;
				for (int i = 0; i < ground_planes_weight.length; i++) {
					if (ground_planes_masks[0][i] && ground_planes_masks[1][i]) {
						num_left++;
						ground_planes_weight[i] = 1.0;
					}
				}
				System.out.println("correlateOrthoPair(): left "+num_left+" tiles (was "+tp_tasks[0].length+" before filtering)");
				System.out.println();
			}

			
	    	boolean show_vector_field = !batch_mode && (debugLevel>0); // true;
	    	Rectangle tile_woi = scaleRectangle (woi, GPUTileProcessor.DTT_SIZE);
	    	double max_err=              5.0;
	    	int num_bins =            1000;
	    	boolean ignore_strength = false;
	    	double  frac_remove =        0.25;
	    	//double  frac_remove =        0.15;
	    	double [][] vf_error2 = new double [vector_field.length][]; // may be able to skip [0]
	    	double [][][] vector_field_bkp = show_vector_field? new double[vector_field.length][][]:null;
	    	if (vector_field_bkp != null) {
@@ -759,7 +782,7 @@ public class OrthoMapsCollection implements Serializable{
				int dbg_width =  tile_woi.x+tile_woi.width;
				int dbg_height = tile_woi.y+tile_woi.height;
				double [][][][] vf_all = {vector_field_bkp,vector_field};
				double [][] dbg_vf = new double [8 * vector_field.length][dbg_width * dbg_height];
				double [][] dbg_vf = new double [8 * vector_field.length+5][dbg_width * dbg_height];
				String [] dbg_titles = new String[dbg_vf.length];
				String [] prefix= {"single","single_filtered","neibs","neibs_filtered"};
				for (int n = 0; n < 2*vector_field.length; n++) {
@@ -768,6 +791,12 @@ public class OrthoMapsCollection implements Serializable{
					dbg_titles [4*n+2] = prefix[n]+"-str";	
					dbg_titles [4*n+3] = prefix[n]+"-err";	
				}
				dbg_titles [8 * vector_field.length + 0] = "mask-elev";
				dbg_titles [8 * vector_field.length + 1] = "elev-0";
				dbg_titles [8 * vector_field.length + 2] = "elev-1";
				dbg_titles [8 * vector_field.length + 3] = "mask-0";
				dbg_titles [8 * vector_field.length + 4] = "mask-1";
						
				for (int i = 0; i < dbg_vf.length; i++) {
					Arrays.fill(dbg_vf[i], Double.NaN);
					
@@ -787,6 +816,11 @@ public class OrthoMapsCollection implements Serializable{
							}
						}
					}
					dbg_vf [8 * vector_field.length + 0][l] = ground_planes_weight[t];
					dbg_vf [8 * vector_field.length + 1][l] = elevations[0][t];
					dbg_vf [8 * vector_field.length + 2][l] = elevations[1][t];
					dbg_vf [8 * vector_field.length + 3][l] = ground_planes_masks[0][t]?1.0:0.0;
					dbg_vf [8 * vector_field.length + 4][l] = ground_planes_masks[1][t]?1.0:0.0;
				}
	    		ShowDoubleFloatArrays.showArrays(
	    				dbg_vf,
@@ -881,16 +915,28 @@ public class OrthoMapsCollection implements Serializable{
						System.out.println("LMA RMSE worsened: new"+rms+" ("+ orthoPairLMA.getInitialRms()+"), prev="+prev_rms);
					}
				}
				if (ignore_prev_rms) {
					if (debugLevel > -3) {
						System.out.println("Will continue, as ignore_prev_rms is set");
					}					
				} else {
					break;
				}
			}
			affines_gpu[1]=OrthoMap.combineAffine(affines_gpu[1], orthoPairLMA.getAffine());
			double [][] jtj = orthoPairLMA.getLastJtJ();
			if ((prev_rms - rms)/prev_rms < rel_improve) {
				if (debugLevel > -2) {
					System.out.println("LMA relative RMSE improvement = "+((prev_rms - rms)/prev_rms)+" < "+rel_improve+", exiting.");
				}
				if (ignore_prev_rms) {
					if (debugLevel > -3) {
						System.out.println("Will continue, as ignore_prev_rms is set");
					}					
				} else {
					break;
				}
			}
			prev_rms=rms;
		} // for (int ntry = 0; ntry < num_tries; ntry++) {
		// unrapping backwards, for "other" map only, reference is not modified.
Loading