Commit 89fbf5c2 authored by Andrey Filippov's avatar Andrey Filippov

cleaning up, adding parameters for different debug modes

parent decd04ed
...@@ -266,24 +266,28 @@ public class IntersceneLma { ...@@ -266,24 +266,28 @@ public class IntersceneLma {
} }
if (rslt[0]) { // better if (rslt[0]) { // better
if (iter >= num_iter) { // better, but num tries exceeded if (iter >= num_iter) { // better, but num tries exceeded
if (debug_level > 0) System.out.println("Step "+iter+": Improved, but number of steps exceeded maximal"); if (debug_level > 1) System.out.println("Step "+iter+": Improved, but number of steps exceeded maximal");
} else { } else {
if (debug_level > 0) System.out.println("Step "+iter+": LMA: Success"); if (debug_level > 1) System.out.println("Step "+iter+": LMA: Success");
} }
} else { // improved over initial ? } else { // improved over initial ?
if (last_rms[0] < initial_rms[0]) { // NaN if (last_rms[0] < initial_rms[0]) { // NaN
rslt[0] = true; rslt[0] = true;
if (debug_level > 0) System.out.println("Step "+iter+": Failed to converge, but result improved over initial"); if (debug_level > 1) System.out.println("Step "+iter+": Failed to converge, but result improved over initial");
} else { } else {
if (debug_level > 0) System.out.println("Step "+iter+": Failed to converge"); if (debug_level > 1) System.out.println("Step "+iter+": Failed to converge");
} }
} }
if (debug_level > 0) { boolean show_intermediate = true;
if (show_intermediate && (debug_level > 0)) {
System.out.println("LMA: full RMS="+last_rms[0]+" ("+initial_rms[0]+"), pure RMS="+last_rms[1]+" ("+initial_rms[1]+") + lambda="+lambda); System.out.println("LMA: full RMS="+last_rms[0]+" ("+initial_rms[0]+"), pure RMS="+last_rms[1]+" ("+initial_rms[1]+") + lambda="+lambda);
} }
if (debug_level > 0) { if (debug_level > 0) {
if ((debug_level > 1) || (iter == 1) || last_run) { if ((debug_level > 1) || (iter == 1) || last_run) {
if (!show_intermediate) {
System.out.println("LMA: full RMS="+last_rms[0]+" ("+initial_rms[0]+"), pure RMS="+last_rms[1]+" ("+initial_rms[1]+") + lambda="+lambda);
}
String [] lines = printOldNew(false); // boolean allvectors) String [] lines = printOldNew(false); // boolean allvectors)
for (String line : lines) { for (String line : lines) {
System.out.println(line); System.out.println(line);
......
...@@ -43,6 +43,8 @@ public class IntersceneLmaParameters { ...@@ -43,6 +43,8 @@ public class IntersceneLmaParameters {
public int ilma_num_iter = 20; public int ilma_num_iter = 20;
public int ilma_num_corr = 10; // maximal number of full correlation+LMA cycles public int ilma_num_corr = 10; // maximal number of full correlation+LMA cycles
public int ilma_debug_level = 1; public int ilma_debug_level = 1;
public boolean ilma_debug_adjust_series = false; // Debug images for series of pose and ers
public boolean ilma_debug_invariant = false; // Monitoring variations when restarting program (should be ilma_thread_invariant=true)
public IntersceneLmaParameters() { public IntersceneLmaParameters() {
ilma_lma_select[ErsCorrection.DP_DVAZ]= true; ilma_lma_select[ErsCorrection.DP_DVAZ]= true;
...@@ -133,11 +135,14 @@ public class IntersceneLmaParameters { ...@@ -133,11 +135,14 @@ public class IntersceneLmaParameters {
"A hard limit on LMA iterations."); "A hard limit on LMA iterations.");
gd.addNumericField("Maximal number of correlation +LMA iterations",this.ilma_num_corr, 0,3,"", gd.addNumericField("Maximal number of correlation +LMA iterations",this.ilma_num_corr, 0,3,"",
"Outer cycle (recalculate correlations + lma). Otherwise exits if LMA exits at first iteration."); "Outer cycle (recalculate correlations + lma). Otherwise exits if LMA exits at first iteration.");
gd.addCheckbox ("Debug adjust_series()", this.ilma_debug_adjust_series,
"Generate debug images for series of pose and ERS (derivatives of pose)" );
gd.addCheckbox ("Debug thread-invariant", this.ilma_debug_invariant,
"Generate debug images and text output to verify same results regardless of threads" );
gd.addNumericField("Debug level", this.ilma_debug_level, 0,3,"", gd.addNumericField("Debug level", this.ilma_debug_level, 0,3,"",
"Debug level of interscene LMA operation."); "Debug level of interscene LMA operation.");
} }
public void dialogAnswers(GenericJTabbedDialog gd) { public void dialogAnswers(GenericJTabbedDialog gd) {
this.ilma_thread_invariant = gd.getNextBoolean(); this.ilma_thread_invariant = gd.getNextBoolean();
for (int i = ErsCorrection.DP_DVAZ; i < ErsCorrection.DP_NUM_PARS; i++) { for (int i = ErsCorrection.DP_DVAZ; i < ErsCorrection.DP_NUM_PARS; i++) {
...@@ -156,6 +161,8 @@ public class IntersceneLmaParameters { ...@@ -156,6 +161,8 @@ public class IntersceneLmaParameters {
this.ilma_rms_diff = gd.getNextNumber(); this.ilma_rms_diff = gd.getNextNumber();
this.ilma_num_iter = (int) gd.getNextNumber(); this.ilma_num_iter = (int) gd.getNextNumber();
this.ilma_num_corr = (int) gd.getNextNumber(); this.ilma_num_corr = (int) gd.getNextNumber();
this.ilma_debug_adjust_series = gd.getNextBoolean();
this.ilma_debug_invariant = gd.getNextBoolean();
this.ilma_debug_level = (int) gd.getNextNumber(); this.ilma_debug_level = (int) gd.getNextNumber();
} }
public void setProperties(String prefix,Properties properties){ public void setProperties(String prefix,Properties properties){
...@@ -174,6 +181,8 @@ public class IntersceneLmaParameters { ...@@ -174,6 +181,8 @@ public class IntersceneLmaParameters {
properties.setProperty(prefix+"ilma_rms_diff", this.ilma_rms_diff+""); properties.setProperty(prefix+"ilma_rms_diff", this.ilma_rms_diff+"");
properties.setProperty(prefix+"ilma_num_iter", this.ilma_num_iter+""); properties.setProperty(prefix+"ilma_num_iter", this.ilma_num_iter+"");
properties.setProperty(prefix+"ilma_num_corr", this.ilma_num_corr+""); properties.setProperty(prefix+"ilma_num_corr", this.ilma_num_corr+"");
properties.setProperty(prefix+"ilma_debug_adjust_series",this.ilma_debug_adjust_series+"");
properties.setProperty(prefix+"ilma_debug_invariant", this.ilma_debug_invariant+"");
properties.setProperty(prefix+"ilma_debug_level", this.ilma_debug_level+""); properties.setProperty(prefix+"ilma_debug_level", this.ilma_debug_level+"");
} }
public void getProperties(String prefix,Properties properties){ public void getProperties(String prefix,Properties properties){
...@@ -184,7 +193,6 @@ public class IntersceneLmaParameters { ...@@ -184,7 +193,6 @@ public class IntersceneLmaParameters {
pn_sel = prefix+ErsCorrection.DP_DERIV_NAMES[i]+"_regweight"; pn_sel = prefix+ErsCorrection.DP_DERIV_NAMES[i]+"_regweight";
if (properties.getProperty(pn_sel)!=null) this.ilma_regularization_weights[i]=Double.parseDouble(properties.getProperty(pn_sel)); if (properties.getProperty(pn_sel)!=null) this.ilma_regularization_weights[i]=Double.parseDouble(properties.getProperty(pn_sel));
} }
if (properties.getProperty(prefix+"ilma_ignore_ers")!=null) this.ilma_ignore_ers=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_ignore_ers")); if (properties.getProperty(prefix+"ilma_ignore_ers")!=null) this.ilma_ignore_ers=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_ignore_ers"));
if (properties.getProperty(prefix+"ilma_ers_adj_lin")!=null) this.ilma_ers_adj_lin=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_ers_adj_lin")); if (properties.getProperty(prefix+"ilma_ers_adj_lin")!=null) this.ilma_ers_adj_lin=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_ers_adj_lin"));
if (properties.getProperty(prefix+"ilma_ers_adj_ang")!=null) this.ilma_ers_adj_ang=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_ers_adj_ang")); if (properties.getProperty(prefix+"ilma_ers_adj_ang")!=null) this.ilma_ers_adj_ang=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_ers_adj_ang"));
...@@ -195,6 +203,8 @@ public class IntersceneLmaParameters { ...@@ -195,6 +203,8 @@ public class IntersceneLmaParameters {
if (properties.getProperty(prefix+"ilma_rms_diff")!=null) this.ilma_rms_diff=Double.parseDouble(properties.getProperty(prefix+"ilma_rms_diff")); if (properties.getProperty(prefix+"ilma_rms_diff")!=null) this.ilma_rms_diff=Double.parseDouble(properties.getProperty(prefix+"ilma_rms_diff"));
if (properties.getProperty(prefix+"ilma_num_iter")!=null) this.ilma_num_iter=Integer.parseInt(properties.getProperty(prefix+"ilma_num_iter")); if (properties.getProperty(prefix+"ilma_num_iter")!=null) this.ilma_num_iter=Integer.parseInt(properties.getProperty(prefix+"ilma_num_iter"));
if (properties.getProperty(prefix+"ilma_num_corr")!=null) this.ilma_num_corr=Integer.parseInt(properties.getProperty(prefix+"ilma_num_corr")); if (properties.getProperty(prefix+"ilma_num_corr")!=null) this.ilma_num_corr=Integer.parseInt(properties.getProperty(prefix+"ilma_num_corr"));
if (properties.getProperty(prefix+"ilma_debug_adjust_series")!=null)this.ilma_debug_adjust_series=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_debug_adjust_series"));
if (properties.getProperty(prefix+"ilma_debug_invariant")!=null) this.ilma_debug_invariant=Boolean.parseBoolean(properties.getProperty(prefix+"ilma_debug_invariant"));
if (properties.getProperty(prefix+"ilma_debug_level")!=null) this.ilma_debug_level=Integer.parseInt(properties.getProperty(prefix+"ilma_debug_level")); if (properties.getProperty(prefix+"ilma_debug_level")!=null) this.ilma_debug_level=Integer.parseInt(properties.getProperty(prefix+"ilma_debug_level"));
} }
...@@ -214,6 +224,8 @@ public class IntersceneLmaParameters { ...@@ -214,6 +224,8 @@ public class IntersceneLmaParameters {
ilp.ilma_rms_diff = this.ilma_rms_diff; ilp.ilma_rms_diff = this.ilma_rms_diff;
ilp.ilma_num_iter = this.ilma_num_iter; ilp.ilma_num_iter = this.ilma_num_iter;
ilp.ilma_num_corr = this.ilma_num_corr; ilp.ilma_num_corr = this.ilma_num_corr;
ilp.ilma_debug_adjust_series = this.ilma_debug_adjust_series;
ilp.ilma_debug_invariant = this.ilma_debug_invariant;
ilp.ilma_debug_level = this.ilma_debug_level; ilp.ilma_debug_level = this.ilma_debug_level;
return ilp; return ilp;
} }
......
...@@ -581,7 +581,7 @@ public class OpticalFlow { ...@@ -581,7 +581,7 @@ public class OpticalFlow {
final int debug_level, //1 final int debug_level, //1
final boolean enable_debug_images) // true final boolean enable_debug_images) // true
{ {
boolean debug_mismatch = (debug_level > -10); // true; boolean debug_mismatch = (debug_level > -10); // && enable_debug_images);
// int debug_corr2d = 0;// 10 // int debug_corr2d = 0;// 10
final TileProcessor tp = reference_QuadClt.getTileProcessor(); final TileProcessor tp = reference_QuadClt.getTileProcessor();
...@@ -3602,8 +3602,7 @@ public class OpticalFlow { ...@@ -3602,8 +3602,7 @@ public class OpticalFlow {
int debug_level int debug_level
) )
{ {
boolean show_results = true; boolean show_results = clt_parameters.ilp.ilma_debug_adjust_series;
if (ref_index < 0) { if (ref_index < 0) {
ref_index += scenes.length; ref_index += scenes.length;
} }
...@@ -8428,6 +8427,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -8428,6 +8427,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
double [][] flowXY = new double [macroTiles][2]; // zero pre-shifts double [][] flowXY = new double [macroTiles][2]; // zero pre-shifts
// double [][] flowXY_frac = new double [macroTiles][]; // Will contain fractional X/Y shift for CLT // double [][] flowXY_frac = new double [macroTiles][]; // Will contain fractional X/Y shift for CLT
double [][] reference_tiles_macro = new double [macroTiles][]; double [][] reference_tiles_macro = new double [macroTiles][];
// hack below to pass nlma for debugging. Change clt_parameters.ilp.ilma_num_corr to -11 after first pass
int test_debug_level = clt_parameters.ilp.ilma_debug_invariant? (clt_parameters.ofp.debug_level_iterate-nlma): -11;
double [][] vector_XYS = correlate2DIterate( // returns optical flow and confidence double [][] vector_XYS = correlate2DIterate( // returns optical flow and confidence
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params,
// for prepareSceneTiles() // for prepareSceneTiles()
...@@ -8460,7 +8461,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -8460,7 +8461,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
clt_parameters.ofp.min_change, // final double min_change, clt_parameters.ofp.min_change, // final double min_change,
clt_parameters.ofp.best_neibs_num, // final int best_num, clt_parameters.ofp.best_neibs_num, // final int best_num,
clt_parameters.ofp.ref_stdev, // final double ref_stdev, clt_parameters.ofp.ref_stdev, // final double ref_stdev,
clt_parameters.ofp.debug_level_iterate-nlma, // final int debug_level) test_debug_level, // clt_parameters.ofp.debug_level_iterate-nlma, // final int debug_level)
clt_parameters.ofp.enable_debug_images); //final boolean enable_debug_images) clt_parameters.ofp.enable_debug_images); //final boolean enable_debug_images)
if (dbg_img != null) { if (dbg_img != null) {
for (int iy = 0; iy < macroTilesY; iy++) { for (int iy = 0; iy < macroTilesY; iy++) {
...@@ -8505,7 +8506,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -8505,7 +8506,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
} }
} }
if (dbg_img != null) { if (clt_parameters.ilp.ilma_debug_invariant) { // dbg_img != null) {
/* /*
long [] long_xyz0 = new long [camera_xyz0.length]; long [] long_xyz0 = new long [camera_xyz0.length];
long [] long_atr0 = new long [camera_atr0.length]; long [] long_atr0 = new long [camera_atr0.length];
......
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