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 Original line 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}
					double [][] cxy = new double [2][2]; // image number, {x,y}
					int [][] icxy = new int [2][2];
					int [][] icxy = new int [2][2];
					for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
					for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
						int tileY = nTile / tiles_woi.width + tiles_woi.x;
						int tileY = nTile / tiles_woi.width + tiles_woi.y;
						int tileX = nTile % tiles_woi.width + tiles_woi.y;
						int tileX = nTile % tiles_woi.width + tiles_woi.x;
						double [] cxy0 = {
						double [] cxy0 = {
								(tileX + 0.5) * GPUTileProcessor.DTT_SIZE,
								(tileX + 0.5) * GPUTileProcessor.DTT_SIZE,
								(tileY + 0.5) * GPUTileProcessor.DTT_SIZE};
								(tileY + 0.5) * GPUTileProcessor.DTT_SIZE};
+101 −36
Original line number Original line 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 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 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 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 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.data";
		String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m.data";
//maps_19_sep13.list		
//maps_19_sep13.list		
		//maps_09_short.list
		//maps_09_short.list
//maps_08_november.list		
//maps_08_november.list		
@@ -76,21 +76,30 @@ public class ComboMatch {
//		String [] gpu_spair = {"1697877465_672024", "1697877528_776377"};
//		String [] gpu_spair = {"1697877465_672024", "1697877528_776377"};
//		String [] gpu_spair = {"1694564245_111645", "1694564701_230240"}; // Morning Sep, 13
//		String [] gpu_spair = {"1694564245_111645", "1694564701_230240"}; // Morning Sep, 13
//		String [] gpu_spair = {"1694564245_111645", "1694564822_637346"}; // 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}}};
		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_width=  clt_parameters.imp.rln_gpu_width; // 3008;
		int gpu_height= clt_parameters.imp.rln_gpu_height; // 3008;
		int gpu_height= clt_parameters.imp.rln_gpu_height; // 3008;
		int zoom_lev = -3; // 0; // +1 - zoom in twice, -1 - zoom out twice
		int zoom_lev = -3; // 0; // +1 - zoom in twice, -1 - zoom out twice
		boolean show_combo_map = false; // true;
		boolean use_alt = false;
		boolean use_alt = false;
		boolean show_centers = true;
		boolean show_centers = true;
		boolean use_saved_collection = true; // false;
		boolean use_saved_collection = true; // false;
		boolean save_collection = true;
		boolean save_collection = true;
		boolean process_correlation = true; // use false to save new version of data
		boolean process_correlation = true; // use false to save new version of data
		boolean restore_temp        = true;
		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 ("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.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.");
		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,"",
		gd.addNumericField("GPU image height",             gpu_height,  0,4,"",
				"GPU image height");
				"GPU image height");
		gd.addCheckbox    ("Show transformation centers", show_centers, "Mark verticals from the UAS on the ground.");
		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 ("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.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();
		gd.showDialog();
		if (gd.wasCanceled()) return false;
		if (gd.wasCanceled()) return false;
@@ -146,10 +157,12 @@ public class ComboMatch {
		OrthoMap.setGPUWidthHeight(gpu_width,gpu_height);
		OrthoMap.setGPUWidthHeight(gpu_width,gpu_height);
		
		
		show_centers =              gd.getNextBoolean();
		show_centers =              gd.getNextBoolean();
		show_combo_map =            gd.getNextBoolean();
		use_alt =                   gd.getNextBoolean();
		use_alt =                   gd.getNextBoolean();


		gpu_spair[0] =              gd.getNextString();
		gpu_spair[0] =              gd.getNextString();
		gpu_spair[1] =              gd.getNextString();
		gpu_spair[1] =              gd.getNextString();
		frac_remove =               gd.getNextNumber();
		
		
		OrthoMapsCollection maps_collection=null;
		OrthoMapsCollection maps_collection=null;
		if (use_saved_collection) {
		if (use_saved_collection) {
@@ -160,7 +173,7 @@ public class ComboMatch {
				e.printStackTrace();
				e.printStackTrace();
			}
			}
		} else {
		} 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();
		String [] names = maps_collection.getNames();
		
		
@@ -172,13 +185,16 @@ public class ComboMatch {
        // which pair to compare
        // which pair to compare
//		String [] gpu_spair = {names[gpu_ipair[0]],names[gpu_ipair[1]]}; 
//		String [] gpu_spair = {names[gpu_ipair[0]],names[gpu_ipair[1]]}; 
		int [] origin = new int[2];
		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,
					"multi_"+zoom_lev, // String      title,
					false,             // boolean     use_alt,
					false,             // boolean     use_alt,
					show_centers,      // boolean     show_centers,
					show_centers,      // boolean     show_centers,
					zoom_lev,          // int         zoom_level,
					zoom_lev,          // int         zoom_level,
					origin);           // int []      origin){
					origin);           // int []      origin){
			imp_img.show();
			imp_img.show();
		}
		ImagePlus imp_alt = null;
		ImagePlus imp_alt = null;
		if (use_alt) {
		if (use_alt) {
			imp_alt =maps_collection.renderMulti (
			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.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] =-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] = 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};
        	double [][][] affines = {affine0,affine1};
    		int [] gpu_pair = new int[gpu_spair.length];
    		int [] gpu_pair = new int[gpu_spair.length];
    		for (int i = 0; i < gpu_pair.length; i++) {
    		for (int i = 0; i < gpu_pair.length; i++) {
    			gpu_pair[i] = maps_collection.getIndex(gpu_spair[i]);
    			gpu_pair[i] = maps_collection.getIndex(gpu_spair[i]);
    		}
    		}
    		int [] zooms = {-3,-1,1000,1000};
    		int [] zooms = {-2,0,1000,1000};
    		debugLevel = 0;
    		debugLevel = 0;
			boolean  batch_mode = true;
			boolean  batch_mode = false; //  true;
			boolean ignore_prev_rms = true;
    		for (int zi = 0; zi < zooms.length; zi++) {
    		for (int zi = 0; zi < zooms.length; zi++) {
    			zoom_lev = zooms[zi];
    			zoom_lev = zooms[zi];
    			if (zoom_lev >=1000) {
    			if (zoom_lev >=1000) {
@@ -251,12 +280,16 @@ public class ComboMatch {
    			// will modify affines[1], later add jtj, weight, smth. else?
    			// will modify affines[1], later add jtj, weight, smth. else?
    			double [][] corr_pair_rslt = maps_collection.correlateOrthoPair(
    			double [][] corr_pair_rslt = maps_collection.correlateOrthoPair(
    					clt_parameters, // CLTParameters    clt_parameters,
    					clt_parameters, // CLTParameters    clt_parameters,
    					frac_remove,    // double           frac_remove, //  =        0.25
    					ignore_prev_rms, // boolean ignore_prev_rms,
    					batch_mode,     // boolean          batch_mode,
    					batch_mode,     // boolean          batch_mode,
    					gpu_pair,      // String []        gpu_spair,
    					gpu_pair,      // String []        gpu_spair,
    					affines,        // double [][][]    affines, // on top of GPS offsets
    					affines,        // double [][][]    affines, // on top of GPS offsets
    					zoom_lev,       // int              zoom_lev,
    					zoom_lev,       // int              zoom_lev,
    					debugLevel);    // final int        debugLevel)
    					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 (
    			ImagePlus imp_img_pair = 	maps_collection.renderMulti (
    					"multi_"+gpu_spair[0]+"-"+gpu_spair[1]+"-zoom_"+render_zoom_lev+"_"+zoom_lev, // String      title,
    					"multi_"+gpu_spair[0]+"-"+gpu_spair[1]+"-zoom_"+render_zoom_lev+"_"+zoom_lev, // String      title,
    					false,             // boolean     use_alt,
    					false,             // boolean     use_alt,
@@ -302,6 +335,38 @@ adjusted affines[1] for a pair: 1694564245_111645/1694564822_637346
[[1.0148318094351692,0.01611699521114023,1.1534804399270817],
[[1.0148318094351692,0.01611699521114023,1.1534804399270817],
 [-0.025584298199020607,1.0182605131307008,-2.157143969635918]]
 [-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};
        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
					debugLevel);     // final int           debug_level
		}
		}
		double [][][] vector_field = new double [corr_tiles_pd.length][][];
		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,
				corr_tiles_pd[0], // final double[][] tiles,
				rln_sngl_rstr,    // double              rmax, 
				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)
				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 Original line Diff line number Diff line
package com.elphel.imagej.orthomosaic;
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 class FloatImageData {
	public int       width;
	public int       width;
	public int       height;
	public int       height;
@@ -66,12 +73,12 @@ public class FloatImageData {
				ze = 2.0 * pix_size_in_cm;
				ze = 2.0 * pix_size_in_cm;
			}
			}
		} else { // high resolution, pixel size < 1 
		} else { // high resolution, pixel size < 1 
			zl--;
//			zl--;
			while (pix_size_in_cm <= (1.0-e)) {
			while (pix_size_in_cm <= (1.0-e)) {
				zl++;		
				zl++;		
				pix_size_in_cm *= 2;
				pix_size_in_cm *= 2;
			}// exits with (2-2*e) >= pix_in_cm > (1-e)
			}// 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) {
			if (!vz) {
				ze = pix_size_in_cm;
				ze = pix_size_in_cm;
			}
			}
@@ -82,9 +89,9 @@ public class FloatImageData {
		if (zoom_in_extra != null) {
		if (zoom_in_extra != null) {
			zoom_in_extra[0] = ze;
			zoom_in_extra[0] = ze;
		}
		}


		return zl;
		return zl;
	}
	}
	
	
	// processing altitudes to remove non-flat surfaces from fitting ortho maps
	
}
}
Loading