Commit 6efffa79 authored by Andrey Filippov's avatar Andrey Filippov

Updated OrthoMultiLMA.buildOrthoMap

parent 9d47b1c6
...@@ -928,6 +928,7 @@ public class ComboMatch { ...@@ -928,6 +928,7 @@ public class ComboMatch {
flt_show_names = gdf.getNextBoolean(); flt_show_names = gdf.getNextBoolean();
flt_show_overlaps = gdf.getNextBoolean(); flt_show_overlaps = gdf.getNextBoolean();
flt_show_rms = gdf.getNextBoolean(); flt_show_rms = gdf.getNextBoolean();
flt_show_zoom = gdf.getNextBoolean();
flt_update_config = gdf.getNextBoolean(); flt_update_config = gdf.getNextBoolean();
if (flt_update_config) { if (flt_update_config) {
clt_parameters.imp.flt_list = flt_list; clt_parameters.imp.flt_list = flt_list;
......
...@@ -5277,29 +5277,29 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -5277,29 +5277,29 @@ public class OrthoMapsCollection implements Serializable{
num_iter_lma = (int) gdf.getNextNumber(); num_iter_lma = (int) gdf.getNextNumber();
max_rms_iter[0] = gdf.getNextNumber(); max_rms_iter[0] = gdf.getNextNumber();
max_rms_iter[1] = gdf.getNextNumber(); max_rms_iter[1] = gdf.getNextNumber();
lores_ignore_rms = gdf.getNextBoolean(); lores_ignore_rms = gdf.getNextBoolean();
frac_remove = gdf.getNextNumber(); frac_remove = gdf.getNextNumber();
metric_err = gdf.getNextNumber(); metric_err = gdf.getNextNumber();
// pmtch_use_affine= gdf.getNextBoolean(); // pmtch_use_affine= gdf.getNextBoolean();
max_std = gdf.getNextNumber(); max_std = gdf.getNextNumber();
min_std_rad = gdf.getNextNumber(); min_std_rad = gdf.getNextNumber();
ignore_prev_rms = gdf.getNextBoolean(); ignore_prev_rms = gdf.getNextBoolean();
num_tries = (int) gdf.getNextNumber(); num_tries = (int) gdf.getNextNumber();
rad_fraction = gdf.getNextNumber(); rad_fraction = gdf.getNextNumber();
max_tile_rad = gdf.getNextNumber(); max_tile_rad = gdf.getNextNumber();
fill_fraction = gdf.getNextNumber(); fill_fraction = gdf.getNextNumber();
fill_fraction_final= gdf.getNextNumber(); fill_fraction_final= gdf.getNextNumber();
ease_nosfm = gdf.getNextNumber(); ease_nosfm = gdf.getNextNumber();
pull_skew = gdf.getNextNumber(); pull_skew = gdf.getNextNumber();
pull_tilt = gdf.getNextNumber(); pull_tilt = gdf.getNextNumber();
pull_scale = gdf.getNextNumber(); pull_scale = gdf.getNextNumber();
save_each = gdf.getNextBoolean(); save_each = gdf.getNextBoolean();
log_append = gdf.getNextBoolean(); log_append = gdf.getNextBoolean();
log_path = gdf.getNextString(); log_path = gdf.getNextString();
debugLevel = (int) gdf.getNextNumber(); debugLevel = (int) gdf.getNextNumber();
min_scene = (int) gdf.getNextNumber(); min_scene = (int) gdf.getNextNumber();
flt_update_config = gdf.getNextBoolean(); flt_update_config = gdf.getNextBoolean();
if (flt_update_config) { if (flt_update_config) {
clt_parameters.imp.flt_min_overlap = flt_min_overlap; clt_parameters.imp.flt_min_overlap = flt_min_overlap;
......
...@@ -29,6 +29,8 @@ import java.awt.Point; ...@@ -29,6 +29,8 @@ import java.awt.Point;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -220,9 +222,54 @@ public class OrthoMultiLMA { ...@@ -220,9 +222,54 @@ public class OrthoMultiLMA {
OrthoMapsCollection maps_collection, OrthoMapsCollection maps_collection,
String orthoMapsCollection_path String orthoMapsCollection_path
) { ) {
boolean all_pairs = true; ArrayList<Point> pairs_list = new ArrayList<Point>();
double min_overlap_frac = clt_parameters.imp.pwise_overlap; // 0.25; for (OrthoMap map : maps_collection.ortho_maps) {
double max_rms_refine = clt_parameters.imp.pwise_max_rms; // 0.35; // for (String other_name: map.pairwise_matches.keySet()) {
pairs_list.add(new Point(
maps_collection.getIndex(map.getName()),
maps_collection.getIndex(other_name)));
}
}
// sort pairs_list by x then y
Collections.sort(pairs_list, new Comparator<Point>() {
@Override
public int compare(Point lhs, Point rhs) {
return (rhs.x > lhs.x) ? -1 : (rhs.x < lhs.x) ? 1 :
((rhs.y > lhs.y) ? -1 : (rhs.y < lhs.y) ? 1 : 0); // increasing
}
});
// convert ArrayList<Point> to array int[][]
int [][] available_pairs = new int [pairs_list.size()][2];
for (int i = 0; i < available_pairs.length; i++) {
available_pairs[i][0] = pairs_list.get(i).x;
available_pairs[i][1] = pairs_list.get(i).y;
}
/// boolean all_pairs = true;
/// double min_overlap_frac = clt_parameters.imp.pwise_overlap; // 0.25;
/// double max_rms_refine = clt_parameters.imp.pwise_max_rms; // 0.35; //
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 = false; // clt_parameters.imp.flt_nan_rms; // false;
boolean flt_filt_zoom = clt_parameters.imp.flt_filt_zoom; // true;
int flt_min_zoom = clt_parameters.imp.flt_min_zoom; // -2;
int flt_max_zoom = clt_parameters.imp.flt_max_zoom; // 10;
boolean flt_show_names = true; // clt_parameters.imp.flt_show_names; // true;
boolean flt_show_overlaps = true; // clt_parameters.imp.flt_show_overlaps; // true;
boolean flt_show_rms = true; // clt_parameters.imp.flt_show_rms; // true;
boolean flt_show_zoom = true; // clt_parameters.imp.flt_show_zoom; // true;
boolean move_only = clt_parameters.imp.pmap_move_only; // false; boolean move_only = clt_parameters.imp.pmap_move_only; // false;
boolean ignore_affines = clt_parameters.imp.pmap_ignore_affines; // false; boolean ignore_affines = clt_parameters.imp.pmap_ignore_affines; // false;
boolean use_inv = clt_parameters.imp.pmap_use_inv; // false; boolean use_inv = clt_parameters.imp.pmap_use_inv; // false;
...@@ -235,11 +282,23 @@ public class OrthoMultiLMA { ...@@ -235,11 +282,23 @@ public class OrthoMultiLMA {
int num_iter = clt_parameters.imp.pmap_num_iter; // 100; // 50; int num_iter = clt_parameters.imp.pmap_num_iter; // 100; // 50;
boolean show_result = clt_parameters.imp.pmap_show_result; // false; boolean show_result = clt_parameters.imp.pmap_show_result; // false;
int debugLevel = clt_parameters.imp.pmap_debugLevel; // 2; int debugLevel = clt_parameters.imp.pmap_debugLevel; // 2;
boolean flt_update_config = false;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Pairwise Match Parameters",1200,400); GenericJTabbedDialog gd = new GenericJTabbedDialog("Pairwise Match Parameters",1200,800);
gd.addCheckbox ("Use all available pairs", all_pairs, "Use all available pairs."); /// gd.addCheckbox ("Use all available pairs", all_pairs, "Use all available pairs.");
gd.addNumericField("Minimal overlap fraction", min_overlap_frac, 3,7,"", "Minimal overlap fraction."); /// gd.addNumericField("Minimal overlap fraction", min_overlap_frac, 3,7,"", "Minimal overlap fraction.");
gd.addNumericField("Satisfactory RMSE, final", max_rms_refine,3,7,"scaled pix", "Maximal RMSE to consider match, in scaled pixels, during refine."); /// gd.addNumericField("Satisfactory RMSE, final", max_rms_refine,3,7,"scaled pix", "Maximal RMSE to consider match, in scaled pixels, during refine.");
gd.addCheckbox ("Filter pairs", flt_list, "Filter available pairs.");
gd.addCheckbox ("Keep undefined pairs only", flt_undef_only, "Keep only undefined pairs (affines== null).");
gd.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.");
gd.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.");
gd.addNumericField("Minimal RMSE", flt_min_rms, 3,7,"", "Minimal LMA RMSE of the scene pair.");
gd.addNumericField("Maximal RMSE", flt_max_rms, 3,7,"", "Maximal LMA RMSE of the scene pair.");
/// gd.addCheckbox ("NaN RMS (failed match)", flt_nan_rms, "Keep only failed matches with RMSE=NaN.");
gd.addCheckbox ("Filter by zoom level" , flt_filt_zoom, "Filter by the zoom level used for matching.");
gd.addNumericField("Minimal zoom", flt_min_zoom, 0,3,"","Minimal zoom level used for matching.");
gd.addNumericField("Maximal zoom", flt_max_zoom, 0,3,"","Maximal zoom level used for matching.");
gd.addCheckbox ("Moves only", move_only, "Moves only, no affine transform."); gd.addCheckbox ("Moves only", move_only, "Moves only, no affine transform.");
gd.addCheckbox ("Ignore existing affines", ignore_affines, "Start from unity matrices, ignore saved affines."); gd.addCheckbox ("Ignore existing affines", ignore_affines, "Start from unity matrices, ignore saved affines.");
gd.addCheckbox ("Use reversed pairs", use_inv, "Use reversed (late-early timestamps) pairs."); gd.addCheckbox ("Use reversed pairs", use_inv, "Use reversed (late-early timestamps) pairs.");
...@@ -252,12 +311,25 @@ public class OrthoMultiLMA { ...@@ -252,12 +311,25 @@ public class OrthoMultiLMA {
gd.addNumericField("LMA iterations", num_iter, 0,3,"",".Maximal number of the LMA iterations."); gd.addNumericField("LMA iterations", num_iter, 0,3,"",".Maximal number of the LMA iterations.");
gd.addCheckbox ("Show result image", show_result, "."); gd.addCheckbox ("Show result image", show_result, ".");
gd.addNumericField("Debug level for maps", debugLevel, 0,3,"","Debug building for LMA building maps."); gd.addNumericField("Debug level for maps", debugLevel, 0,3,"","Debug building for LMA building maps.");
gd.addCheckbox ("Update configuration", flt_update_config, "Update matching configuration parameters to be saved as defaults.");
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return -1; if (gd.wasCanceled()) return -1;
all_pairs = gd.getNextBoolean(); /// all_pairs = gd.getNextBoolean();
min_overlap_frac = gd.getNextNumber(); /// min_overlap_frac = gd.getNextNumber();
max_rms_refine = gd.getNextNumber(); /// max_rms_refine = gd.getNextNumber();
flt_list = gd.getNextBoolean();
flt_undef_only = gd.getNextBoolean();
flt_min_overlap = gd.getNextNumber();
flt_max_overlap = gd.getNextNumber();
flt_min_rms = gd.getNextNumber();
flt_max_rms = gd.getNextNumber();
/// flt_nan_rms = gd.getNextBoolean();
flt_filt_zoom = gd.getNextBoolean();
flt_min_zoom = (int) gd.getNextNumber();
flt_max_zoom = (int) gd.getNextNumber();
move_only = gd.getNextBoolean(); move_only = gd.getNextBoolean();
ignore_affines = gd.getNextBoolean(); ignore_affines = gd.getNextBoolean();
use_inv = gd.getNextBoolean(); use_inv = gd.getNextBoolean();
...@@ -270,16 +342,70 @@ public class OrthoMultiLMA { ...@@ -270,16 +342,70 @@ public class OrthoMultiLMA {
num_iter = (int) gd.getNextNumber(); num_iter = (int) gd.getNextNumber();
show_result = gd.getNextBoolean(); show_result = gd.getNextBoolean();
debugLevel = (int) gd.getNextNumber(); debugLevel = (int) gd.getNextNumber();
flt_update_config = gd.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_filt_zoom = flt_filt_zoom;
clt_parameters.imp.flt_min_zoom = flt_min_zoom;
clt_parameters.imp.flt_max_zoom = flt_max_zoom;
clt_parameters.imp.pmap_move_only = move_only;
clt_parameters.imp.pmap_ignore_affines = ignore_affines;
clt_parameters.imp.pmap_use_inv = use_inv;
clt_parameters.imp.pmap_skew_pull = skew_pull;
clt_parameters.imp.pmap_tilt_pull = tilt_pull;
clt_parameters.imp.pmap_scale_pull = scale_pull;
clt_parameters.imp.pmap_position_pull = position_pull;
clt_parameters.imp.pmap_overlap_pow = overlap_pow;
clt_parameters.imp.pmap_rms_diff = rms_diff;
clt_parameters.imp.pmap_num_iter = num_iter;
clt_parameters.imp.pmap_show_result = show_result;
clt_parameters.imp.pmap_debugLevel = debugLevel;
}
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)
flt_filt_zoom, // boolean filt_zoom,
flt_min_zoom, // int min_zoom,
flt_max_zoom); // int max_zoom)
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_show_zoom, // boolean show_zoom,
null); // String extra_line)
if (debugLevel > 0) {
System.out.println("Selected "+available_pairs.length+" scene pairs for matching");
for (int i = 0; i < available_pairs.length; i++) {
System.out.println(String.format("%4d:%s",i,choices_all[i]));
}
}
if (available_pairs.length == 0) {
return -1;
}
return buildOrthoMap( return buildOrthoMap(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
maps_collection, // OrthoMapsCollection maps_collection, maps_collection, // OrthoMapsCollection maps_collection,
orthoMapsCollection_path, // String orthoMapsCollection_path, orthoMapsCollection_path, // String orthoMapsCollection_path,
all_pairs, // boolean all_pairs, /// all_pairs, // boolean all_pairs,
// filtering of the pairs // filtering of the pairs
min_overlap_frac, // double min_overlap_frac, /// min_overlap_frac, // double min_overlap_frac,
max_rms_refine, // double max_rms, /// max_rms_refine, // double max_rms,
available_pairs, // int [][] available_pairs,
move_only, // boolean move_only, move_only, // boolean move_only,
ignore_affines, // boolean ignore_affines, ignore_affines, // boolean ignore_affines,
use_inv, // boolean use_inv, use_inv, // boolean use_inv,
...@@ -297,10 +423,10 @@ public class OrthoMultiLMA { ...@@ -297,10 +423,10 @@ public class OrthoMultiLMA {
CLTParameters clt_parameters, CLTParameters clt_parameters,
OrthoMapsCollection maps_collection, OrthoMapsCollection maps_collection,
String orthoMapsCollection_path, String orthoMapsCollection_path,
boolean all_pairs, /// boolean all_pairs,
double min_overlap_frac, /// double min_overlap_frac,
double max_rms, /// double max_rms,
int [][] available_pairs,
boolean move_only, boolean move_only,
boolean ignore_affines, boolean ignore_affines,
boolean use_inv, boolean use_inv,
...@@ -316,33 +442,8 @@ public class OrthoMultiLMA { ...@@ -316,33 +442,8 @@ public class OrthoMultiLMA {
double [] val_coord = null; // 1 - valid, 0 - invalid, minimize coordinates errors double [] val_coord = null; // 1 - valid, 0 - invalid, minimize coordinates errors
boolean corr_avg= (skew_pull > 0) || (tilt_pull > 0) || (scale_pull > 0); boolean corr_avg= (skew_pull > 0) || (tilt_pull > 0) || (scale_pull > 0);
int [] indices = null; int [] indices = null;
/*
if (all_pairs) { if (all_pairs) {
/*
boolean [] used_scenes = new boolean [maps_collection.ortho_maps.length];
for (int scene0 = 0; scene0 < (used_scenes.length-1); scene0++) {
Set<String> match_names = maps_collection.ortho_maps[scene0].pairwise_matches.keySet();
for (String scene1_name:match_names) {
PairwiseOrthoMatch match = maps_collection.ortho_maps[scene0].getMatch(scene1_name); // defined only
if (match != null) {
int scene1 = maps_collection.getIndex(scene1_name);
used_scenes[scene0] = true;
used_scenes[scene1] = true;
}
}
}
int num_scenes = 0;
for (int i = 0; i < used_scenes.length; i++) if (used_scenes[i]){
num_scenes++;
}
indices = new int [num_scenes];
int indx = 0;
for (int i = 0; i < used_scenes.length; i++) if (used_scenes[i]){
indices[indx++] = i;
}
if (debugLevel > -1) {
System.out.println("buildOrthoMap(): got "+indices.length+" scenes with pairs");
}
*/
} else { } else {
indices = maps_collection.getScenesSelection( indices = maps_collection.getScenesSelection(
null, // boolean select_all, null, // boolean select_all,
...@@ -355,13 +456,13 @@ public class OrthoMultiLMA { ...@@ -355,13 +456,13 @@ public class OrthoMultiLMA {
max_rms, // double max_rmse, max_rms, // double max_rmse,
true, // boolean max_resolution, true, // boolean max_resolution,
null); // int [][] remove_pairs null); // int [][] remove_pairs
*/
indices= maps_collection.getScenesFromPairs( indices= maps_collection.getScenesFromPairs( // may be shorter, each element - absolute scene number used in pairs
pairs_defined_abs,// int [][] pairs, available_pairs, // pairs_defined_abs,// int [][] pairs,
null); // int [] indices_in) // preselected indices or null null); // int [] indices_in) // preselected indices or null
int [][] defined_pairs = maps_collection.condensePairs (pairs_defined_abs,indices); int [][] defined_pairs = maps_collection.condensePairs (available_pairs, indices); // pairs_defined_abs,indices);
OrthoMultiLMA oml = new OrthoMultiLMA( OrthoMultiLMA oml = new OrthoMultiLMA(
corr_avg, corr_avg,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment