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

preparing for adding pairwise matching after single-connected are

subject to LMA
parent 099bf912
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -850,6 +850,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
			addButton("Warp pair",  panelLWIRWorld, color_process);
			addButton("Read Tiff",  panelLWIRWorld, color_process);
			addButton("Test video",  panelLWIRWorld, color_process);
			addButton("Ortho",         panelLWIRWorld, color_process);
			addButton("Ortho Pairs",  panelLWIRWorld, color_process);
			addButton("Manual pair",  panelLWIRWorld, color_process);
			addButton("Extract Objects",  panelLWIRWorld, color_process);
@@ -5718,7 +5719,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
				e.printStackTrace();
			}
//			ComboMatch.testReadTiff();
		} else if (label.equals("Ortho Pairs") || label.equals("Extract Objects") || label.equals("Manual pair")) {
		} else if (label.equals("Ortho") || label.equals("Ortho Pairs") || label.equals("Extract Objects") || label.equals("Manual pair")) {
			DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
			EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
			if (GPU_TILE_PROCESSOR == null) {
@@ -5739,6 +5740,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
			ComboMatch.openTestPairGps(
					CLT_PARAMETERS,     // CLTParameters    clt_parameters,
					GPU_TILE_PROCESSOR,
					label.equals("Ortho"),// 			 boolean          dflt_options,
					label.equals("Extract Objects"), // boolean    extract_mines,
					label.equals("Manual pair"), // boolean          manual_pair,
					DEBUG_LEVEL);
+118 −13
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class ComboMatch {
	public static int gpu_max_width=  4096;
	public static int gpu_max_height= 4096;
	public static String [] FILES_LISTS_PATHS = {
			"/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/nov3_50-75",
			"/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_sep12-13_50-25-50-75-100m",
			"/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_19_sep13_25-50-75-100m",
			"/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_nov3_50-75",
@@ -60,6 +61,7 @@ public class ComboMatch {
	public static boolean openTestPairGps(
			 CLTParameters    clt_parameters,
			 GPUTileProcessor gpu_tile_processor, // initialized by the caller
			 boolean          dflt_options,
			 boolean          extract_objects,
			 boolean          manual_pair,
			 int              debugLevel) {
@@ -103,7 +105,7 @@ public class ComboMatch {
			}
		}
// find -L /media/elphel/SSD3-4GB/lwir16-proc/berdich3/linked/linked_1697875868-1697879449-b/ -type f -name "*-GCORR-GEO.tiff" | sort  > GCORR-GEO.list

// find -L . -path "*-BC-FLAT_CLN-VERT-GCORR-GEO.tiff" -newermt "2024-06-01" -print > GCORR-GEO.list
//		String files_list_path =          "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/maps_03_short.list";
//		String orthoMapsCollection_path = "/media/elphel/SSD3-4GB/lwir16-proc/ortho_videos/ortho_maps_collection.data";

@@ -155,7 +157,7 @@ public class ComboMatch {
			gpu_spair = new String[]{"1694564291_293695","1694564778_589341"};  // Morning Sep, 13 50m, 75m #97, #139
		}
		*/		
		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_height= clt_parameters.imp.rln_gpu_height; // 3008;
		int zoom_lev = -3; // 0; // +1 - zoom in twice, -1 - zoom out twice
@@ -173,7 +175,7 @@ public class ComboMatch {
		boolean update_match =        true; // use false to save new version of data
		boolean render_match =        false; // true;
		boolean test_multi_lma =      false;
		boolean pattern_match =       true; // false;
		boolean pattern_match =       !dflt_options; //true; // false;
		
		boolean bounds_to_indices =   true;
		int     temp_mode =           0;
@@ -200,7 +202,7 @@ public class ComboMatch {
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,800);
//		gd.addChoice      ("Files list/data path (w/o extension):", FILES_LISTS_PATHS, FILES_LISTS_PATHS[default_list_choice]);
		gd.addChoice      ("Files list/data path (w/o extension):", FILES_LISTS_PATHS, omtch_img_set);
		gd.addCheckbox    ("Use saved maps collection", use_saved_collection, "If false - use files list.");
		gd.addCheckbox    ("Use saved maps collection ", use_saved_collection, " (if available). If false - use files list.");
		gd.addCheckbox    ("Save maps collection", save_collection, "Save maps collection to be able to restore.");
		gd.addCheckbox    ("Process correlations", process_correlation, "false to skip to just regenerate new save file.");
//		int num_tries_fit =           10;
@@ -318,23 +320,32 @@ public class ComboMatch {
		log_append =                gd.getNextBoolean();
		log_path =                  gd.getNextString();
		OrthoMapsCollection maps_collection=null;
		boolean use_files_list = false;
		if (use_saved_collection) {
			try {
				maps_collection = OrthoMapsCollection.readOrthoMapsCollection (orthoMapsCollection_path);
			} catch (ClassNotFoundException | IOException e) {
				use_files_list = true;
				System.out.println("Saved data not found: "+orthoMapsCollection_path+", building from a list "+files_list_path);
				// TODO Auto-generated catch block
				e.printStackTrace();
//				e.printStackTrace();
			}
			//files_list_path
			if (!use_files_list) {
				if (update_kernel_patterns) {
					maps_collection.updateKernels(files_list_path);
					maps_collection.updatePatterns(files_list_path);
				}
			}
		} else {
			use_files_list = true;
		}
		if (use_files_list) { // using files list
			maps_collection = new OrthoMapsCollection(files_list_path); // should have ".list" extension
			maps_collection.updateNumberScenes();
			maps_collection.updateSfmGain();
		}
		
		if (update_bl_bc) {
			boolean OK = updateBlBcFileNames(
					suffixes_bl_bc[suffix_bc_bl_indx], // String suffix,
@@ -857,22 +868,96 @@ public class ComboMatch {
        			available_pairs[i][0] = pairs_list.get(i).x;
        			available_pairs[i][1] = pairs_list.get(i).y;
        		}
        		
        		boolean flt_list =           clt_parameters.imp.flt_list;          //  true;
        		boolean flt_undef_only =     clt_parameters.imp.flt_undef_only;    //  false;
        		double  flt_min_overlap =    clt_parameters.imp.flt_min_overlap;   //  0.0;
        		double  flt_max_overlap =    clt_parameters.imp.flt_max_overlap;   //  1.0;
        		double  flt_min_rms =        clt_parameters.imp.flt_min_rms;       //  0.0;
        		double  flt_max_rms =        clt_parameters.imp.flt_max_rms;       //  2.0;
        		boolean flt_nan_rms =        clt_parameters.imp.flt_nan_rms;       //  false;
        		boolean flt_show_names =     clt_parameters.imp.flt_show_names;    //  true;
        		boolean flt_show_overlaps =  clt_parameters.imp.flt_show_overlaps; //  true;
        		boolean flt_show_rms =       clt_parameters.imp.flt_show_rms;      //  true;
        		boolean flt_update_config = false;
        		String  flt_extra_line =    "--- select a single image ---";
				GenericJTabbedDialog gdf = new GenericJTabbedDialog("Select pairs filter/display",800,500);
				gdf.addCheckbox    ("Filter pairs",                flt_list, "Filter available pairs.");
				gdf.addCheckbox    ("Keep undefined pairs only",   flt_undef_only, "Keep only undefined pairs (affines== null).");
				gdf.addNumericField("Minimal scene overlap (0..1)",flt_min_overlap,  3,7,"", "Minimal overlap of the scenes to keep (0-no overlap, 1.0 - smaller scene is inside the parger one.");
				gdf.addNumericField("Maximal scene overlap (0..1)",flt_max_overlap,  3,7,"", "Maximal overlap of the scenes to keep (0-no overlap, 1.0 - smaller scene is inside the parger one.");
				gdf.addNumericField("Minimal RMSE",                flt_min_rms,  3,7,"",	 "Minimal LMA RMSE of the scene pair.");
				gdf.addNumericField("Maximal RMSE",                flt_max_rms,  3,7,"",	 "Maximal LMA RMSE of the scene pair.");
				gdf.addCheckbox    ("NaN RMS (failed match)",      flt_nan_rms, "Keep only failed matches with RMSE=NaN.");
				gdf.addCheckbox    ("Show scene names",            flt_show_names, "Show scene full names (timestamps) in selection drop-down list.");
				gdf.addCheckbox    ("Show scene overlaps",         flt_show_overlaps, "Show scene overlaps (in percents) in selection drop-down list.");
				gdf.addCheckbox    ("Show pairs RMSE",             flt_show_rms, "Show scene match RMSE in selection drop-down list.");
				gdf.addCheckbox    ("Update configuration",        flt_update_config, "Update matching configuration parameters to be saved as defaults.");
				gdf.showDialog();
				if (gdf.wasCanceled()) return false;
				flt_list          = gdf.getNextBoolean();
				flt_undef_only    = gdf.getNextBoolean();
				flt_min_overlap   = gdf.getNextNumber();
				flt_max_overlap   = gdf.getNextNumber();
				flt_min_rms       = gdf.getNextNumber();
				flt_max_rms       = gdf.getNextNumber();
				flt_nan_rms       = gdf.getNextBoolean();
				flt_show_names    = gdf.getNextBoolean();
				flt_show_overlaps = gdf.getNextBoolean();
				flt_show_rms      = gdf.getNextBoolean();
				flt_update_config = gdf.getNextBoolean();
				if (flt_update_config) {
					clt_parameters.imp.flt_list =          flt_list;
					clt_parameters.imp.flt_undef_only =    flt_undef_only;
					clt_parameters.imp.flt_min_overlap =   flt_min_overlap;
					clt_parameters.imp.flt_max_overlap =   flt_max_overlap;
					clt_parameters.imp.flt_min_rms =       flt_min_rms;
					clt_parameters.imp.flt_max_rms =       flt_max_rms;
					clt_parameters.imp.flt_nan_rms =       flt_nan_rms;
					clt_parameters.imp.flt_show_names =    flt_show_names;
					clt_parameters.imp.flt_show_overlaps = flt_show_overlaps;
					clt_parameters.imp.flt_show_rms =      flt_show_rms;
				}

				if (flt_list) {
					available_pairs = maps_collection.filterPairs(
							available_pairs, // int [][] plist_in,
							flt_undef_only,  // boolean  undef_only,
							flt_min_overlap, // double   min_overlap,
							flt_max_overlap, // double   max_overlap,
							flt_min_rms,     // double   min_rms,
							flt_max_rms,     // double   max_rms,
							flt_nan_rms);    // boolean  nan_rms)
				}
				
				String [] choices_all = maps_collection.textPairs (
						available_pairs,   // int [][] plist,
						flt_show_names,    // boolean          show_names,
						flt_show_overlaps, // boolean          show_overlap,
						flt_show_rms,      // boolean          show_rms,
						flt_extra_line);   // String           extra_line)
						
				/*
				String [] choices = getPairChoices(
						available_pairs, // int [][] pairs,
						names); // String [] names)
				String [] choices_all = new String[choices.length+1];
				System.arraycopy(choices, 0, choices_all, 0, choices.length);
				choices_all[choices_all.length-1] = "--- select a single image ---";
				*/
				
				
				
				GenericJTabbedDialog gdc = new GenericJTabbedDialog("Select image pair",1200,100);
				int num_choice_lines = 50;
				gdc.addChoice("Image pair:",
						choices_all,
						choices_all[choices.length], // -1],
						choices_all[choices_all.length - 1], // -1],
						"Select processed image pair or request a single image selection", num_choice_lines);
				gdc.showDialog();
				if (gdc.wasCanceled()) return false;
				int pair= gdc.getNextChoiceIndex();
				if (pair >= choices.length) {
				if (pair >= (choices_all.length -1)) {
					int default_choice = 0;
					int num_scene_lines = 50;
					if (process_correlation || render_match) { // select a second image to match
@@ -932,7 +1017,7 @@ public class ComboMatch {
					//						imp_pat_match.show();
				}
        		
        	} else {
        	} else { // gpu_spair.length >= 2
        		if (test_multi_lma) {
        			OrthoMultiLMA.testMultiLMA(
        					clt_parameters,  // CLTParameters       clt_parameters,
@@ -956,11 +1041,31 @@ public class ComboMatch {
        			pairwiseOrthoMatch = maps_collection.ortho_maps[gpu_pair[0]].getMatch(
        					maps_collection.ortho_maps[gpu_pair[1]].getName());
        		}
        		if (pairwiseOrthoMatch == null) { // try undefined
        			pairwiseOrthoMatch = maps_collection.ortho_maps[gpu_pair[0]].getMatch(
        					maps_collection.ortho_maps[gpu_pair[1]].getName(), true);
            		if (pairwiseOrthoMatch != null) {
            			double [][] aff0 = maps_collection.ortho_maps[gpu_pair[0]].getAffine();            			
            			double [][] aff1 = maps_collection.ortho_maps[gpu_pair[1]].getAffine();
            			double [] enuOffset = maps_collection.ortho_maps[gpu_pair[1]].enuOffsetTo(maps_collection.ortho_maps[gpu_pair[0]]);
            			double [] rd = {enuOffset[0], -enuOffset[1]}; // {right,down} of the image 
            			PairwiseOrthoMatch aff_match = new PairwiseOrthoMatch (
            					aff0, // double [][] affine0,
            					aff1, // double [][] affine1,
            					rd);  // double [] rd);
            			double [][] daffine = aff_match.getAffine();
            			pairwiseOrthoMatch.setAffine(daffine);
            		}
        		}        		
        		
        		if (pairwiseOrthoMatch == null) {
        			System.out.println("No correlation data is available for pairs "+gpu_spair[0]+
        					" - "+gpu_spair[1]+" need to implement/search reverse,  a spiral search or restart command");
        			System.out.println("after loading a corresponding full map image and marking same feature on");
        			System.out.print("after loading a corresponding full map image and marking same feature on ");
        			System.out.println("each of the two selected slices, reference one first");
        			
        			
        			
        		} else {
        			affine1 = pairwiseOrthoMatch.getAffine();
        			double [][][] affines = {affine0,affine1};
+10 −2
Original line number Diff line number Diff line
@@ -236,7 +236,8 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
		if (undefined_only) {
			String [] matches = pairwise_matches.keySet().toArray(new String[0]);
			for (String match:matches) {
				if (!getMatch(match).isDefined()) {
				PairwiseOrthoMatch pm = getMatch(match); 
				if ((pm == null) || !pm.isDefined()) {
					unsetMatch(match);
				}
			}
@@ -483,7 +484,14 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			lla = ElphelTiffReader.getLLA(imp_prop);
		} catch (NullPointerException e) {
			System.out.println("No GPS data in "+path);
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		dt = ElphelTiffReader.getLocalDateTime(imp_prop);
		vert_meters =      ElphelTiffReader.getXYOffsetMeters(imp_prop);
		orig_pix_meters = ElphelTiffReader.getPixelSize(imp_prop)[0];
+177 −21

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ public class PairwiseOrthoMatch implements Serializable {
	public transient int []      nxy = null; // not saved, just to communicate for logging
	public transient double      overlap = 0.0;
	public transient double []   equalize1to0 = {1,0}; // value1 = equalize2to1[0]*value2+equalize2to1[1]
	public transient boolean     ok = false;

//	public PairwiseOrthoMatch() {}
	public double getOverlap() {
@@ -75,6 +76,7 @@ public class PairwiseOrthoMatch implements Serializable {
			pom.nxy = nxy.clone();
		}
		pom.equalize1to0 = this.equalize1to0.clone();
		pom.ok = this.ok;
		return pom;
	}
	/**
Loading