Commit dbd2a71c authored by Andrey Filippov's avatar Andrey Filippov

Fixing batch mode with new features

parent c0c2cd6a
...@@ -225,6 +225,66 @@ public class BiCamDSI { ...@@ -225,6 +225,66 @@ public class BiCamDSI {
return selection; return selection;
} }
/**
* Select small/thin near objects over infinity
* @param min_strength minimal strength of the tile and neighbors
* @param min_neibs minimal number of neighbors with close disparity
* @param min_disparity minimal disaparity
* @param disp_atolerance disparity absolute tolerance (to qualify for a similar neighbor)
* @param disp_rtolerance disparity relative tolerance (adds to absolute)
* @param infinity_select tile, previously assigned to infinity (or null)
* @param selection existing selection (to add to) or null
* @param disparity array of tile disparity values (may have NaN-s)
* @param strength array of tile strength values
* @return new selection (new or added to existing)
*/
public boolean [] selectNearOverInfinity(
double min_strength,
int min_neibs,
double min_disparity,
double disp_atolerance,
double disp_rtolerance,
boolean [] infinity_select,
boolean [] selection,
double [] disparity,
double [] strength) {
int num_tiles = disparity.length;
if (infinity_select == null) {
infinity_select = new boolean [num_tiles];
for (int nTile = 0; nTile < num_tiles; nTile++) infinity_select[nTile] = true;
}
if (selection == null) selection = new boolean [num_tiles];
boolean [] new_sel = selection.clone();
//tnImage
for (int nTile =0; nTile <num_tiles; nTile++)
if ( infinity_select[nTile] &&
!selection[nTile] &&
(strength[nTile] >= min_strength ) &&
(disparity[nTile] >= min_disparity)){
int nn = 0;
double tolerance = disp_atolerance + disparity[nTile] * disp_rtolerance;
double min_d = Math.max(disparity[nTile] - tolerance, min_disparity);
double max_d = disparity[nTile] + tolerance;
for (int dir = 0; dir < 8; dir++) {
int nTile1 = tnImage.getNeibIndex(nTile, dir);
if ( (nTile1 >=0) &&
((strength [nTile1] >= min_strength ) || selection[nTile1]) && // strong or already selected
(disparity[nTile1] >= min_d) &&
(disparity[nTile1] <= max_d)){
nn++;
/// if (selection[nTile]) nn++; // count selected as 2 ?
}
}
if (nn >= min_neibs) {
new_sel[nTile] = true;
}
}
for (int nTile =0; nTile <num_tiles; nTile++) {
selection[nTile] |= new_sel[nTile];
}
return selection;
}
/** /**
* Select far tiles (even lone) over infinity areas that have sufficient disparity and strength * Select far tiles (even lone) over infinity areas that have sufficient disparity and strength
* @param min_far_strength minimal tile strength (may be 0 as the tiles are already filtered) * @param min_far_strength minimal tile strength (may be 0 as the tiles are already filtered)
......
...@@ -211,6 +211,15 @@ public class BiQuadParameters { ...@@ -211,6 +211,15 @@ public class BiQuadParameters {
public double ltfar_trusted_s = 0.4; // Add even single tiles over infinity if strength (and disparity too) is sufficient public double ltfar_trusted_s = 0.4; // Add even single tiles over infinity if strength (and disparity too) is sufficient
public double ltfar_trusted_d = 0.2; // Add even single tiles over infinity if disparity (and strength too) is sufficient public double ltfar_trusted_d = 0.2; // Add even single tiles over infinity if disparity (and strength too) is sufficient
// Parameters to select near (too near to be processed as poles) objects over infinity background
public double ltgrp_min_strength = 0.2; // Minimal strength of the tile and neighbors
public int ltgrp_min_neibs = 2; // minimal number of neighbors with close disparity
public double ltgrp_gr_min_disparity = 0.5; // Minimal group disparity
public double ltgrp_gr_disp_atolerance = 0.2; // Group disparity absolute tolerance (to qualify for a similar neighbor)
public double ltgrp_gr_disp_rtolerance = 0.1; // Group disparity relative tolerance (adds to absolute)
// rig selection filtering // rig selection filtering
...@@ -581,10 +590,22 @@ public class BiQuadParameters { ...@@ -581,10 +590,22 @@ public class BiQuadParameters {
gd.addMessage("Filtering selection of non-infinity tiles"); gd.addMessage("Filtering selection of non-infinity tiles");
gd.addNumericField("Add even single tiles over infinity if STRENGTH (and disparity too) is sufficient", this.ltfar_trusted_s, 4,6,"", gd.addNumericField("Add even single tiles over infinity if STRENGTH (and disparity too) is sufficient", this.ltfar_trusted_s, 4,6,"",
"Add strong tiles over infinity areas that have both strenth and disparity above respective thersholds (re-add them after filtering)"); "Add strong tiles over infinity areas that have both strenth and disparity above respective thresholds (re-add them after filtering)");
gd.addNumericField("Add even single tiles over infinity if DISPARITY (and strength too) is sufficient", this.ltfar_trusted_d, 4,6,"pix", gd.addNumericField("Add even single tiles over infinity if DISPARITY (and strength too) is sufficient", this.ltfar_trusted_d, 4,6,"pix",
"Add strong tiles over infinity areas that have both strenth and disparity above respective thersholds (re-add them after filtering)"); "Add strong tiles over infinity areas that have both strenth and disparity above respective thresholds (re-add them after filtering)");
gd.addMessage("Parameters to select near (too near to be processed as poles) objects over infinity background");
gd.addNumericField("Minimal strength of the tile and neighbors", this.ltgrp_min_strength, 4,6,"",
"Tile will be added to selection if the tile over infinity selection is strong enough and has several neighbors (of 8) with similar disparity and also strong");
gd.addNumericField("Minimal number of neighbors with close disparity", this.ltgrp_min_neibs, 0,3,"tiles",
"For thin objects (poles, wires) there may be just 2 neighbors");
gd.addNumericField("Minimal group disparity", this.ltgrp_gr_min_disparity, 4,6,"pix",
"Only process tiles that are close enough (and their qualifying neighbors too)");
gd.addNumericField("Group disparity absolute tolerance (to qualify for a similar neighbor)", this.ltgrp_gr_disp_atolerance, 4,6,"pix",
"Neighbors should have disparity different by not more than this");
gd.addNumericField("Group disparity relative tolerance", this.ltgrp_gr_disp_rtolerance, 4,6,"pix/pix",
"Increase disparity tolerance by this for each absolute disparity pixel");
gd.addTab("Rig selection","Rig tile selection filter"); gd.addTab("Rig selection","Rig tile selection filter");
...@@ -814,6 +835,13 @@ public class BiQuadParameters { ...@@ -814,6 +835,13 @@ public class BiQuadParameters {
this.ltfar_trusted_s= gd.getNextNumber(); this.ltfar_trusted_s= gd.getNextNumber();
this.ltfar_trusted_d= gd.getNextNumber(); this.ltfar_trusted_d= gd.getNextNumber();
this.ltgrp_min_strength= gd.getNextNumber();
this.ltgrp_min_neibs= (int) gd.getNextNumber();
this.ltgrp_gr_min_disparity= gd.getNextNumber();
this.ltgrp_gr_disp_atolerance= gd.getNextNumber();
this.ltgrp_gr_disp_rtolerance= gd.getNextNumber();
this.rf_master_infinity= gd.getNextBoolean(); this.rf_master_infinity= gd.getNextBoolean();
this.rf_master_near= gd.getNextBoolean(); this.rf_master_near= gd.getNextBoolean();
this.rf_pre_expand= (int) gd.getNextNumber(); this.rf_pre_expand= (int) gd.getNextNumber();
...@@ -1013,6 +1041,13 @@ public class BiQuadParameters { ...@@ -1013,6 +1041,13 @@ public class BiQuadParameters {
properties.setProperty(prefix+"ltfar_trusted_s", this.ltfar_trusted_s+""); properties.setProperty(prefix+"ltfar_trusted_s", this.ltfar_trusted_s+"");
properties.setProperty(prefix+"ltfar_trusted_d", this.ltfar_trusted_d+""); properties.setProperty(prefix+"ltfar_trusted_d", this.ltfar_trusted_d+"");
properties.setProperty(prefix+"ltgrp_min_strength", this.ltgrp_min_strength+"");
properties.setProperty(prefix+"ltgrp_min_neibs", this.ltgrp_min_neibs+"");
properties.setProperty(prefix+"ltgrp_gr_min_disparity", this.ltgrp_gr_min_disparity+"");
properties.setProperty(prefix+"ltgrp_gr_disp_atolerance", this.ltgrp_gr_disp_atolerance+"");
properties.setProperty(prefix+"ltgrp_gr_disp_rtolerance", this.ltgrp_gr_disp_rtolerance+"");
properties.setProperty(prefix+"rf_master_infinity", this.rf_master_infinity+""); properties.setProperty(prefix+"rf_master_infinity", this.rf_master_infinity+"");
properties.setProperty(prefix+"rf_master_near", this.rf_master_near+""); properties.setProperty(prefix+"rf_master_near", this.rf_master_near+"");
properties.setProperty(prefix+"rf_pre_expand", this.rf_pre_expand+""); properties.setProperty(prefix+"rf_pre_expand", this.rf_pre_expand+"");
...@@ -1210,6 +1245,12 @@ public class BiQuadParameters { ...@@ -1210,6 +1245,12 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"ltfar_trusted_s")!=null) this.ltfar_trusted_s=Double.parseDouble(properties.getProperty(prefix+"ltfar_trusted_s")); if (properties.getProperty(prefix+"ltfar_trusted_s")!=null) this.ltfar_trusted_s=Double.parseDouble(properties.getProperty(prefix+"ltfar_trusted_s"));
if (properties.getProperty(prefix+"ltfar_trusted_d")!=null) this.ltfar_trusted_d=Double.parseDouble(properties.getProperty(prefix+"ltfar_trusted_d")); if (properties.getProperty(prefix+"ltfar_trusted_d")!=null) this.ltfar_trusted_d=Double.parseDouble(properties.getProperty(prefix+"ltfar_trusted_d"));
if (properties.getProperty(prefix+"ltgrp_min_strength")!=null) this.ltgrp_min_strength=Double.parseDouble(properties.getProperty(prefix+"ltgrp_min_strength"));
if (properties.getProperty(prefix+"ltgrp_min_neibs")!=null) this.ltgrp_min_neibs=Integer.parseInt(properties.getProperty(prefix+"ltgrp_min_neibs"));
if (properties.getProperty(prefix+"ltgrp_gr_min_disparity")!=null) this.ltgrp_gr_min_disparity=Double.parseDouble(properties.getProperty(prefix+"ltgrp_gr_min_disparity"));
if (properties.getProperty(prefix+"ltgrp_gr_disp_atolerance")!=null)this.ltgrp_gr_disp_atolerance=Double.parseDouble(properties.getProperty(prefix+"ltgrp_gr_disp_atolerance"));
if (properties.getProperty(prefix+"ltgrp_gr_disp_rtolerance")!=null)this.ltgrp_gr_disp_rtolerance=Double.parseDouble(properties.getProperty(prefix+"ltgrp_gr_disp_rtolerance"));
if (properties.getProperty(prefix+"rf_master_infinity")!=null) this.rf_master_infinity=Boolean.parseBoolean(properties.getProperty(prefix+"rf_master_infinity")); if (properties.getProperty(prefix+"rf_master_infinity")!=null) this.rf_master_infinity=Boolean.parseBoolean(properties.getProperty(prefix+"rf_master_infinity"));
if (properties.getProperty(prefix+"rf_master_near")!=null) this.rf_master_near=Boolean.parseBoolean(properties.getProperty(prefix+"rf_master_near")); if (properties.getProperty(prefix+"rf_master_near")!=null) this.rf_master_near=Boolean.parseBoolean(properties.getProperty(prefix+"rf_master_near"));
if (properties.getProperty(prefix+"rf_pre_expand")!=null) this.rf_pre_expand=Integer.parseInt(properties.getProperty(prefix+"rf_pre_expand")); if (properties.getProperty(prefix+"rf_pre_expand")!=null) this.rf_pre_expand=Integer.parseInt(properties.getProperty(prefix+"rf_pre_expand"));
...@@ -1408,6 +1449,12 @@ public class BiQuadParameters { ...@@ -1408,6 +1449,12 @@ public class BiQuadParameters {
bqp.ltfar_trusted_s= this.ltfar_trusted_s; bqp.ltfar_trusted_s= this.ltfar_trusted_s;
bqp.ltfar_trusted_d= this.ltfar_trusted_d; bqp.ltfar_trusted_d= this.ltfar_trusted_d;
bqp.ltgrp_min_strength = this.ltgrp_min_strength;
bqp.ltgrp_min_neibs = this.ltgrp_min_neibs;
bqp.ltgrp_gr_min_disparity = this.ltgrp_gr_min_disparity;
bqp.ltgrp_gr_disp_atolerance = this.ltgrp_gr_disp_atolerance;
bqp.ltgrp_gr_disp_rtolerance = this.ltgrp_gr_disp_rtolerance;
bqp.rf_master_infinity= this.rf_master_infinity; bqp.rf_master_infinity= this.rf_master_infinity;
bqp.rf_master_near= this.rf_master_near; bqp.rf_master_near= this.rf_master_near;
bqp.rf_pre_expand= this.rf_pre_expand; bqp.rf_pre_expand= this.rf_pre_expand;
......
...@@ -135,6 +135,12 @@ public class EyesisCorrectionParameters { ...@@ -135,6 +135,12 @@ public class EyesisCorrectionParameters {
public boolean clt_batch_assign = true; // Assign tiles to surfaces public boolean clt_batch_assign = true; // Assign tiles to surfaces
public boolean clt_batch_gen3d = true; // Generate 3d output: x3d and/or obj+mtl public boolean clt_batch_gen3d = true; // Generate 3d output: x3d and/or obj+mtl
public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected
public boolean clt_batch_dsi = true; // Create and save DSI combo image with the model
public boolean clt_batch_dsi_aux = false; // Calculate and save aux camera DSI (currently it is offset from the main/rig data
public boolean clt_batch_save_extrinsics = true; // Save cameras extrinsic parameters with the model
public boolean clt_batch_save_all = true; // Save all parameters with the model
public String x3dModelVersion="v01"; public String x3dModelVersion="v01";
public String jp4SubDir="jp4"; public String jp4SubDir="jp4";
...@@ -263,6 +269,11 @@ public class EyesisCorrectionParameters { ...@@ -263,6 +269,11 @@ public class EyesisCorrectionParameters {
cp.clt_batch_assign= this.clt_batch_assign; cp.clt_batch_assign= this.clt_batch_assign;
cp.clt_batch_gen3d= this.clt_batch_gen3d; cp.clt_batch_gen3d= this.clt_batch_gen3d;
cp.clt_batch_dbg1= this.clt_batch_dbg1; cp.clt_batch_dbg1= this.clt_batch_dbg1;
cp.clt_batch_dsi= this.clt_batch_dsi;
cp.clt_batch_dsi_aux= this.clt_batch_dsi_aux;
cp.clt_batch_save_extrinsics= this.clt_batch_save_extrinsics;
cp.clt_batch_save_all= this.clt_batch_save_all;
} }
...@@ -413,6 +424,11 @@ public class EyesisCorrectionParameters { ...@@ -413,6 +424,11 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"clt_batch_gen3d", this.clt_batch_gen3d+""); properties.setProperty(prefix+"clt_batch_gen3d", this.clt_batch_gen3d+"");
properties.setProperty(prefix+"clt_batch_dbg1", this.clt_batch_dbg1+""); properties.setProperty(prefix+"clt_batch_dbg1", this.clt_batch_dbg1+"");
properties.setProperty(prefix+"clt_batch_dsi", this.clt_batch_dsi+"");
properties.setProperty(prefix+"clt_batch_dsi_aux", this.clt_batch_dsi_aux+"");
properties.setProperty(prefix+"clt_batch_save_extrinsics", this.clt_batch_save_extrinsics+"");
properties.setProperty(prefix+"clt_batch_save_all", this.clt_batch_save_all+"");
properties.setProperty(prefix+"thumb_width", this.thumb_width+""); properties.setProperty(prefix+"thumb_width", this.thumb_width+"");
properties.setProperty(prefix+"thumb_height", this.thumb_height+""); properties.setProperty(prefix+"thumb_height", this.thumb_height+"");
properties.setProperty(prefix+"thumb_h_center", this.thumb_h_center+""); properties.setProperty(prefix+"thumb_h_center", this.thumb_h_center+"");
...@@ -557,6 +573,11 @@ public class EyesisCorrectionParameters { ...@@ -557,6 +573,11 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"clt_batch_gen3d")!= null) this.clt_batch_gen3d=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_gen3d")); if (properties.getProperty(prefix+"clt_batch_gen3d")!= null) this.clt_batch_gen3d=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_gen3d"));
if (properties.getProperty(prefix+"clt_batch_dbg1")!= null) this.clt_batch_dbg1=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dbg1")); if (properties.getProperty(prefix+"clt_batch_dbg1")!= null) this.clt_batch_dbg1=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dbg1"));
if (properties.getProperty(prefix+"clt_batch_dsi")!= null) this.clt_batch_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi"));
if (properties.getProperty(prefix+"clt_batch_dsi_aux")!= null) this.clt_batch_dsi_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux"));
if (properties.getProperty(prefix+"clt_batch_save_extrinsics")!= null) this.clt_batch_save_extrinsics=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_extrinsics"));
if (properties.getProperty(prefix+"clt_batch_save_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all"));
if (properties.getProperty(prefix+"thumb_width")!=null) this.thumb_width=Integer.parseInt(properties.getProperty(prefix+"thumb_width")); if (properties.getProperty(prefix+"thumb_width")!=null) this.thumb_width=Integer.parseInt(properties.getProperty(prefix+"thumb_width"));
if (properties.getProperty(prefix+"thumb_height")!=null) this.thumb_height=Integer.parseInt(properties.getProperty(prefix+"thumb_height")); if (properties.getProperty(prefix+"thumb_height")!=null) this.thumb_height=Integer.parseInt(properties.getProperty(prefix+"thumb_height"));
if (properties.getProperty(prefix+"thumb_h_center")!=null) this.thumb_h_center= Double.parseDouble(properties.getProperty(prefix+"thumb_h_center")); if (properties.getProperty(prefix+"thumb_h_center")!=null) this.thumb_h_center= Double.parseDouble(properties.getProperty(prefix+"thumb_h_center"));
...@@ -899,6 +920,18 @@ public class EyesisCorrectionParameters { ...@@ -899,6 +920,18 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Assign tiles to surfaces", this.clt_batch_assign); // 27 gd.addCheckbox ("Assign tiles to surfaces", this.clt_batch_assign); // 27
gd.addCheckbox ("Generate 3d output: x3d and/or obj+mtl", this.clt_batch_gen3d); // 28 gd.addCheckbox ("Generate 3d output: x3d and/or obj+mtl", this.clt_batch_gen3d); // 28
gd.addCheckbox ("Generate debug images if a single set is selected", this.clt_batch_dbg1); // 29 gd.addCheckbox ("Generate debug images if a single set is selected", this.clt_batch_dbg1); // 29
gd.addCheckbox ("Create DSI combo image", this.clt_batch_dsi,
"Save main camera, dual-quad rig and optionally aux camera combo DSI image with the model");
gd.addCheckbox ("Include aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux,
"Currently DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time");
gd.addCheckbox ("Save field adjustment data with the model", this.clt_batch_save_extrinsics,
"This data can be used to restore specific filed-adjusted cameras extrinsics used when the model was generated");
gd.addCheckbox ("Save all parameters with the model", this.clt_batch_save_all,
"Save a copy of all parameters with the model");
if (clt_parameters != null) { if (clt_parameters != null) {
// gd.addMessage ("============ selected CLT parameters ============"); // gd.addMessage ("============ selected CLT parameters ============");
gd.addTab ("CLT", "Modify selected CLT parameters"); gd.addTab ("CLT", "Modify selected CLT parameters");
...@@ -968,6 +1001,10 @@ public class EyesisCorrectionParameters { ...@@ -968,6 +1001,10 @@ public class EyesisCorrectionParameters {
this.clt_batch_assign= gd.getNextBoolean(); // 27 this.clt_batch_assign= gd.getNextBoolean(); // 27
this.clt_batch_gen3d= gd.getNextBoolean(); // 28 this.clt_batch_gen3d= gd.getNextBoolean(); // 28
this.clt_batch_dbg1= gd.getNextBoolean(); // 29 this.clt_batch_dbg1= gd.getNextBoolean(); // 29
this.clt_batch_dsi= gd.getNextBoolean();
this.clt_batch_dsi_aux= gd.getNextBoolean();
this.clt_batch_save_extrinsics= gd.getNextBoolean();
this.clt_batch_save_all= gd.getNextBoolean();
if (clt_parameters != null) { if (clt_parameters != null) {
clt_parameters.grow_disp_max = gd.getNextNumber(); clt_parameters.grow_disp_max = gd.getNextNumber();
clt_parameters.gain_equalize = gd.getNextBoolean(); clt_parameters.gain_equalize = gd.getNextBoolean();
......
...@@ -588,6 +588,8 @@ private Panel panel1, ...@@ -588,6 +588,8 @@ private Panel panel1,
addButton("MAIN extrinsics", panelClt4, color_process); addButton("MAIN extrinsics", panelClt4, color_process);
addButton("AUX extrinsics", panelClt4, color_process); addButton("AUX extrinsics", panelClt4, color_process);
addButton("RIG extrinsics", panelClt4, color_conf_process); addButton("RIG extrinsics", panelClt4, color_conf_process);
addButton("SAVE extrinsics", panelClt4,color_process); //, "Save configuration");
addButton("Rig8 images", panelClt4, color_conf_process); addButton("Rig8 images", panelClt4, color_conf_process);
// addButton("Rig enhance", panelClt4, color_conf_process); // addButton("Rig enhance", panelClt4, color_conf_process);
...@@ -598,6 +600,7 @@ private Panel panel1, ...@@ -598,6 +600,7 @@ private Panel panel1,
addButton("Poles GT", panelClt4, color_process); addButton("Poles GT", panelClt4, color_process);
addButton("ML export", panelClt4, color_conf_process); addButton("ML export", panelClt4, color_conf_process);
addButton("JP4 copy", panelClt4, color_conf_process); addButton("JP4 copy", panelClt4, color_conf_process);
addButton("DSI show", panelClt4, color_process);
addButton("Rig batch", panelClt4, color_process); addButton("Rig batch", panelClt4, color_process);
...@@ -4366,12 +4369,12 @@ private Panel panel1, ...@@ -4366,12 +4369,12 @@ private Panel panel1,
if (!CLT_PARAMETERS.showTsDialog()) return; if (!CLT_PARAMETERS.showTsDialog()) return;
boolean OK = QUAD_CLT.assignCLTPlanes( double [][] assign_dbg = QUAD_CLT.assignCLTPlanes(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters, CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel); DEBUG_LEVEL); //final int debugLevel);
if (!OK){ if (assign_dbg == null){
System.out.println("Could not assign tiles to surfaces, probably \"CLT planes\" command did not run"); System.out.println("Could not assign tiles to surfaces, probably \"CLT planes\" command did not run");
return; return;
} }
...@@ -4506,6 +4509,11 @@ private Panel panel1, ...@@ -4506,6 +4509,11 @@ private Panel panel1,
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
infinityRig(); infinityRig();
return; return;
/* ======================================================================== */
} else if (label.equals("SAVE extrinsics")) {
saveExtrinsics();
return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("SHOW extrinsics")) { } else if (label.equals("SHOW extrinsics")) {
if (QUAD_CLT == null){ if (QUAD_CLT == null){
...@@ -4617,6 +4625,11 @@ private Panel panel1, ...@@ -4617,6 +4625,11 @@ private Panel panel1,
} }
QUAD_CLT_AUX.editRig(); QUAD_CLT_AUX.editRig();
return; return;
/* ======================================================================== */
} else if (label.equals("DSI show")) {
showDSI();
return;
//JTabbedTest //JTabbedTest
// End of buttons code // End of buttons code
} }
...@@ -5009,7 +5022,7 @@ private Panel panel1, ...@@ -5009,7 +5022,7 @@ private Panel panel1,
public boolean rigPlanes() { public boolean rigPlanes() {
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) { if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) {
String msg = "DSI data is not available. Please run \"CLT 3D\" first"; String msg = "DSI data is not available. Please run \"CLT 3D\" first";
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
System.out.println(msg); System.out.println(msg);
...@@ -5259,7 +5272,7 @@ private Panel panel1, ...@@ -5259,7 +5272,7 @@ private Panel panel1,
public boolean groundTruth() { public boolean groundTruth() {
long startTime=System.nanoTime(); long startTime=System.nanoTime();
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) { if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) {
boolean OK = clt3d( boolean OK = clt3d(
false, // boolean adjust_extrinsics, false, // boolean adjust_extrinsics,
false); // boolean adjust_poly); false); // boolean adjust_poly);
...@@ -5300,7 +5313,7 @@ private Panel panel1, ...@@ -5300,7 +5313,7 @@ private Panel panel1,
public boolean rigDSI() { public boolean rigDSI() {
long startTime=System.nanoTime(); long startTime=System.nanoTime();
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) { if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) {
boolean OK = clt3d( boolean OK = clt3d(
false, // boolean adjust_extrinsics, false, // boolean adjust_extrinsics,
false); // boolean adjust_poly); false); // boolean adjust_poly);
...@@ -5347,7 +5360,7 @@ private Panel panel1, ...@@ -5347,7 +5360,7 @@ private Panel panel1,
public boolean batchRig() { public boolean batchRig() {
long startTime=System.nanoTime(); long startTime=System.nanoTime();
/* if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) { /* if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null) || (QUAD_CLT.tp.clt_3d_passes.size() == 0)) {
boolean OK = clt3d( boolean OK = clt3d(
false, // boolean adjust_extrinsics, false, // boolean adjust_extrinsics,
...@@ -5364,6 +5377,7 @@ private Panel panel1, ...@@ -5364,6 +5377,7 @@ private Panel panel1,
if (!prepareRigImages()) return false; if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath(); String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false; if (configPath.equals("ABORT")) return false;
setAllProperties(PROPERTIES); // batchRig may save properties with the model. Extrinsics will be updated, others should be set here
if (DEBUG_LEVEL > -2){ if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Running batch processing of dual-quad camera rig ++++++++++++++"); System.out.println("++++++++++++++ Running batch processing of dual-quad camera rig ++++++++++++++");
} }
...@@ -5377,6 +5391,7 @@ private Panel panel1, ...@@ -5377,6 +5391,7 @@ private Panel panel1,
CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters, CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters, RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters, EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
PROPERTIES, // Properties properties,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus, UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); DEBUG_LEVEL);
...@@ -5528,7 +5543,32 @@ private Panel panel1, ...@@ -5528,7 +5543,32 @@ private Panel panel1,
return true; return true;
} }
public boolean saveExtrinsics() {
String [] patterns= {".corr-xml",".xml"};
String path= selectFile(true, // save
"Save configuration selection", // title
"Select configuration file", // button
new MultipleExtensionsFileFilter(patterns, "XML Configuration files (*.corr-xml)"), // filter
CORRECTION_PARAMETERS.resultsDirectory); // may be ""
if (path==null) return false;
if (TWO_QUAD_CLT == null) {
return false;
}
TWO_QUAD_CLT.saveProperties(
path, // String path, // full name with extension or w/o path to use x3d directory
null, // Properties properties, // if null - will only save extrinsics)
DEBUG_LEVEL); // int debugLevel)
return true;
}
public boolean showDSI() {
if (TWO_QUAD_CLT == null) {
System.out.println("TWO_QUAD_CLT is not initialized");
return false;
}
TWO_QUAD_CLT.showDSI();
return true;
}
public boolean infinityRig() { public boolean infinityRig() {
if (!prepareRigImages()) return false; if (!prepareRigImages()) return false;
...@@ -6725,8 +6765,6 @@ private Panel panel1, ...@@ -6725,8 +6765,6 @@ private Panel panel1,
} }
/* ======================================================================== */ /* ======================================================================== */
public void setAllProperties(Properties properties){ public void setAllProperties(Properties properties){
// QuadCLT qc = QUAD_CLT;
// QuadCLT aqc = QUAD_CLT_AUX;
properties.setProperty("MASTER_DEBUG_LEVEL",MASTER_DEBUG_LEVEL+""); properties.setProperty("MASTER_DEBUG_LEVEL",MASTER_DEBUG_LEVEL+"");
properties.setProperty("UPDATE_STATUS", UPDATE_STATUS+ ""); properties.setProperty("UPDATE_STATUS", UPDATE_STATUS+ "");
SPLIT_PARAMETERS.setProperties("SPLIT_PARAMETERS.", properties); SPLIT_PARAMETERS.setProperties("SPLIT_PARAMETERS.", properties);
...@@ -6735,9 +6773,7 @@ private Panel panel1, ...@@ -6735,9 +6773,7 @@ private Panel panel1,
DEBAYER_PARAMETERS.setProperties("DEBAYER_PARAMETERS.", properties); DEBAYER_PARAMETERS.setProperties("DEBAYER_PARAMETERS.", properties);
NONLIN_PARAMETERS.setProperties("NONLIN_PARAMETERS.", properties); // keep for Eyesis, not used fro Quad CLT NONLIN_PARAMETERS.setProperties("NONLIN_PARAMETERS.", properties); // keep for Eyesis, not used fro Quad CLT
COLOR_PROC_PARAMETERS.setProperties("COLOR_PROC_PARAMETERS.", properties); COLOR_PROC_PARAMETERS.setProperties("COLOR_PROC_PARAMETERS.", properties);
// COLOR_CALIB_PARAMETERS.setProperties("COLOR_CALIB_PARAMETERS.", properties);
RGB_PARAMETERS.setProperties("RGB_PARAMETERS.", properties); RGB_PARAMETERS.setProperties("RGB_PARAMETERS.", properties);
// FILE_PARAMETERS.setProperties("FILE_PARAMETERS.", properties);
PROCESS_PARAMETERS.setProperties("PROCESS_PARAMETERS.", properties); PROCESS_PARAMETERS.setProperties("PROCESS_PARAMETERS.", properties);
CORRECTION_PARAMETERS.setProperties("CORRECTION_PARAMETERS.", properties); CORRECTION_PARAMETERS.setProperties("CORRECTION_PARAMETERS.", properties);
CHANNEL_GAINS_PARAMETERS.setProperties("CHANNEL_GAINS_PARAMETERS.", properties); CHANNEL_GAINS_PARAMETERS.setProperties("CHANNEL_GAINS_PARAMETERS.", properties);
...@@ -6750,8 +6786,8 @@ private Panel panel1, ...@@ -6750,8 +6786,8 @@ private Panel panel1,
properties.setProperty("THREADS_MAX",THREADS_MAX+""); // 100, testing multi-threading, limit maximal number of threads properties.setProperty("THREADS_MAX",THREADS_MAX+""); // 100, testing multi-threading, limit maximal number of threads
properties.setProperty("GAUSS_WIDTH",GAUSS_WIDTH+""); // 0.4 (0 - use Hamming window) properties.setProperty("GAUSS_WIDTH",GAUSS_WIDTH+""); // 0.4 (0 - use Hamming window)
properties.setProperty("PSF_SUBPIXEL_SHOULD_BE_4",PSF_SUBPIXEL_SHOULD_BE_4+""); // 4, sub-pixel decimation properties.setProperty("PSF_SUBPIXEL_SHOULD_BE_4",PSF_SUBPIXEL_SHOULD_BE_4+""); // 4, sub-pixel decimation
if (QUAD_CLT != null) QUAD_CLT.setProperties(QuadCLT.PREFIX); if (QUAD_CLT != null) QUAD_CLT.setProperties(QuadCLT.PREFIX, null);
if (QUAD_CLT_AUX != null) QUAD_CLT_AUX.setProperties(QuadCLT.PREFIX_AUX); if (QUAD_CLT_AUX != null) QUAD_CLT_AUX.setProperties(QuadCLT.PREFIX_AUX, null);
} }
/* ======================================================================== */ /* ======================================================================== */
public void getAllProperties(Properties properties){ public void getAllProperties(Properties properties){
...@@ -6763,7 +6799,6 @@ private Panel panel1, ...@@ -6763,7 +6799,6 @@ private Panel panel1,
DEBAYER_PARAMETERS.getProperties("DEBAYER_PARAMETERS.", properties); DEBAYER_PARAMETERS.getProperties("DEBAYER_PARAMETERS.", properties);
NONLIN_PARAMETERS.getProperties("NONLIN_PARAMETERS.", properties); // keep for Eyesis, not used fro Quad CLT NONLIN_PARAMETERS.getProperties("NONLIN_PARAMETERS.", properties); // keep for Eyesis, not used fro Quad CLT
COLOR_PROC_PARAMETERS.getProperties("COLOR_PROC_PARAMETERS.", properties); COLOR_PROC_PARAMETERS.getProperties("COLOR_PROC_PARAMETERS.", properties);
// COLOR_CALIB_PARAMETERS.getProperties("COLOR_CALIB_PARAMETERS.", properties);
RGB_PARAMETERS.getProperties("RGB_PARAMETERS.", properties); RGB_PARAMETERS.getProperties("RGB_PARAMETERS.", properties);
PROCESS_PARAMETERS.getProperties("PROCESS_PARAMETERS.", properties); PROCESS_PARAMETERS.getProperties("PROCESS_PARAMETERS.", properties);
CORRECTION_PARAMETERS.getProperties("CORRECTION_PARAMETERS.", properties); CORRECTION_PARAMETERS.getProperties("CORRECTION_PARAMETERS.", properties);
......
...@@ -926,7 +926,12 @@ public class LinkPlanes { ...@@ -926,7 +926,12 @@ public class LinkPlanes {
this_plane.initMergedValue(dir,other_planes.length); // filled with NaN this_plane.initMergedValue(dir,other_planes.length); // filled with NaN
for (int np = 0; np < other_planes.length; np ++){ for (int np = 0; np < other_planes.length; np ++){
if (other_planes[np] != null) { if (other_planes[np] != null) {
TilePlanes.PlaneData other_plane = this_plane.getPlaneToThis( if (nsTile0 == 790) {
System.out.println("?LinkPlanes.matchPlanes() DEBUG1:");
System.out.println("?LinkPlanes.matchPlanes() DEBUG1:");
}
TilePlanes.PlaneData other_plane = this_plane.getPlaneToThis( // returns NaN with FRONTO
other_planes[np], other_planes[np],
dl - 2); // debugLevel); dl - 2); // debugLevel);
if (other_plane !=null) { // now always, but may add later if (other_plane !=null) { // now always, but may add later
......
...@@ -203,7 +203,10 @@ public class QuadCLT { ...@@ -203,7 +203,10 @@ public class QuadCLT {
// public void setProperties(){ // public void setProperties(){
// setProperties(this.properties_prefix); // setProperties(this.properties_prefix);
// } // }
public void setProperties(String prefix){ // save public void setProperties(String prefix, Properties properties){ // save
if (properties == null) {
properties = this.properties;
}
// System.out.println("setProperties("+prefix+")"); // System.out.println("setProperties("+prefix+")");
for (int n = 0; n < fine_corr.length; n++){ for (int n = 0; n < fine_corr.length; n++){
for (int d = 0; d < fine_corr[n].length; d++){ for (int d = 0; d < fine_corr[n].length; d++){
...@@ -5610,7 +5613,7 @@ public class QuadCLT { ...@@ -5610,7 +5613,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public boolean assignCLTPlanes( public double [][] assignCLTPlanes(
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -5618,14 +5621,14 @@ public class QuadCLT { ...@@ -5618,14 +5621,14 @@ public class QuadCLT {
{ {
if (tp == null){ if (tp == null){
System.out.println("showCLTPlanes(): tp is null"); System.out.println("showCLTPlanes(): tp is null");
return false; return null;
} }
if (tp.clt_3d_passes == null){ if (tp.clt_3d_passes == null){
System.out.println("showCLTPlanes(): tp.clt_3d_passes is null"); System.out.println("showCLTPlanes(): tp.clt_3d_passes is null");
return false; return null;
} }
this.startStepTime=System.nanoTime(); this.startStepTime=System.nanoTime();
boolean ok = tp.assignTilesToSurfaces( double [][] assign_dbg = tp.assignTilesToSurfaces(
clt_parameters, clt_parameters,
geometryCorrection, geometryCorrection,
threadsMax, threadsMax,
...@@ -5635,7 +5638,7 @@ public class QuadCLT { ...@@ -5635,7 +5638,7 @@ public class QuadCLT {
Runtime.getRuntime().gc(); Runtime.getRuntime().gc();
System.out.println("assignCLTPlanes(): processing finished at "+ System.out.println("assignCLTPlanes(): processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return ok; return assign_dbg;
} }
...@@ -9199,13 +9202,13 @@ public class QuadCLT { ...@@ -9199,13 +9202,13 @@ public class QuadCLT {
} else continue; // if (correctionsParameters.clt_batch_surf) } else continue; // if (correctionsParameters.clt_batch_surf)
if (correctionsParameters.clt_batch_assign) { if (correctionsParameters.clt_batch_assign) {
boolean ok = tp.assignTilesToSurfaces( double [][] assign_dbg = tp.assignTilesToSurfaces(
clt_parameters, clt_parameters,
geometryCorrection, geometryCorrection,
threadsMax, threadsMax,
updateStatus, updateStatus,
debugLevelInner); debugLevelInner);
if (!ok) continue; if (assign_dbg == null) continue;
} else continue; // if (correctionsParameters.clt_batch_assign) } else continue; // if (correctionsParameters.clt_batch_assign)
if (correctionsParameters.clt_batch_gen3d) { if (correctionsParameters.clt_batch_gen3d) {
......
...@@ -1818,7 +1818,12 @@ public class SuperTiles{ ...@@ -1818,7 +1818,12 @@ public class SuperTiles{
} }
sel_list.add(new Selections2(new_sel)); sel_list.add(new Selections2(new_sel));
} }
if (sel_list.isEmpty()) {
if (dl > 2){
System.out.println("dispClusterizeHighest(): nsTile="+nsTile+": nothing found");
}
continue;
}
plane_selections[nsTile] = new boolean [sel_list.size()][][]; //plane_sels; plane_selections[nsTile] = new boolean [sel_list.size()][][]; //plane_sels;
for (int np = 0; np < plane_selections[nsTile].length; np++) { for (int np = 0; np < plane_selections[nsTile].length; np++) {
plane_selections[nsTile][np] = sel_list.get(np).getSel(); plane_selections[nsTile][np] = sel_list.get(np).getSel();
...@@ -2546,6 +2551,8 @@ public class SuperTiles{ ...@@ -2546,6 +2551,8 @@ public class SuperTiles{
final int dbg_X, final int dbg_X,
final int dbg_Y) final int dbg_Y)
{ {
// TODO: Make a configurable parameters (0 should also work)
final int min_fresh_used = 1; // minimal number of new tiles not already used by the other direction (hor/vert)
final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY();
...@@ -2816,6 +2823,7 @@ public class SuperTiles{ ...@@ -2816,6 +2823,7 @@ public class SuperTiles{
new_planes_selections[np] = planes_selections[nsTile][np]; new_planes_selections[np] = planes_selections[nsTile][np];
new_plane_types[np] = hor_planes[nsTile][np]; new_plane_types[np] = hor_planes[nsTile][np];
} }
int planes_added = 0;
for (int nnp = 0; nnp < num_planes; nnp++) { // SelStrength ss:selStrengthList){ for (int nnp = 0; nnp < num_planes; nnp++) { // SelStrength ss:selStrengthList){
SelStrength ss = selStrengthList.get(nnp); SelStrength ss = selStrengthList.get(nnp);
new_plane_types[np] = ss.type != 0; // 0 - vert, 1 - hor; new_plane_types[np] = ss.type != 0; // 0 - vert, 1 - hor;
...@@ -2831,6 +2839,27 @@ public class SuperTiles{ ...@@ -2831,6 +2839,27 @@ public class SuperTiles{
// Filling small gaps in new selections before marking them as "used" // Filling small gaps in new selections before marking them as "used"
boolean [] used_before = (ss.type == 0) ? used_vert[nsTile][ml] : used_hor[nsTile][ml]; boolean [] used_before = (ss.type == 0) ? used_vert[nsTile][ml] : used_hor[nsTile][ml];
boolean [] this_used = sels_all[ss.type][ss.indx][ml].clone(); boolean [] this_used = sels_all[ss.type][ss.indx][ml].clone();
// See how many really new tiles has this_used;
int num_really_new = 0;
for (int i = 0; i < num_tiles; i++) if (this_used[i] && !used_vert[nsTile][ml][i] && !used_hor[nsTile][ml][i]) {
num_really_new++;
}
// see if is enough
if (num_really_new < min_fresh_used) {
for (int i = 0; i < num_tiles; i++){
used_before[i] |= this_used[i]; // Still mark them as used on this orientation
}
this_used = new boolean[this_used.length]; // unselect all
if (dl > 1){
System.out.println("initialDiscriminateTiles():"+nsTile+" selection does not provide enough previously unused tiles");
}
// disable these tiles in this orientation used
} else {
planes_added++;
}
boolean [] this_used_expanded = this_used.clone(); boolean [] this_used_expanded = this_used.clone();
tnStile.growSelection( tnStile.growSelection(
2, 2,
...@@ -2882,6 +2911,13 @@ public class SuperTiles{ ...@@ -2882,6 +2911,13 @@ public class SuperTiles{
} }
np++; np++;
} }
if (planes_added == 0) {
if (dl > 1){
System.out.println("initialDiscriminateTiles():"+nsTile+": No new planes added");
}
continue;
}
planes_selections[nsTile] = new_planes_selections; planes_selections[nsTile] = new_planes_selections;
hor_planes[nsTile] = new_plane_types; hor_planes[nsTile] = new_plane_types;
if (dl > 2){ if (dl > 2){
...@@ -3456,7 +3492,7 @@ public class SuperTiles{ ...@@ -3456,7 +3492,7 @@ public class SuperTiles{
plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
PlFrontoPow, // double fronto_pow, // = 1.0; // increase weight even more PlFrontoPow, // double fronto_pow, // = 1.0; // increase weight even more
hor_planes, // final boolean [][] hor_planes, // returns plane types (hor/vert) hor_planes, // final boolean [][] hor_planes, // returns plane types (hor/vert)
debugLevel + 0, // 1, // 0, // 1, // + 2, // 1, // final int debugLevel, debugLevel+(debug_initial_discriminate? 3:0), // 1, // 0, // 1, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y) dbg_Y); // final int dbg_Y)
this.planes = new_planes; // save as "measured" (as opposed to "smoothed" by neighbors) planes this.planes = new_planes; // save as "measured" (as opposed to "smoothed" by neighbors) planes
......
This diff is collapsed.
...@@ -270,7 +270,9 @@ public class TilePlanes { ...@@ -270,7 +270,9 @@ public class TilePlanes {
{ {
if (!force && (world_xyz == null)) return Double.NaN; if (!force && (world_xyz == null)) return Double.NaN;
if (wvectors == null) return Double.NaN; if (wvectors == null) return Double.NaN;
Matrix norm_disp = new Matrix(this.getWorldXYZ(this.correctDistortions, 0),3); // normal to plane from disparity space double [] anorm_disp = this.getWorldXYZ(this.correctDistortions, 0);
if (anorm_disp == null) return Double.NaN;
Matrix norm_disp = new Matrix(anorm_disp,3); // normal to plane from disparity space
Matrix norm_world = new Matrix(wvectors[0],3); // normal to plane from disparity space Matrix norm_world = new Matrix(wvectors[0],3); // normal to plane from disparity space
Matrix cp = cross3d(norm_disp, norm_world); Matrix cp = cross3d(norm_disp, norm_world);
double cp2 = cp.transpose().times(cp).get(0, 0); double cp2 = cp.transpose().times(cp).get(0, 0);
...@@ -1273,7 +1275,7 @@ public class TilePlanes { ...@@ -1273,7 +1275,7 @@ public class TilePlanes {
} }
if ((dispNorm > 0.0) && (zxy[0] > dispNorm)) { if ((dispNorm > 0.0) && (zxy[0] > dispNorm)) {
almost_fronto = false; // disable fronto for near objects completely // almost_fronto = false; // disable fronto for near objects completely
} }
this.fronto = almost_fronto; this.fronto = almost_fronto;
return almost_fronto; return almost_fronto;
...@@ -2163,6 +2165,8 @@ public class TilePlanes { ...@@ -2163,6 +2165,8 @@ public class TilePlanes {
double w = disp_str[nl][1][indx]; double w = disp_str[nl][1][indx];
if ((w > 0.0) && !(disp_str[nl][0][indx] > 0.0)) { if ((w > 0.0) && !(disp_str[nl][0][indx] > 0.0)) {
System.out.println("BUG!!!: getPlaneFromMeas(): disp_str[nl][0]["+indx+"]="+disp_str[nl][0][indx]+", disp_str[nl][1]["+indx+"]="+disp_str[nl][1][indx]); System.out.println("BUG!!!: getPlaneFromMeas(): disp_str[nl][0]["+indx+"]="+disp_str[nl][0][indx]+", disp_str[nl][1]["+indx+"]="+disp_str[nl][1][indx]);
w = 0.0;
disp_str[nl][1][indx] = 0.0;
continue; continue;
} }
if (w > 0.0){ if (w > 0.0){
...@@ -3995,6 +3999,23 @@ public class TilePlanes { ...@@ -3995,6 +3999,23 @@ public class TilePlanes {
px_py[0], px_py[0],
px_py[1], px_py[1],
this.correctDistortions); this.correctDistortions);
if (Double.isNaN(disp)) {
System.out.println("getPlaneToThis(), px_py = {"+px_py[0]+", "+px_py[1]+"}, px_py_other = {"+px_py_other[0]+", "+px_py_other[1]+"}");
System.out.println("getPlaneToThis(), disp = "+disp);
System.out.println("getPlaneToThis(), pd="+ pd.toString());
System.out.println("getPlaneToThis(), otherPd="+ otherPd.toString());
System.out.println("getPlaneToThis(), pd.getWorldXYZ(this.correctDistortions)="+ pd.getWorldXYZ(this.correctDistortions));
System.out.println("getPlaneToThis(), wv1 = {"+ wv1[0]+", "+ wv1[1]+", "+ wv1[2]+"}");
System.out.println("getPlaneToThis(), wv2 = {"+ wv2[0]+", "+ wv2[1]+", "+ wv2[2]+"}");
double [] norm_xyz = pd.getWorldXYZ(this.correctDistortions);
System.out.println("getPlaneToThis(),norm_xyz="+ norm_xyz);
disp = geometryCorrection.getPlaneDisparity( // disparity (at this center) for crossing other supertile plane
norm_xyz, // will calculate if not yet done so. Should it use otherPd, not pd? and then clone later?
px_py[0],
px_py[1],
this.correctDistortions);
}
if (debugLevel > 0) { if (debugLevel > 0) {
System.out.println("getPlaneToThis(), px_py = {"+px_py[0]+", "+px_py[1]+"}, px_py_other = {"+px_py_other[0]+", "+px_py_other[1]+"}"); System.out.println("getPlaneToThis(), px_py = {"+px_py[0]+", "+px_py[1]+"}, px_py_other = {"+px_py_other[0]+", "+px_py_other[1]+"}");
System.out.println("getPlaneToThis(), disp = "+disp); System.out.println("getPlaneToThis(), disp = "+disp);
...@@ -4178,6 +4199,15 @@ public class TilePlanes { ...@@ -4178,6 +4199,15 @@ public class TilePlanes {
int debugLevel) int debugLevel)
{ {
double delta = 0.0001; double delta = 0.0001;
// debugging:
if (world_xyz != null) {
double l2 = world_xyz[0]*world_xyz[0] + world_xyz[1]*world_xyz[1]+world_xyz[2]*world_xyz[2];
if (l2 < 0.5) {
System.out.println("getWorldXYZ(): l2="+l2); // +" this=\n"+this.toString());
world_xyz = null;
}
}
if (world_xyz != null) return world_xyz; if (world_xyz != null) return world_xyz;
setCorrectDistortions(correct_distortions); setCorrectDistortions(correct_distortions);
// get pixel coordinates of the plane origin point // get pixel coordinates of the plane origin point
...@@ -4271,6 +4301,10 @@ public class TilePlanes { ...@@ -4271,6 +4301,10 @@ public class TilePlanes {
// convert plane normal vector to world coordinates // convert plane normal vector to world coordinates
//world_xyz //world_xyz
world_xyz = norm_xyz.times((xyz.transpose().times(norm_xyz).get(0,0))).getColumnPackedCopy(); world_xyz = norm_xyz.times((xyz.transpose().times(norm_xyz).get(0,0))).getColumnPackedCopy();
double l2 = world_xyz[0]*world_xyz[0] + world_xyz[1]*world_xyz[1]+world_xyz[2]*world_xyz[2];
if (l2 < 0.5) {
System.out.println("getWorldXYZ(): l2="+l2); // +" this=\n"+this.toString());
}
return world_xyz; return world_xyz;
} }
......
...@@ -2245,6 +2245,24 @@ public class TileProcessor { ...@@ -2245,6 +2245,24 @@ public class TileProcessor {
System.out.println("showScan("+title+"): isMeasured()="+scan.isMeasured()+", isProcessed()="+scan.isProcessed()+", isCombo()="+scan.isCombo()); System.out.println("showScan("+title+"): isMeasured()="+scan.isMeasured()+", isProcessed()="+scan.isProcessed()+", isCombo()="+scan.isCombo());
} }
public double [][] getShowDS(
CLTPass3d scan,
boolean force_final)
{
double [][] dbg_img = getShowScan(scan);
double [][] ds = new double [2][];
if (!force_final && (dbg_img[2] != null)) {
ds[0] = dbg_img[2]; // disparity
} else {
ds[0] = dbg_img[1]; // final
}
if (!force_final && (dbg_img[7] != null)) {
ds[1] = dbg_img[7]; // strength
} else {
ds[1] = dbg_img[6]; // final strength
}
return ds;
}
public double [][] getShowScan( public double [][] getShowScan(
CLTPass3d scan) CLTPass3d scan)
...@@ -4696,7 +4714,7 @@ public class TileProcessor { ...@@ -4696,7 +4714,7 @@ public class TileProcessor {
} }
public boolean assignTilesToSurfaces( public double [][] assignTilesToSurfaces(
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
GeometryCorrection geometryCorrection, GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
...@@ -4712,7 +4730,7 @@ public class TileProcessor { ...@@ -4712,7 +4730,7 @@ public class TileProcessor {
SuperTiles st = scan_prev.getSuperTiles(); SuperTiles st = scan_prev.getSuperTiles();
TileSurface tileSurface = st.getTileSurface(); TileSurface tileSurface = st.getTileSurface();
if (tileSurface == null){ if (tileSurface == null){
return false; return null; // false;
} }
// show testure_tiles // show testure_tiles
...@@ -5069,10 +5087,10 @@ public class TileProcessor { ...@@ -5069,10 +5087,10 @@ public class TileProcessor {
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf"); (new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf");
} }
if (!batch_mode && (debugLevel > -1)) { if (!batch_mode && (debugLevel > -1)) {
ta.showTileCost("before_",tile_layers_surf); ta.showTileCost("before_",tile_layers_surf); // , true);
ta.showTileCosts("before_",tile_layers_surf); ta.showTileCosts("before_",tile_layers_surf); //, true);
} }
TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf); TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf);// ,(debugLevel > -1));
for (int i = 0; i < ta_stats.length; i++){ for (int i = 0; i < ta_stats.length; i++){
System.out.println(ta_stats[i].toString()); System.out.println(ta_stats[i].toString());
...@@ -5097,12 +5115,12 @@ public class TileProcessor { ...@@ -5097,12 +5115,12 @@ public class TileProcessor {
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf"); (new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf");
} }
if (!batch_mode && (debugLevel > -2)) { if (!batch_mode && (debugLevel > -2)) {
ta.showTileCost("after_",tile_layers_surf); ta.showTileCost("after_",tile_layers_surf); // , true);
} }
if (!batch_mode && (debugLevel > -1)) { if (!batch_mode && (debugLevel > -1)) {
ta.showTileCosts("after_",tile_layers_surf); ta.showTileCosts("after_",tile_layers_surf); // , true);
} }
ta_stats = ta.statTileCosts(tile_layers_surf); ta_stats = ta.statTileCosts(tile_layers_surf); // , (debugLevel > -1));
System.out.println("Optimized:"); System.out.println("Optimized:");
for (int i = 0; i < ta_stats.length; i++){ for (int i = 0; i < ta_stats.length; i++){
System.out.println(ta_stats[i].toString()); System.out.println(ta_stats[i].toString());
...@@ -5122,10 +5140,14 @@ public class TileProcessor { ...@@ -5122,10 +5140,14 @@ public class TileProcessor {
tileSel, // final boolean [][] tileSel, tileSel, // final boolean [][] tileSel,
debugLevel); // final int debugLevel, debugLevel); // final int debugLevel,
double [][] assignments_dbg = tileSurface.getShowAssignment(dispStrength);
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -2)){ if (!batch_mode && clt_parameters.tsShow && (debugLevel > -2)){
tileSurface.showAssignment( String title_asgn = "assignments";
"assignments", // String title, String [] titles_asgn = tileSurface.getTitlesAssignment(dispStrength);
dispStrength); // final double [][][] dispStrength) (new showDoubleFloatArrays()).showArrays(assignments_dbg, tilesX, tilesY, true, title_asgn, titles_asgn);
/// tileSurface.showAssignment(
/// "assignments", // String title,
/// dispStrength); // final double [][][] dispStrength)
} }
boolean [][] assigned_sel = tileSurface.extractSelection( boolean [][] assigned_sel = tileSurface.extractSelection(
batch_mode ? -5: 0, // final int debugLevel, batch_mode ? -5: 0, // final int debugLevel,
...@@ -5261,7 +5283,7 @@ public class TileProcessor { ...@@ -5261,7 +5283,7 @@ public class TileProcessor {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
sdfa_instance.showArrays(img_data, tilesX, tilesY, true, "final_surfaces",titles); sdfa_instance.showArrays(img_data, tilesX, tilesY, true, "final_surfaces",titles);
} }
return true; return assignments_dbg;
} }
//====================== //======================
......
...@@ -76,6 +76,12 @@ public class TileSurface { ...@@ -76,6 +76,12 @@ public class TileSurface {
static int CLUST_NUM_CONFLICTS_B = 6; static int CLUST_NUM_CONFLICTS_B = 6;
static int CLUST_NUM_STATS = 7; static int CLUST_NUM_STATS = 7;
static int ASGN_DISP = 0;
static int ASGN_A_DISP = 1;
static int ASGN_A_NAN = 2;
static int ASGN_INDX = 3;
static int ASGN_STRENGTH = 4;
static int ASGN_NG = 5;
// private int nsTilesstSize = 0; // 8; // private int nsTilesstSize = 0; // 8;
...@@ -2776,6 +2782,57 @@ public class TileSurface { ...@@ -2776,6 +2782,57 @@ public class TileSurface {
public void showAssignment( public void showAssignment(
String title, String title,
final double [][][] dispStrength) final double [][][] dispStrength)
{
String [] titles = getTitlesAssignment(dispStrength);
double [][] img_data = getShowAssignment(dispStrength);
(new showDoubleFloatArrays()).showArrays(img_data, imageTilesX, imageTilesY, true, title, titles);
}
public double [][] getShowAssignment(
final double [][][] dispStrength)
{
double [][] img_data = new double [ASGN_NG * tileLayers.length][];
for (int ml = 0; ml < tileLayers.length; ml ++){
if (dispStrength[ml] != null) {
img_data[ASGN_NG * ml + ASGN_DISP] = dispStrength[ml][0];
img_data[ASGN_NG * ml + ASGN_STRENGTH] = dispStrength[ml][1];
img_data[ASGN_NG * ml + ASGN_A_DISP] = new double [dispStrength[ml][0].length];
img_data[ASGN_NG * ml + ASGN_A_NAN] = new double [dispStrength[ml][0].length];
img_data[ASGN_NG * ml + ASGN_INDX] = new double [dispStrength[ml][0].length];
for (int nTile = 0; nTile < dispStrength[ml][0].length; nTile++){
int nSurfTile = getSurfaceTileIndex(nTile);
if (tileLayers[ml][nTile] > 0){
img_data[ASGN_NG * ml + ASGN_A_DISP][nTile] = tileData[nSurfTile][tileLayers[ml][nTile]-1].getDisparity();
img_data[ASGN_NG * ml + ASGN_A_NAN][nTile] = tileData[nSurfTile][tileLayers[ml][nTile]-1].getDisparity();
} else {
img_data[ASGN_NG * ml + ASGN_A_DISP][nTile] = dispStrength[ml][0][nTile];
img_data[ASGN_NG * ml + ASGN_A_NAN][nTile] = Double.NaN;
}
img_data[ASGN_NG * ml + ASGN_INDX][nTile] = tileLayers[ml][nTile];
}
}
}
return img_data;
}
public String [] getTitlesAssignment(
final double [][][] dispStrength)
{
int ng = 5;
String [] titles = new String[ng * tileLayers.length];
for (int ml = 0; ml < tileLayers.length; ml ++){
titles[ng * ml + ASGN_DISP] = "disp_"+ml;
titles[ng * ml + ASGN_A_DISP] = "a_disp_"+ml;
titles[ng * ml + ASGN_A_NAN] = "a_nan_"+ml;
titles[ng * ml + ASGN_INDX] = "index_"+ml;
titles[ng * ml + ASGN_STRENGTH] = "strength_"+ml;
}
return titles;
}
public void showAssignment_old(
String title,
final double [][][] dispStrength)
{ {
int layer_disp = 0; int layer_disp = 0;
int layer_a_disp = 1; int layer_a_disp = 1;
...@@ -2816,6 +2873,7 @@ public class TileSurface { ...@@ -2816,6 +2873,7 @@ public class TileSurface {
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, title, titles); sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, title, titles);
} }
/** /**
* Unassign tiles that have too few connected other tiles (or total weight of the cluster is too small) * Unassign tiles that have too few connected other tiles (or total weight of the cluster is too small)
* This is a single-threaded method * This is a single-threaded method
......
This diff is collapsed.
...@@ -228,6 +228,29 @@ import ij.process.ImageProcessor; ...@@ -228,6 +228,29 @@ import ij.process.ImageProcessor;
} else imp[i]=null; } else imp[i]=null;
return imp; return imp;
} }
public ImagePlus makeArrays(double[][] pixels, int width, int height, String title, String [] titles) {
int i,j;
if (pixels==null) {
System.out.println("showDoubleFloatArrays.makeArrays(): - pixel array is null");
}
float [] fpixels;
ImageStack array_stack=new ImageStack(width,height);
boolean not_empty = false;
for (i=0;i<pixels.length;i++) if (pixels[i]!=null) {
not_empty = true;
fpixels=new float[pixels[i].length];
for (j=0;j<fpixels.length;j++) fpixels[j]=(float)pixels[i][j];
array_stack.addSlice(titles[i], fpixels);
}
if (not_empty) {
ImagePlus imp_stack = new ImagePlus(title, array_stack);
imp_stack.getProcessor().resetMinAndMax();
// imp_stack.show();
return imp_stack;
}
return null;
}
public ImagePlus [] makeArrays(double[][] pixels, int width, int height, String [] titles) { public ImagePlus [] makeArrays(double[][] pixels, int width, int height, String [] titles) {
int i,j; int i,j;
float [] fpixels; float [] fpixels;
......
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