Commit 8c2ea7ed authored by Andrey Filippov's avatar Andrey Filippov

debugging batch dsi

parent e12c624a
......@@ -586,6 +586,15 @@ public class CLTParameters {
public double gr_unique_tol = 0.15; // Do not re-measure correlation if target disparity differs from some previous by this
public double gr_unique_pretol = 0.5; // Larger tolerance for expanding (not refining)
public int gr_max_clust_radius = 4; // 7x7
public int gr_num_refines = 4;
public boolean gr_exp_certain = false;
public boolean gr_reduce_sngl = true;
public boolean gr_reduce_multi = true;
public boolean gr_all_last = true;
public boolean gr_nan_bg = true;
public boolean ft_mod_strength = true; // When set, multiply each tile strength by the number of selected neighbors
public boolean ft_clusterize_by_highest = true; // Clusterize using disparity horizontal maximums for fronto planes and minimums - for horizontal. False - use histograms
......@@ -1468,6 +1477,13 @@ public class CLTParameters {
properties.setProperty(prefix+"gr_fin_diff", this.gr_fin_diff +"");
properties.setProperty(prefix+"gr_unique_tol", this.gr_unique_tol +"");
properties.setProperty(prefix+"gr_unique_pretol", this.gr_unique_pretol +"");
properties.setProperty(prefix+"gr_max_clust_radius", this.gr_max_clust_radius +"");
properties.setProperty(prefix+"gr_num_refines", this.gr_num_refines +"");
properties.setProperty(prefix+"gr_exp_certain", this.gr_exp_certain +"");
properties.setProperty(prefix+"gr_reduce_sngl", this.gr_reduce_sngl +"");
properties.setProperty(prefix+"gr_reduce_multi", this.gr_reduce_multi +"");
properties.setProperty(prefix+"gr_all_last", this.gr_all_last +"");
properties.setProperty(prefix+"gr_nan_bg", this.gr_nan_bg +"");
properties.setProperty(prefix+"ft_mod_strength", this.ft_mod_strength +"");
properties.setProperty(prefix+"ft_clusterize_by_highest", this.ft_clusterize_by_highest +"");
......@@ -2298,7 +2314,13 @@ public class CLTParameters {
if (properties.getProperty(prefix+"gr_fin_diff")!=null) this.gr_fin_diff=Double.parseDouble(properties.getProperty(prefix+"gr_fin_diff"));
if (properties.getProperty(prefix+"gr_unique_tol")!=null) this.gr_unique_tol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_tol"));
if (properties.getProperty(prefix+"gr_unique_pretol")!=null) this.gr_unique_pretol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_pretol"));
if (properties.getProperty(prefix+"gr_max_clust_radius")!=null) this.gr_max_clust_radius=Integer.parseInt(properties.getProperty(prefix+"gr_max_clust_radius"));
if (properties.getProperty(prefix+"gr_num_refines")!=null) this.gr_num_refines=Integer.parseInt(properties.getProperty(prefix+"gr_num_refines"));
if (properties.getProperty(prefix+"gr_exp_certain")!=null) this.gr_exp_certain=Boolean.parseBoolean(properties.getProperty(prefix+"gr_exp_certain"));
if (properties.getProperty(prefix+"gr_reduce_sngl")!=null) this.gr_reduce_sngl=Boolean.parseBoolean(properties.getProperty(prefix+"gr_reduce_sngl"));
if (properties.getProperty(prefix+"gr_reduce_multi")!=null) this.gr_reduce_multi=Boolean.parseBoolean(properties.getProperty(prefix+"gr_reduce_multi"));
if (properties.getProperty(prefix+"gr_all_last")!=null) this.gr_all_last=Boolean.parseBoolean(properties.getProperty(prefix+"gr_all_last"));
if (properties.getProperty(prefix+"gr_nan_bg")!=null) this.gr_nan_bg=Boolean.parseBoolean(properties.getProperty(prefix+"gr_nan_bg"));
if (properties.getProperty(prefix+"ft_mod_strength")!=null) this.ft_mod_strength=Boolean.parseBoolean(properties.getProperty(prefix+"ft_mod_strength"));
if (properties.getProperty(prefix+"ft_clusterize_by_highest")!=null) this.ft_clusterize_by_highest=Boolean.parseBoolean(properties.getProperty(prefix+"ft_clusterize_by_highest"));
......@@ -2315,8 +2337,6 @@ public class CLTParameters {
if (properties.getProperty(prefix+"ft_used_companions")!=null) this.ft_used_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_companions"));
if (properties.getProperty(prefix+"ft_used_true_companions")!=null) this.ft_used_true_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_true_companions"));
if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity"));
if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm"));
if (properties.getProperty(prefix+"plFrontoTol")!=null) this.plFrontoTol=Double.parseDouble(properties.getProperty(prefix+"plFrontoTol"));
......@@ -3290,6 +3310,24 @@ public class CLTParameters {
gd.addNumericField("Do not re-measure correlation if target disparity differs from some previous less", this.gr_unique_tol, 6);
gd.addNumericField("Larger tolerance for expanding (not refining)", this.gr_unique_pretol, 6);
gd.addMessage ("--- Mukti-tile DSI expansion ---");
gd.addNumericField("Maximal cluster radius", this.gr_max_clust_radius, 0,6,"",
"2 - 3x3, 3 - 5x5, 4 - 7x7 tiles");
gd.addNumericField("Number of refines for each cluster radius", this.gr_num_refines, 0,6,"",
"Each tile will be processed until change fallls below gr_unique_tol ('Do not re-measure...' above), buit hard-limited by this value");
gd.addCheckbox ("Expand DSI over weak tiles", this.gr_exp_certain,
"Has problems (produces dips), disable");
gd.addCheckbox ("Reduce number of pairs when refining single-tile DSI", this.gr_reduce_sngl,
"Currently to 40 pairs: neigbors, squares, diameters");
gd.addCheckbox ("Reduce number of pairs when refining single-tile DSI", this.gr_reduce_multi,
"Currently to 40 pairs: neigbors, squares, diameters");
gd.addCheckbox ("Restore to all configured pairs for the last refine cycles", this.gr_all_last,
"Use configured (ImageDtt tab) pairs for the last refine cycles (both single and multi-tile");
gd.addCheckbox ("Undefine disparity for the background tiles", this.gr_nan_bg,
"Set DSI disparity to NaN for the BG tiles");
gd.addTab ("Alt CLusterize", "Alternative initial tiles clusterization");
gd.addCheckbox ("Modify cluster strengths", this.ft_mod_strength,
......@@ -4170,6 +4208,13 @@ public class CLTParameters {
this.gr_fin_diff= gd.getNextNumber();
this.gr_unique_tol= gd.getNextNumber();
this.gr_unique_pretol= gd.getNextNumber();
this.gr_max_clust_radius= (int) gd.getNextNumber();
this.gr_num_refines= (int) gd.getNextNumber();
this.gr_exp_certain= gd.getNextBoolean();
this.gr_reduce_sngl= gd.getNextBoolean();
this.gr_reduce_multi= gd.getNextBoolean();
this.gr_all_last= gd.getNextBoolean();
this.gr_nan_bg= gd.getNextBoolean();
this.ft_mod_strength= gd.getNextBoolean();
this.ft_clusterize_by_highest= gd.getNextBoolean();
......
......@@ -1019,7 +1019,7 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Include/genarate separate aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux,
"8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+
" EO+LWIR - generate a separate GT+AUX file");
gd.addCheckbox ("Additional steps to calculate Auf DSI (more than for LY adjustment)", this.clt_batch_dsi_aux_full,
gd.addCheckbox ("Additional steps to calculate Aux DSI (more than for LY adjustment)", this.clt_batch_dsi_aux_full,
"(Not yet tested)");
......
......@@ -2468,7 +2468,7 @@ public class ImageDtt extends ImageDttCPU {
}
nTile = tileY * tilesX + tileX;
if (tp_tasks[iTile].getTask() == 0) continue; // nothing to do for this tile
boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > -6);
boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > 0);
if (debugTile0) {
System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY+", iTile="+iTile+", nTile="+nTile);
}
......@@ -2517,7 +2517,9 @@ public class ImageDtt extends ImageDttCPU {
corrs[npair] , //double [] corr_tile,
npair); // int num_pair)
if (pair_width < 0.1) {
if (globalDebugLevel > 0) {
System.out.println("pair_width["+npair+"]="+pair_width);
}
} else {
weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
}
......
......@@ -15970,7 +15970,7 @@ public class ImageDttCPU {
}
}
}
boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > -6);
boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > 0);
if (debugTile0) {
System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY);
}
......@@ -16027,7 +16027,9 @@ public class ImageDttCPU {
corrs[npair] , //double [] corr_tile,
npair); // int num_pair)
if (pair_width < 0.1) {
if (globalDebugLevel > 0) {
System.out.println("pair_width["+npair+"]="+pair_width);
}
} else {
weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
}
......@@ -16884,7 +16886,7 @@ public class ImageDttCPU {
tileYC = tp_tasks[iTileC].getTileY(); // /tilesX;
tileXC = tp_tasks[iTileC].getTileX(); //nTile % tilesX;
nTileC = tileYC * tilesX + tileXC;
if ((tileXC == debug_tileX) && (tileYC == debug_tileY)) {
if ((globalDebugLevel > -2) && (tileXC == debug_tileX) && (tileYC == debug_tileY)) {
System.out.println("quadCorrTD_tilted(): tileXC="+tileXC+", tileYC="+tileYC+", iTileC="+iTileC);
}
//quadCorrTD_tilted
......@@ -16963,7 +16965,7 @@ public class ImageDttCPU {
} else {
tp_index_multi[offset_index][cindex] = iTileC;
}
if ((globalDebugLevel > 0) && (tileXC == debug_tileX) && (tileYC == debug_tileY)) {
if ((globalDebugLevel > -2) && (tileXC == debug_tileX) && (tileYC == debug_tileY)) {
System.out.println("mindx="+mindx+", cindex="+cindex+", disparity_target="+disparity_target+
", offset_index="+offset_index+", cindex="+cindex+", tileX="+tileX+", tileY="+tileY );
}
......@@ -17037,7 +17039,7 @@ public class ImageDttCPU {
globalDebugLevel);
if (globalDebugLevel > 0) {
for (TpTask tt: tp_tasks_pass) {
if ((globalDebugLevel > 0) && ((tt.getTileY() - idy) == debug_tileY) && ((tt.getTileX()-idx) == debug_tileX)) {
if ((globalDebugLevel > -2) && ((tt.getTileY() - idy) == debug_tileY) && ((tt.getTileX()-idx) == debug_tileX)) {
System.out.println(" +++ neib_index="+neib_index+" tX="+tt.getTileX()+" tY="+tt.getTileY()
+ " target_disparity="+tt.getTargetDisparity()+" idx="+idx+" idy="+idy);
}
......@@ -17064,7 +17066,7 @@ public class ImageDttCPU {
float [][] src_corrs = fcorr_td_part[tY_src][tX_src];
if (src_corrs != null) {
// TODO: finish checking correct fcorr_td_part
if ((globalDebugLevel > 0) && (tX_dst == debug_tileX) && (tY_dst == debug_tileY)) {
if ((globalDebugLevel > -2) && (tX_dst == debug_tileX) && (tY_dst == debug_tileY)) {
System.out.println("*** quadCorrTD_tilted_sum(): neib_index="+fneib_index+", tX_dst="+tX_dst+", tY_dst="+tY_dst+
", iTileC="+iTileC+", tX_src="+tX_src+", tY_src="+tY_src+", w="+w);
}
......
......@@ -8243,7 +8243,7 @@ public class QuadCLTCPU {
tp.clt_3d_passes.add(bgnd_data);
// if (show_init_refine)
// if ((debugLevel > -2) && clt_parameters.show_first_bg) {
if ((debugLevel > -3) && clt_parameters.show_first_bg) {
if ((debugLevel > -2) && clt_parameters.show_first_bg) {
tp.showScan(
tp.clt_3d_passes.get(0), // CLTPass3d scan,
"bgnd_data-"+tp.clt_3d_passes.size());
......@@ -8269,7 +8269,7 @@ public class QuadCLTCPU {
updateStatus,
debugLevel);
if (debugLevel > -3) {
if (debugLevel > -2) {
imp_bgnd_int.show(); /// OK
}
......@@ -8448,8 +8448,9 @@ public class QuadCLTCPU {
}
}
// Save pair selection and minimaize them for scanning, then restore;
// boolean reduce_pairs_multi = true;
// boolean last_iter_all = true;
// Save pair selection and minimize them for scanning, then restore;
int save_pairs_selection = clt_parameters.img_dtt.getMcorr(getNumSensors());
clt_parameters.img_dtt.setMcorr(getNumSensors(), 0 ); // remove all
clt_parameters.img_dtt.setMcorrNeib(getNumSensors(),true);
......@@ -8458,14 +8459,14 @@ public class QuadCLTCPU {
boolean save_run_lma = clt_parameters.correlate_lma;
clt_parameters.correlate_lma = false;
int num_macro_refine = 3;
// int num_macro_refine = 3;
int dbg_num_new = 0;
for (CLTPass3d from_macro_pass: new_meas) {
if (debugLevel > -2) {
System.out.println("Next from new_meas: "+dbg_num_new);
}
dbg_num_new++;
for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
for (int nnn = 0; nnn < clt_parameters.gr_num_refines; nnn ++){ //
refine_pass = tp.clt_3d_passes.size(); // 1
CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
// final double [][][] image_data, // first index - number of image in a quad
......@@ -8516,6 +8517,7 @@ public class QuadCLTCPU {
"after_refinePassSetup-"+tp.clt_3d_passes.size());
// Just debugging
/*
if (clt_parameters.gpu_debug_accum) { //
CLTMeasureCorrTesting( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
......@@ -8533,9 +8535,11 @@ public class QuadCLTCPU {
updateStatus,
debugLevel);
}
*/
// End of just debugging
// will split old/new
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
// CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
// CLTMeasCorr(
clt_parameters,
refine_pass,
......@@ -8551,7 +8555,7 @@ public class QuadCLTCPU {
if (show_init_refine) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_measure-"+tp.clt_3d_passes.size());
if (nnn < (num_macro_refine-1)) { // all but last
if (nnn < (clt_parameters.gr_num_refines-1)) { // all but last
// if (clt_parameters.combine_refine){
CLTPass3d combo_pass = tp.compositeScan(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
......@@ -8583,7 +8587,8 @@ public class QuadCLTCPU {
}
// add new scan from macro
tp.clt_3d_passes.add(from_macro_pass);
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
// CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
// image_data, // first index - number of image in a quad
// saturation_imp, //final boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
......@@ -8602,17 +8607,22 @@ public class QuadCLTCPU {
}
// Restore pair selection and minimize them for scanning, then restore;
if (!clt_parameters.gr_reduce_sngl) {
clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
}
clt_parameters.correlate_lma = save_run_lma; // restore
/// Refining after all added
if (debugLevel > -1){
if (debugLevel > -3){
System.out.println("---- Refining after all added ----");
}
// find out - why first pass corresponds to last scan step?
// first ("before_makeUnique-41-" was empty)
for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
for (int nnn = 0; nnn < clt_parameters.gr_num_refines; nnn ++){ //
if ((nnn == (clt_parameters.gr_num_refines - 1)) && clt_parameters.gr_all_last) {
clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
}
refine_pass = tp.clt_3d_passes.size(); // 1
CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
// final double [][][] image_data, // first index - number of image in a quad
......@@ -8666,7 +8676,8 @@ public class QuadCLTCPU {
// first time - last scan step????
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
// CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
// image_data, // first index - number of image in a quad
// saturation_imp, //final boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
......@@ -8704,16 +8715,23 @@ public class QuadCLTCPU {
tp.clt_3d_passes.add(combo_pass);
}
// create and measure several variable-cluster scans from the same single-tile combo_pass
CLTPass3d combo_pass = tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1); // last pass created by tp.compositeScan
int max_clust_radius = 4; // 7x7
CLTPass3d [] combo_multi = new CLTPass3d[max_clust_radius+1];
// int max_clust_radius = 4; // 7x7
CLTPass3d [] combo_multi = new CLTPass3d[clt_parameters.gr_max_clust_radius+1];
combo_multi[0] = combo_pass;
int max_expand_radius = 0; // max_clust_radius;
for (int clust_radius = 2; clust_radius <= max_clust_radius; clust_radius++) {
for (int clust_radius = 2; clust_radius <= clt_parameters.gr_max_clust_radius; clust_radius++) {
// for (int clust_radius = 4; clust_radius <= max_clust_radius; clust_radius++) { // just for faster testing
if (clt_parameters.gr_reduce_multi) {
clt_parameters.img_dtt.setMcorr(getNumSensors(), 0 ); // remove all
clt_parameters.img_dtt.setMcorrNeib(getNumSensors(),true);
clt_parameters.img_dtt.setMcorrSq (getNumSensors(),true); // remove even more?
clt_parameters.img_dtt.setMcorrDia (getNumSensors(),true); // remove even more?
}
// using combo_pass (latest)
int num_added = 0;
if (clust_radius < max_expand_radius) {
......@@ -8734,8 +8752,10 @@ public class QuadCLTCPU {
System.out.println("Added "+num_added+" tiles before cluster radius "+clust_radius);
boolean [] has_lma = combo_pass.getLMA();
double [] disparity = combo_pass.getDisparity(1); // calc_disparity (skip NaN!)
for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
for (int nnn = 0; nnn < clt_parameters.gr_num_refines; nnn ++){ //
if ((nnn == (clt_parameters.gr_num_refines - 1)) && clt_parameters.gr_all_last) {
clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
}
refine_pass = tp.clt_3d_passes.size();
CLTPass3d refined_multi = tp.refinePassSetupMulti( // prepare tile tasks for the second pass based on the previous one(s)
combo_pass, // CLTPass3d combo_pass,
......@@ -8776,8 +8796,8 @@ public class QuadCLTCPU {
// double [] saved_target_disparity = tp.clt_3d_passes.get(refine_pass).getDA(); // TODO: remove when done
// for (int ii = 0; ii < rpt; ii++) { // TODO: remove when done
// tp.clt_3d_passes.get(refine_pass).setDA(saved_target_disparity); // TODO: remove when done
boolean alt_clt = true;
if (alt_clt) {
/// boolean alt_clt = true;
/// if (alt_clt) {
CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
refine_pass,
......@@ -8786,16 +8806,16 @@ public class QuadCLTCPU {
threadsMax,
updateStatus,
debugLevel);
} else {
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
refine_pass,
false, // true, // final boolean save_textures,
clust_radius, // final int clust_radius,
threadsMax,
updateStatus,
debugLevel);
}
/// } else {
/// CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
/// clt_parameters,
/// refine_pass,
/// false, // true, // final boolean save_textures,
/// clust_radius, // final int clust_radius,
/// threadsMax,
/// updateStatus,
/// debugLevel);
/// }
if (show_init_refine) tp.showScan(
......@@ -8839,6 +8859,18 @@ public class QuadCLTCPU {
}
}
// Restore pairs selection
clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
if (clt_parameters.gr_nan_bg) {
if (debugLevel > -3) {
tp.showScan(
tp.clt_3d_passes.get(bg_pass), // CLTPass3d scan,
"bg_passs-"+tp.clt_3d_passes.size());
}
}
if (clt_parameters.gr_exp_certain) {
int num_added = tp.expandCertainMulti (
combo_pass, // CLTPass3d combo_pass, // modify
tp.clt_3d_passes, //ArrayList <CLTPass3d> passes,
......@@ -8856,7 +8888,7 @@ public class QuadCLTCPU {
if (debugLevel > -2) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_multi-tile_disparity_extension");
}
///// Refining after all added - end
Runtime.getRuntime().gc();
......@@ -12175,6 +12207,7 @@ public class QuadCLTCPU {
}
}
@Deprecated
public CLTPass3d CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
CLTParameters clt_parameters,
final int scanIndex,
......
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