Commit c325ea24 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Generating combined results table

parent c8e09488
Loading
Loading
Loading
Loading
+54 −1
Original line number Original line Diff line number Diff line
@@ -170,6 +170,9 @@ public class ComboMatch {
		double  metric_error =        0.05; // 0.02;//  2 cm
		double  metric_error =        0.05; // 0.02;//  2 cm
		boolean update_lla =          false; // re-read file metadata
		boolean update_lla =          false; // re-read file metadata
		boolean update_kernel_patterns = false;
		boolean update_kernel_patterns = false;
		boolean update_bl_bc =        false;
		String [] suffixes_bl_bc=     {"","-BL","-BC"};
		int  suffix_bc_bl_indx =   2;
		if (!use_marked_image) {
		if (!use_marked_image) {
			process_correlation=false; // use already adjusted by default
			process_correlation=false; // use already adjusted by default
		}
		}
@@ -225,6 +228,15 @@ public class ComboMatch {
		}
		}
		gd.addCheckbox    ("Update files metadata",     update_lla, "Re-read files metadata (if it was modified)");
		gd.addCheckbox    ("Update files metadata",     update_lla, "Re-read files metadata (if it was modified)");
		gd.addCheckbox    ("Update kernels/patterns",   update_kernel_patterns, "Re-read kernels and patterns from *.list file");
		gd.addCheckbox    ("Update kernels/patterns",   update_kernel_patterns, "Re-read kernels and patterns from *.list file");
		gd.addCheckbox    ("Update BC/BL suffix",       update_bl_bc,
				"Change source filenames to use -BC for bicubic, -BL - for bilinear, or empty - for old bilinear files");
		gd.addChoice("BL/BC suffix:",        
				suffixes_bl_bc,
				suffixes_bl_bc[suffix_bc_bl_indx],
				"Select interpolation mode of the source files: old bilinear (empty), bilinear (-BL), or bicubic (-BC)", 0);

		
		
//		update_kernel_patterns
//		update_kernel_patterns
		gd.showDialog();
		gd.showDialog();
		if (gd.wasCanceled()) return false;
		if (gd.wasCanceled()) return false;
@@ -273,6 +285,8 @@ public class ComboMatch {
		}
		}
		update_lla=                 gd.getNextBoolean();
		update_lla=                 gd.getNextBoolean();
		update_kernel_patterns=     gd.getNextBoolean();
		update_kernel_patterns=     gd.getNextBoolean();
		update_bl_bc=               gd.getNextBoolean();
		suffix_bc_bl_indx =         gd.getNextChoiceIndex();
		OrthoMapsCollection maps_collection=null;
		OrthoMapsCollection maps_collection=null;
		if (use_saved_collection) {
		if (use_saved_collection) {
			try {
			try {
@@ -291,6 +305,16 @@ public class ComboMatch {
			maps_collection.updateNumberScenes();
			maps_collection.updateNumberScenes();
			maps_collection.updateSfmGain();
			maps_collection.updateSfmGain();
		}
		}
		if (update_bl_bc) {
			boolean OK = updateBlBcFileNames(
					suffixes_bl_bc[suffix_bc_bl_indx], // String suffix,
					"-FLAT",// String before,
					maps_collection); // OrthoMapsCollection maps_collection)
			if (!OK) {
				System.out.println("Failed to update filenames for different interpolation mode");
			}
		}
		
		String [] names = maps_collection.getNames(); // null
		String [] names = maps_collection.getNames(); // null
		if (object_list != null) {
		if (object_list != null) {
			int       corr_size =                128;
			int       corr_size =                128;
@@ -955,6 +979,35 @@ public class ComboMatch {
        return true;
        return true;
	}
	}
	
	
	public static boolean updateBlBcFileNames(
			String suffix,
			String before,
			OrthoMapsCollection maps_collection) {
		String [] filenames = new String [maps_collection.ortho_maps.length];
		for (int i = 0; i < filenames.length; i++) {
			filenames[i] = maps_collection.ortho_maps[i].getFileName(); // getName();
		}
		String [] old_names = filenames.clone();
		for (int i = 0; i < filenames.length; i++) {
			int insert_indx = filenames[i].indexOf(before);
			if (insert_indx < 0) {
				System.out.println("updateBlBcFileNames(): no substring '"+
						before+"' in filename "+filenames[i]);
				return false;
			}
			String stail =  filenames[i].substring(insert_indx);
			String prefix = filenames[i].substring(0, insert_indx);
			if (prefix.endsWith("-BL") || prefix.endsWith("-BC")) {
				prefix = prefix.substring(0, insert_indx - "-BC".length());
			}
			filenames[i] = prefix + suffix + stail;
		}
		for (int i = 0; i < filenames.length; i++) {
			maps_collection.ortho_maps[i].setFileName(filenames[i]);
		}		
		return true;
	}
	
	
	
		/*
		/*
    	double [][] affine1 = {
    	double [][] affine1 = {
+25 −0
Original line number Original line Diff line number Diff line
@@ -462,6 +462,31 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
	public String getName() {
	public String getName() {
		return name;
		return name;
	}
	}

	public String getPath() {
		return path;
	}
	
	public void setPath(String path) {
		this.path = path;
	}
	public String getFileName() {
		int p1 = path.lastIndexOf(Prefs.getFileSeparator()); 
		if (p1 < 0) {
			return null;
		}
		return path.substring(p1+1);
	}
	
	public boolean setFileName(String filename) {
		int p1 = path.lastIndexOf(Prefs.getFileSeparator());
		if (p1 < 0) {
			return false;
		}
		path= path.substring(0, p1+1) + filename;
		return true;
	}
	
	public void setAffine(double [][] affine) {
	public void setAffine(double [][] affine) {
		this.affine = affine;
		this.affine = affine;
	}
	}
+25 −4
Original line number Original line Diff line number Diff line
@@ -65,13 +65,14 @@ public class OrthoMapsParameters {
	public	boolean       corr_centered; // re-correlate first scene centered at candidates
	public	boolean       corr_centered; // re-correlate first scene centered at candidates
	public  int           debugLevel;
	public  int           debugLevel;
	public  String        save_top_dir;
	public  String        save_top_dir;
	public  String        sub_dir;
	public  String        sub_dir;       // also the bas of the name to save combined results
	public	boolean       show_images;
	public	boolean       show_images;
	public	boolean       show_final_image;
	public	boolean       show_final_image;
	public	boolean       save_images;
	public	boolean       save_images;
	public	boolean       show_results;
	public	boolean       show_results;
	public  boolean       append_log;
	public  boolean       append_log;
	public  String        alt_mode;
	public  String        alt_mode;
	public  boolean       results_multi; // save multiple scenes result in the same file
	
	
	public OrthoMapsParameters() {
	public OrthoMapsParameters() {
		setDefaults();
		setDefaults();
@@ -119,7 +120,7 @@ public class OrthoMapsParameters {
		convolve_after =      false; // true for old kernel tuning (kernel decimation before convolution)
		convolve_after =      false; // true for old kernel tuning (kernel decimation before convolution)
		corr_centered =       true; // re-correlate first scene centered at candidates
		corr_centered =       true; // re-correlate first scene centered at candidates
		save_top_dir =        "/media/elphel/NVME/lwir16-proc/ortho_videos/debug/sept12-13/pattern_match/";
		save_top_dir =        "/media/elphel/NVME/lwir16-proc/ortho_videos/debug/sept12-13/pattern_match/";
		sub_dir =             "dbg_recenter_07";
		sub_dir =             "bicubic_01";
		show_images =         false;
		show_images =         false;
		show_final_image =    true;
		show_final_image =    true;
		save_images =         true;
		save_images =         true;
@@ -129,6 +130,7 @@ public class OrthoMapsParameters {
		append_log =          true;
		append_log =          true;
		alt_mode=             "??m";		
		alt_mode=             "??m";		
		debugLevel =          0;
		debugLevel =          0;
		results_multi =       true;
	}
	}
	
	
	public void setDefaults50() {
	public void setDefaults50() {
@@ -163,7 +165,8 @@ public class OrthoMapsParameters {
		lpf_sigma =  new double [] {0.25, 0.25};
		lpf_sigma =  new double [] {0.25, 0.25};
		phaseCoeff = new double [] {0.95, 0.95};
		phaseCoeff = new double [] {0.95, 0.95};
		//				min_corrs[0] =      0.0119;
		//				min_corrs[0] =      0.0119;
		min_corrs =   new double[]{0.0090,0.008}; // A1: .0654
//		min_corrs =   new double[]{0.0090,0.008}; // A1: .0654
		min_corrs =   new double[]{0.0087,0.008}; // A1: .0654
		abs_edge_frac =     0.35;
		abs_edge_frac =     0.35;
		abs_oversize =      2.2;		
		abs_oversize =      2.2;		
		filt_abs_contrast = 75; // 70;
		filt_abs_contrast = 75; // 70;
@@ -173,7 +176,7 @@ public class OrthoMapsParameters {
		// parameters for force round
		// parameters for force round
		abs_force_round =   true;
		abs_force_round =   true;
		filt_roundness[0] = 0.56; // 0.55;
		filt_roundness[0] = 0.56; // 0.55;
		filt_best[0] =      0.009; //****** tune, this one is inactive
		filt_best[0] =      0.0087; // 0.009; //****** tune, this one is inactive
		filt_max_radius = new double [][] {{0.35,0.2},{0.35,0.2}}; // {1.0,1.0}}; // [second/main][full/half] - inactive now
		filt_max_radius = new double [][] {{0.35,0.2},{0.35,0.2}}; // {1.0,1.0}}; // [second/main][full/half] - inactive now
		filt_elongation = new double [][] {{1.45,1.55},{1.45,1.55}}; // [second/main][full/half] ellipse axis ratio
		filt_elongation = new double [][] {{1.45,1.55},{1.45,1.55}}; // [second/main][full/half] ellipse axis ratio
		filt_other_rad  = 25; // should be no disconnected high peaks in this radius (only for halves multiplied)
		filt_other_rad  = 25; // should be no disconnected high peaks in this radius (only for halves multiplied)
@@ -281,6 +284,7 @@ public class OrthoMapsParameters {
		gd.addCheckbox    ("Append results table",              append_table,"Append results table.");
		gd.addCheckbox    ("Append results table",              append_table,"Append results table.");
		gd.addCheckbox    ("Date/time when appending",          table_datetime, "Include date/time when appending results.");
		gd.addCheckbox    ("Date/time when appending",          table_datetime, "Include date/time when appending results.");
		gd.addCheckbox    ("Write to log",                      append_log, "Append log file.");
		gd.addCheckbox    ("Write to log",                      append_log, "Append log file.");
		gd.addCheckbox    ("Save multi-scene results",          results_multi, "Save multi-scene results to a single table.");
		//
		//
		gd.addNumericField("Debug level",                       debugLevel,  0,4,"", "Debug level.");
		gd.addNumericField("Debug level",                       debugLevel,  0,4,"", "Debug level.");
		gd.showDialog();
		gd.showDialog();
@@ -348,6 +352,7 @@ public class OrthoMapsParameters {
		append_table=          gd.getNextBoolean();
		append_table=          gd.getNextBoolean();
		table_datetime=        gd.getNextBoolean();
		table_datetime=        gd.getNextBoolean();
		append_log=            gd.getNextBoolean();
		append_log=            gd.getNextBoolean();
		results_multi =        gd.getNextBoolean();
		debugLevel=      (int) gd.getNextNumber();
		debugLevel=      (int) gd.getNextNumber();
		setSaveDir(
		setSaveDir(
				indices,     // int [] indices,
				indices,     // int [] indices,
@@ -380,6 +385,7 @@ public class OrthoMapsParameters {
		}
		}
	}
	}
	
	
	
	public void printReport(
	public void printReport(
			boolean               gen_results,
			boolean               gen_results,
			boolean               gen_parameters,
			boolean               gen_parameters,
@@ -784,6 +790,21 @@ public class OrthoMapsParameters {
			sb.append("\n");
			sb.append("\n");
			sb.append(sb_body_params);
			sb.append(sb_body_params);
		}
		}
		if (save && results_multi) { // no date stamp
			String multi_path = save_top_dir;
			if (!multi_path.endsWith(Prefs.getFileSeparator())) {
				multi_path+= Prefs.getFileSeparator();
			}
			multi_path += sub_dir+RESULTS_SUFFIX; 
			CalibrationFileManagement.saveStringToFile (
					multi_path,          //String path,
					sb.toString(), // data,
					append_table); // boolean append)
			if (debugLevel > -4) {
				System.out.println ("Results appended to "+multi_path);
			}
		}
		
		if (save_images && save && (gen_results || gen_parameters)) {
		if (save_images && save && (gen_results || gen_parameters)) {
			StringBuffer sb1 =    new StringBuffer();
			StringBuffer sb1 =    new StringBuffer();
			if (table_datetime && append_table) {
			if (table_datetime && append_table) {