Commit ef8c6ac2 authored by Andrey Filippov's avatar Andrey Filippov

preparing for adding pairwise matching after single-connected are

subject to LMA
parent 099bf912
...@@ -850,6 +850,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -850,6 +850,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addButton("Warp pair", panelLWIRWorld, color_process); addButton("Warp pair", panelLWIRWorld, color_process);
addButton("Read Tiff", panelLWIRWorld, color_process); addButton("Read Tiff", panelLWIRWorld, color_process);
addButton("Test video", panelLWIRWorld, color_process); addButton("Test video", panelLWIRWorld, color_process);
addButton("Ortho", panelLWIRWorld, color_process);
addButton("Ortho Pairs", panelLWIRWorld, color_process); addButton("Ortho Pairs", panelLWIRWorld, color_process);
addButton("Manual pair", panelLWIRWorld, color_process); addButton("Manual pair", panelLWIRWorld, color_process);
addButton("Extract Objects", panelLWIRWorld, color_process); addButton("Extract Objects", panelLWIRWorld, color_process);
...@@ -5718,7 +5719,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -5718,7 +5719,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
e.printStackTrace(); e.printStackTrace();
} }
// ComboMatch.testReadTiff(); // 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; DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (GPU_TILE_PROCESSOR == null) { if (GPU_TILE_PROCESSOR == null) {
...@@ -5739,6 +5740,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -5739,6 +5740,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
ComboMatch.openTestPairGps( ComboMatch.openTestPairGps(
CLT_PARAMETERS, // CLTParameters clt_parameters, CLT_PARAMETERS, // CLTParameters clt_parameters,
GPU_TILE_PROCESSOR, GPU_TILE_PROCESSOR,
label.equals("Ortho"),// boolean dflt_options,
label.equals("Extract Objects"), // boolean extract_mines, label.equals("Extract Objects"), // boolean extract_mines,
label.equals("Manual pair"), // boolean manual_pair, label.equals("Manual pair"), // boolean manual_pair,
DEBUG_LEVEL); DEBUG_LEVEL);
......
...@@ -236,7 +236,8 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ ...@@ -236,7 +236,8 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
if (undefined_only) { if (undefined_only) {
String [] matches = pairwise_matches.keySet().toArray(new String[0]); String [] matches = pairwise_matches.keySet().toArray(new String[0]);
for (String match:matches) { for (String match:matches) {
if (!getMatch(match).isDefined()) { PairwiseOrthoMatch pm = getMatch(match);
if ((pm == null) || !pm.isDefined()) {
unsetMatch(match); unsetMatch(match);
} }
} }
...@@ -483,7 +484,14 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ ...@@ -483,7 +484,14 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
lla = ElphelTiffReader.getLLA(imp_prop); 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); dt = ElphelTiffReader.getLocalDateTime(imp_prop);
vert_meters = ElphelTiffReader.getXYOffsetMeters(imp_prop); vert_meters = ElphelTiffReader.getXYOffsetMeters(imp_prop);
orig_pix_meters = ElphelTiffReader.getPixelSize(imp_prop)[0]; orig_pix_meters = ElphelTiffReader.getPixelSize(imp_prop)[0];
......
...@@ -16,6 +16,7 @@ public class PairwiseOrthoMatch implements Serializable { ...@@ -16,6 +16,7 @@ public class PairwiseOrthoMatch implements Serializable {
public transient int [] nxy = null; // not saved, just to communicate for logging public transient int [] nxy = null; // not saved, just to communicate for logging
public transient double overlap = 0.0; public transient double overlap = 0.0;
public transient double [] equalize1to0 = {1,0}; // value1 = equalize2to1[0]*value2+equalize2to1[1] public transient double [] equalize1to0 = {1,0}; // value1 = equalize2to1[0]*value2+equalize2to1[1]
public transient boolean ok = false;
// public PairwiseOrthoMatch() {} // public PairwiseOrthoMatch() {}
public double getOverlap() { public double getOverlap() {
...@@ -75,6 +76,7 @@ public class PairwiseOrthoMatch implements Serializable { ...@@ -75,6 +76,7 @@ public class PairwiseOrthoMatch implements Serializable {
pom.nxy = nxy.clone(); pom.nxy = nxy.clone();
} }
pom.equalize1to0 = this.equalize1to0.clone(); pom.equalize1to0 = this.equalize1to0.clone();
pom.ok = this.ok;
return pom; return pom;
} }
/** /**
......
...@@ -223,6 +223,9 @@ public class QuadCLTCPU { ...@@ -223,6 +223,9 @@ public class QuadCLTCPU {
enu_corr_metric = corr; enu_corr_metric = corr;
} }
public String toString() {
return this.image_name;
}
// find best rotation between IMU XYZ and camera XYZ // find best rotation between IMU XYZ and camera XYZ
/** /**
......
...@@ -8636,7 +8636,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8636,7 +8636,7 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel+2); // final int debugLevel) debugLevel+2); // final int debugLevel)
if (model_directory == null) { if (model_directory == null) {
// TODO: Save continueation after failure not to retry each run // TODO: Save continuation after failure not to retry each run
System.out.println("Failed to build sequence for series "+ref_index); System.out.println("Failed to build sequence for series "+ref_index);
if (start_ref_pointers[0] < (min_num_scenes-1)) { if (start_ref_pointers[0] < (min_num_scenes-1)) {
break; break;
...@@ -8645,6 +8645,12 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8645,6 +8645,12 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Continue from index "+ref_index); System.out.println("Continue from index "+ref_index);
continue; // and go to the to next scene sequence from the list continue; // and go to the to next scene sequence from the list
} }
if ((start_ref_pointers[0]==0) && (start_ref_pointers[1]==0)) { // bail out for debug
System.out.println("\n ----- PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+") ABORTED in "+
IJ.d2s(0.000000001*(System.nanoTime()-start_time_seq),3)+" sec ("+
IJ.d2s(0.000000001*(System.nanoTime()-start_time_all),3)+" sec from the overall start\n");
break;
}
first_in_series = false; // at least once success in this series first_in_series = false; // at least once success in this series
System.out.println("adding to video_sets_list start="+start_ref_pointers[0]+", end="+ref_index); // start_ref_pointers[1]); System.out.println("adding to video_sets_list start="+start_ref_pointers[0]+", end="+ref_index); // start_ref_pointers[1]);
for (int i= 0; i < video_list[0].length; i++) { for (int i= 0; i < video_list[0].length; i++) {
......
...@@ -790,6 +790,76 @@ public class StructureFromMotion { ...@@ -790,6 +790,76 @@ public class StructureFromMotion {
return combo_dsn_final; return combo_dsn_final;
} }
/**
* Filter reference disparity from NaN (average immediate neighbors), dips and bumps
* @param disp_in
* @param max_dip maximal dip relative to lowest neighbor (0 - any)
* @param max_bump maximal bump relative to highest neighbor (0 - any)
* @param filter_nan replace NaN by neighbors average
* @param tilesX
* @return filtered disparity
*/
public static double [] filterRefDisparity(
final double [] disp_in,
final double max_dip,
final double max_bump,
final boolean filter_nan,
final int tilesX ) {
final double [] disp_out = disp_in.clone();
final int tilesY = disp_in.length / tilesX;
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < disp_in.length; nTile = ai.getAndIncrement()) {
int navg = 0;
double s = 0;
if (Double.isNaN(disp_in[nTile])) {
for (int dir = 0; dir < TileNeibs.DIRS; dir++) {
int tile1 = tn.getNeibIndex(nTile, dir);
if ((tile1 >=0) && !Double.isNaN(disp_in[tile1])){
s += disp_in[tile1];
navg++;
}
}
if (navg > 0) {
disp_out[nTile] = s/navg;
}
} else {
double mn = Double.NaN, mx = Double.NaN;
for (int dir = 0; dir < TileNeibs.DIRS; dir++) {
int tile1 = tn.getNeibIndex(nTile, dir);
if (tile1 >=0){
double d = disp_in[tile1];
if (!Double.isNaN(d)) {
if (Double.isNaN(mn)) {
mn = d;
mx = d;
} else {
mn = Math.min(mn, d);
mx = Math.max(mn, d);
}
s += d;
navg++;
}
}
}
if (navg > 0) {
if ( ((max_dip > 0) && (disp_in[nTile] < (mn - max_dip))) ||
((max_bump > 0) && (disp_in[nTile] > (mx + max_bump)))) {
disp_out[nTile] = s/navg;
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return disp_out;
}
public static double [][] sfmPairsSet( public static double [][] sfmPairsSet(
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
...@@ -798,6 +868,7 @@ public class StructureFromMotion { ...@@ -798,6 +868,7 @@ public class StructureFromMotion {
final double mb_max_gain, final double mb_max_gain,
final boolean batch_mode, final boolean batch_mode,
final int debugLevel) { final int debugLevel) {
boolean save_disp_seq = clt_parameters.imp.sfm_save_seq; //true; boolean save_disp_seq = clt_parameters.imp.sfm_save_seq; //true;
boolean show_disp_seq = clt_parameters.imp.sfm_show_seq &= !batch_mode; //true; boolean show_disp_seq = clt_parameters.imp.sfm_show_seq &= !batch_mode; //true;
boolean show_disp_corr_ind = clt_parameters.imp.sfm_show_corr_ind &= !batch_mode; //false; //true; boolean show_disp_corr_ind = clt_parameters.imp.sfm_show_corr_ind &= !batch_mode; //false; //true;
...@@ -836,6 +907,10 @@ public class StructureFromMotion { ...@@ -836,6 +907,10 @@ public class StructureFromMotion {
final boolean fill_weak = clt_parameters.imp.sfm_fill_weak; // false; final boolean fill_weak = clt_parameters.imp.sfm_fill_weak; // false;
final boolean extrapolate = clt_parameters.imp.sfm_extrapolate; // false; final boolean extrapolate = clt_parameters.imp.sfm_extrapolate; // false;
final double max_dip = clt_parameters.imp.sfm_max_dip; // 0.1;
final double max_bump = clt_parameters.imp.sfm_max_bump; // 0.5;
final boolean filter_nan = clt_parameters.imp.sfm_filter_nan; // true;
final int tilesX = ref_scene.getTileProcessor().getTilesX(); final int tilesX = ref_scene.getTileProcessor().getTilesX();
final int tilesY = ref_scene.getTileProcessor().getTilesY(); final int tilesY = ref_scene.getTileProcessor().getTilesY();
...@@ -882,7 +957,7 @@ public class StructureFromMotion { ...@@ -882,7 +957,7 @@ public class StructureFromMotion {
debugLevel); debugLevel);
double [] interscene_ref_disparity = null; // keep null to use old single-scene disparity for interscene matching double [] interscene_ref_disparity = null; // keep null to use old single-scene disparity for interscene matching
if (use_combo_dsi) { if (use_combo_dsi) {
interscene_ref_disparity = ds[0].clone(); // use_lma_dsi ? interscene_ref_disparity = ds[0]; // .clone(); // use_lma_dsi ?
/* use conditioned! /* use conditioned!
if (use_lma_dsi) { if (use_lma_dsi) {
for (int i = 0; i < interscene_ref_disparity.length; i++) { for (int i = 0; i < interscene_ref_disparity.length; i++) {
...@@ -897,7 +972,15 @@ public class StructureFromMotion { ...@@ -897,7 +972,15 @@ public class StructureFromMotion {
if (interscene_ref_disparity == null) { if (interscene_ref_disparity == null) {
interscene_ref_disparity =ref_scene.getDLS()[use_lma_dsi?1:0]; interscene_ref_disparity =ref_scene.getDLS()[use_lma_dsi?1:0];
} }
final double [] ref_disparity = interscene_ref_disparity; boolean filter_ref = filter_nan || (max_dip > 0) || (max_bump > 0);
final double [] ref_disparity = filter_ref ?
filterRefDisparity(
interscene_ref_disparity, // final double [] disp_in,
max_dip, // final double max_dip,
max_bump, // final double max_bump,
filter_nan, // final boolean filter_nan,
tilesX ): // final int tilesX)
interscene_ref_disparity.clone();
double [][] disp_adj = (show_disp_seq || save_disp_seq)? (new double [num_readjust+2][]):null; double [][] disp_adj = (show_disp_seq || save_disp_seq)? (new double [num_readjust+2][]):null;
if (disp_adj != null) { if (disp_adj != null) {
disp_adj[0] = ref_disparity.clone(); disp_adj[0] = ref_disparity.clone();
...@@ -1076,22 +1159,26 @@ public class StructureFromMotion { ...@@ -1076,22 +1159,26 @@ public class StructureFromMotion {
if (sfmCorrCombo[nTile].corr_ind == null) { if (sfmCorrCombo[nTile].corr_ind == null) {
sfmCorrCombo[nTile].corr_ind= new double[2]; sfmCorrCombo[nTile].corr_ind= new double[2];
} }
sfmCorrCombo[nTile].corr_ind[0]+= sfmCorr[nTile].corr_ind[0] * sfmCorr[nTile].sfm_gain; if (!Double.isNaN(sfmCorr[nTile].corr_ind[0]) && (sfmCorr[nTile].corr_ind[1] > 0)) {
sfmCorrCombo[nTile].corr_ind[1]+= sfmCorr[nTile].corr_ind[1] * sfmCorr[nTile].sfm_gain; sfmCorrCombo[nTile].corr_ind[0]+= sfmCorr[nTile].corr_ind[0] * sfmCorr[nTile].sfm_gain;
sum_weights_ind[nTile]+=sfmCorr[nTile].sfm_gain; sfmCorrCombo[nTile].corr_ind[1]+= sfmCorr[nTile].corr_ind[1] * sfmCorr[nTile].sfm_gain;
if (sfmCorr[nTile].sfm_gain > sfmCorrCombo[nTile].sfm_gain) { sum_weights_ind[nTile]+=sfmCorr[nTile].sfm_gain;
sfmCorrCombo[nTile].sfm_gain = sfmCorr[nTile].sfm_gain; if (sfmCorr[nTile].sfm_gain > sfmCorrCombo[nTile].sfm_gain) {
sfmCorrCombo[nTile].sfm_gain = sfmCorr[nTile].sfm_gain;
}
} }
} }
if (sfmCorr[nTile].corr_neib != null) { if (sfmCorr[nTile].corr_neib != null) {
if (sfmCorrCombo[nTile].corr_neib == null) { if (sfmCorrCombo[nTile].corr_neib == null) {
sfmCorrCombo[nTile].corr_neib= new double[2]; sfmCorrCombo[nTile].corr_neib= new double[2];
} }
sfmCorrCombo[nTile].corr_neib[0]+= sfmCorr[nTile].corr_neib[0] * sfmCorr[nTile].sfm_gain; if (!Double.isNaN(sfmCorr[nTile].corr_neib[0]) && (sfmCorr[nTile].corr_neib[1] > 0)) {
sfmCorrCombo[nTile].corr_neib[1]+= sfmCorr[nTile].corr_neib[1] * sfmCorr[nTile].sfm_gain; sfmCorrCombo[nTile].corr_neib[0]+= sfmCorr[nTile].corr_neib[0] * sfmCorr[nTile].sfm_gain;
sum_weights_neib[nTile]+=sfmCorr[nTile].sfm_gain; sfmCorrCombo[nTile].corr_neib[1]+= sfmCorr[nTile].corr_neib[1] * sfmCorr[nTile].sfm_gain;
if (sfmCorr[nTile].sfm_gain > sfmCorrCombo[nTile].sfm_gain) { sum_weights_neib[nTile]+=sfmCorr[nTile].sfm_gain;
sfmCorrCombo[nTile].sfm_gain = sfmCorr[nTile].sfm_gain; if (sfmCorr[nTile].sfm_gain > sfmCorrCombo[nTile].sfm_gain) {
sfmCorrCombo[nTile].sfm_gain = sfmCorr[nTile].sfm_gain;
}
} }
} }
} }
......
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