Commit a2bb43cd authored by Andrey Filippov's avatar Andrey Filippov

Done with individual quad-cam adjustment using rig "GT" data

parent ee9c0264
......@@ -2056,7 +2056,7 @@ B = |+dy0 -dy1 -2*dy3 |
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX, tilesY, true, "hist_filt_ds"); // , titles);
}
}
// combine infinity and lasy eye scan data into a single array
// combine infinity and lazy eye scan data into a single array
double [][] inf_and_ly = new double [2 * NUM_SLICES][];
for (int i = 0; i < NUM_SLICES; i++){
inf_and_ly[i] = inf_scan[i];
......@@ -2076,7 +2076,9 @@ B = |+dy0 -dy1 -2*dy3 |
}
// static final int INDEX_10_WEIGHT = 1;
if (debugLevel > 0) {
System.out.println("test123");
}
if ((debugLevel > -1) && (hist_smpl_side > 0)) { // 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
String [] titles = new String [2 * NUM_SLICES];
......@@ -2128,7 +2130,9 @@ B = |+dy0 -dy1 -2*dy3 |
}
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX1, tilesY1, true, "inf_and_ly8",titles);
}
System.out.println("test1234");
if (debugLevel > 0) {
System.out.println("test1234");
}
// create list for infinity data
// /clt_parameters.ly_inf_en,
ArrayList<Sample> inf_samples_list;
......@@ -2275,6 +2279,7 @@ System.out.println("test1234");
clt_parameters.ly_par_sel, //int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
mismatch_list, // ArrayList<Mismatch> mismatch_list,
qc.geometryCorrection, // GeometryCorrection geometryCorrection,
null, // GeometryCorrection geometryCorrection_main, // if is aux camera using main cameras' coordinates. Disparity is still in aux camera pixels
qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
// 2); // debugLevel); // 2); // 1); // int debugLevel)
......@@ -2323,6 +2328,7 @@ System.out.println("test1234");
public double [][][] lazyEyeCorrectionFromGT(
final GeometryCorrection geometryCorrection_main, // if not null - this is an AUX camera of a rig
final boolean use_poly, // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor
final boolean restore_disp_inf, // Restore subtracted disparity for scan #0 (infinity) always true
final double fcorr_radius,
......@@ -2360,7 +2366,7 @@ System.out.println("test1234");
int debugLevel){
// final double lazyEyeDispRelVariation = 0.02;
//geometryCorrection_main
final int dbg_nTile = -34145; // 37005; // -59038;
final int num_scans = scans_14.length/NUM_ALL_SLICES;
final int num_tiles = scans_14[0].length;
......@@ -2368,6 +2374,8 @@ System.out.println("test1234");
final boolean [] center_mask = getCenterMask(fcorr_radius, tilesX, tilesY);
final double [][] scans = new double [num_scans * NUM_SLICES][];
// final double [][] comp_strength_rms = new double [num_scans][num_tiles];
for (int ns = 0; ns < num_scans; ns++){
final double [] min_weights = new double [num_tiles];
for (int nTile = 0; nTile < num_tiles; nTile++){
......@@ -2478,7 +2486,7 @@ System.out.println("test1234");
double [][] combo_mismatch = new double [NUM_SLICES][num_tiles];
for (int ns = 0; ns < num_scans; ns++){
for (int nTile = 0; nTile < num_tiles; nTile++) {
if ((nTile == dbg_nTile) || (nTile == 24971)){
if (nTile == dbg_nTile) { // || (nTile == 24971)){
System.out.println("lazyEyeCorrectionFromGT().1: nTile="+nTile); // filtered_scans[2][37005] = NaN
}
// double w = filtered_scans[ns * NUM_SLICES + 1][nTile];
......@@ -2588,7 +2596,9 @@ System.out.println("test1234");
}
// static final int INDEX_10_WEIGHT = 1;
if (debugLevel > 0) {
System.out.println("test123");
}
if ((debugLevel > -1) && (hist_smpl_side > 0)) { // 0) {
String [] titles = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, tilesY, true, "inf_and_ly",titles);
......@@ -2628,7 +2638,9 @@ System.out.println("test1234");
}
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX1, tilesY1, true, "inf_and_ly8",titles);
}
if (debugLevel > 0) {
System.out.println("test1234a");
}
// create list for infinity data
// /clt_parameters.ly_inf_en,
......@@ -2732,6 +2744,7 @@ System.out.println("test1234");
System.out.println("Are null - non-null are for poly correction only");
}
}
// TODO: use geometryCorrection_main (if not null)
if (!use_poly && (mismatch_list != null)){
double [] old_new_rms = new double[1];
boolean apply_extrinsic = true;
......@@ -2743,9 +2756,10 @@ System.out.println("test1234");
clt_parameters.ly_inf_force, // boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity
clt_parameters.ly_com_roll, // boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength, // boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_par_sel, //int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
mismatch_list, // ArrayList<Mismatch> mismatch_list,
qc.geometryCorrection, // GeometryCorrection geometryCorrection,
geometryCorrection_main, // GeometryCorrection geometryCorrection_main, // if is aux camera using main cameras' coordinates. Disparity is still in aux camera pixels
qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
// 2); // debugLevel); // 2); // 1); // int debugLevel)
......@@ -3278,10 +3292,9 @@ System.out.println("test1234");
boolean common_roll, // Enable common roll (valid for high disparity range only)
boolean corr_focalLength, // Correct scales (focal length temperature? variations)
int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection geometryCorrection_main, // if is aux camera using main cameras' coordinates. Disparity is still in aux camera pixels
GeometryCorrection.CorrVector corr_vector,
double [] old_new_rms, // should be double[2]
int debugLevel)
......
......@@ -512,7 +512,7 @@ public class BiScan {
int dbg_x = 193;
int dbg_y = 162;
int debugLevel = -1;
final int dbg_tile = (debugLevel>-2)?(dbg_x + tnImage.sizeX*dbg_y):-1;
final int dbg_tile = (debugLevel>-1)?(dbg_x + tnImage.sizeX*dbg_y):-1;
ai.set(0);
// find definitely trusted and conditionally trusted tiles
......
......@@ -122,6 +122,10 @@ public class EyesisCorrectionParameters {
public int rig_batch_adjust_aux = 0;
public int rig_batch_adjust_rig = 0;
public int rig_batch_adjust_main_gt = 0; // adjust main camera using rig disparity as ground truth
public int rig_batch_adjust_aux_gt = 0; // adjust aux camera using rig disparity as ground truth (TODO: finish geometry in derivatives)
public int rig_batch_adjust_rig_gt = 0; // adjust rig after main and aux are adjusted with rig GT (late rig adjustment)
public boolean clt_batch_apply_man = false; // Apply (and disable) manual pixel shift
public boolean clt_batch_extrinsic = false; // Calibrate extrinsic parameters for each set
public boolean clt_batch_poly = false; // Calculate fine polynomial correction for each set
......@@ -132,8 +136,6 @@ public class EyesisCorrectionParameters {
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 String x3dModelVersion="v01";
public String jp4SubDir="jp4";
......@@ -248,6 +250,9 @@ public class EyesisCorrectionParameters {
cp.rig_batch_adjust_aux= this.rig_batch_adjust_aux;
cp.rig_batch_adjust_rig= this.rig_batch_adjust_rig;
cp.rig_batch_adjust_main_gt = this.rig_batch_adjust_main_gt;
cp.rig_batch_adjust_aux_gt = this.rig_batch_adjust_aux_gt;
cp.rig_batch_adjust_rig_gt = this.rig_batch_adjust_rig_gt;
cp.clt_batch_apply_man= this.clt_batch_apply_man;
cp.clt_batch_extrinsic= this.clt_batch_extrinsic;
......@@ -393,6 +398,11 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"rig_batch_adjust_aux", this.rig_batch_adjust_aux+"");
properties.setProperty(prefix+"rig_batch_adjust_rig", this.rig_batch_adjust_rig+"");
properties.setProperty(prefix+"rig_batch_adjust_main_gt", this.rig_batch_adjust_main_gt+"");
properties.setProperty(prefix+"rig_batch_adjust_aux_gt", this.rig_batch_adjust_aux_gt+"");
properties.setProperty(prefix+"rig_batch_adjust_rig_gt", this.rig_batch_adjust_rig_gt+"");
properties.setProperty(prefix+"clt_batch_apply_man", this.clt_batch_apply_man+"");
properties.setProperty(prefix+"clt_batch_extrinsic", this.clt_batch_extrinsic+"");
properties.setProperty(prefix+"clt_batch_poly", this.clt_batch_poly+"");
......@@ -533,6 +543,9 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"rig_batch_adjust_main")!=null) this.rig_batch_adjust_main=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_main"));
if (properties.getProperty(prefix+"rig_batch_adjust_aux")!=null) this.rig_batch_adjust_aux=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_aux"));
if (properties.getProperty(prefix+"rig_batch_adjust_rig")!=null) this.rig_batch_adjust_rig=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_rig"));
if (properties.getProperty(prefix+"rig_batch_adjust_main_gt")!=null) this.rig_batch_adjust_main_gt=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_main_gt"));
if (properties.getProperty(prefix+"rig_batch_adjust_aux_gt")!=null) this.rig_batch_adjust_aux_gt=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_aux_gt"));
if (properties.getProperty(prefix+"rig_batch_adjust_rig_gt")!=null) this.rig_batch_adjust_rig_gt=Integer.parseInt(properties.getProperty(prefix+"rig_batch_adjust_rig_gt"));
if (properties.getProperty(prefix+"clt_batch_apply_man")!= null) this.clt_batch_apply_man=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_apply_man"));
if (properties.getProperty(prefix+"clt_batch_extrinsic")!= null) this.clt_batch_extrinsic=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_extrinsic"));
......@@ -869,9 +882,13 @@ public class EyesisCorrectionParameters {
gd.addTab ("Batch", "Select Batch parameters");
gd.addNumericField("Repeat main camera field adjustment", this.rig_batch_adjust_main, 0);
gd.addNumericField("Repeat aux camera field adjustment", this.rig_batch_adjust_aux, 0);
gd.addNumericField("Repeat 2-quad camera rig field adjustment", this.rig_batch_adjust_rig, 0);
gd.addNumericField("Repeat main camera field adjustment (early, before rig)", this.rig_batch_adjust_main, 0);
gd.addNumericField("Repeat aux camera field adjustment (early, before rig)", this.rig_batch_adjust_aux, 0);
gd.addNumericField("Repeat 2-quad camera rig field adjustment (early, before late main/aux)", this.rig_batch_adjust_rig, 0);
gd.addNumericField("Repeat main camera field adjustment (late, with GT disparity from rig)", this.rig_batch_adjust_main_gt, 0);
gd.addNumericField("Repeat aux camera field adjustment (late, with GT disparity from rig)", this.rig_batch_adjust_aux_gt, 0);
gd.addNumericField("Repeat 2-quad camera rig field adjustment (late, after all others)", this.rig_batch_adjust_rig_gt, 0);
gd.addCheckbox ("Apply (and disable) manual pixel shift", this.clt_batch_apply_man); // 21
gd.addCheckbox ("Calibrate extrinsic parameters for each set", this.clt_batch_extrinsic); // 22
......@@ -938,6 +955,10 @@ public class EyesisCorrectionParameters {
this.rig_batch_adjust_aux = (int) gd.getNextNumber();
this.rig_batch_adjust_rig = (int) gd.getNextNumber();
this.rig_batch_adjust_main_gt = (int) gd.getNextNumber();
this.rig_batch_adjust_aux_gt = (int) gd.getNextNumber();
this.rig_batch_adjust_rig_gt = (int) gd.getNextNumber();
this.clt_batch_apply_man= gd.getNextBoolean(); // 21
this.clt_batch_extrinsic= gd.getNextBoolean(); // 22
this.clt_batch_poly= gd.getNextBoolean(); // 23
......@@ -2610,6 +2631,9 @@ public class EyesisCorrectionParameters {
public int lyf_min_samples = 5; // Minimal number of tiles remaining in the sample
public boolean lyf_norm_center = true; // Replace samples with a single average with equal weight
public double ly_corr_scale = 1.0; // Scale calculated correction vector
public boolean lyr_filter_ds = false; // true;
public boolean lyr_filter_lyf = false; // ~clt_parameters.lyf_filter, but may be different, now off for a single cameras
// old fcorr parameters, reuse?
// public int fcorr_sample_size = 32; // Use square this size side to detect outliers
......@@ -2965,7 +2989,7 @@ public class EyesisCorrectionParameters {
// comparing merge quality for plane pairs
public double plCostDist = 4.0; // Disparity (pix) - closer cost will use more of the real world, farther - disparity
public double plCostKrq = 0.8; // Cost of merge quality sqrt(weighted*equal) in disparity space
public double plCostKrqEq = 0.2; // Cost of merge quality averaje of weighted and equal weight in disparity space
public double plCostKrqEq = 0.2; // Cost of merge quality average of weighted and equal weight in disparity space
public double plCostWrq = 0.8; // Cost of merge quality sqrt(weighted*equal) in world space
public double plCostWrqEq = 0.2; // Cost of merge quality average of weighted and equal weight in world space
public double plCostSin2 = 10.0; // Cost of sin squared between normals
......@@ -3323,6 +3347,9 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"lyf_norm_center", this.lyf_norm_center+"");
properties.setProperty(prefix+"ly_corr_scale", this.ly_corr_scale +"");
properties.setProperty(prefix+"lyr_filter_ds", this.lyr_filter_ds +"");
properties.setProperty(prefix+"lyr_filter_lyf", this.lyr_filter_lyf +"");
properties.setProperty(prefix+"corr_magic_scale", this.corr_magic_scale +"");
properties.setProperty(prefix+"corr_select", this.corr_select +"");
......@@ -3986,6 +4013,9 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"lyf_norm_center")!=null) this.lyf_norm_center=Boolean.parseBoolean(properties.getProperty(prefix+"lyf_norm_center"));
if (properties.getProperty(prefix+"ly_corr_scale")!=null) this.ly_corr_scale=Double.parseDouble(properties.getProperty(prefix+"ly_corr_scale"));
if (properties.getProperty(prefix+"lyr_filter_ds")!=null) this.lyr_filter_ds=Boolean.parseBoolean(properties.getProperty(prefix+"lyr_filter_ds"));
if (properties.getProperty(prefix+"lyr_filter_lyf")!=null) this.lyr_filter_lyf=Boolean.parseBoolean(properties.getProperty(prefix+"lyr_filter_lyf"));
if (properties.getProperty(prefix+"corr_magic_scale")!=null) this.corr_magic_scale=Double.parseDouble(properties.getProperty(prefix+"corr_magic_scale"));
if (properties.getProperty(prefix+"corr_select")!=null) this.corr_select=Integer.parseInt(properties.getProperty(prefix+"corr_select"));
......@@ -4690,7 +4720,14 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Minimal number of tiles remaining in the sample", this.lyf_min_samples, 0);
gd.addCheckbox ("Replace samples with a single average with equal weight", this.lyf_norm_center);
gd.addNumericField("Scale calculated correction vector", this.ly_corr_scale, 3);
gd.addMessage ("---");
gd.addMessage ("--- Parameters specific to LY adjustments with dual-camera rig data (as ground truth ---");
gd.addCheckbox ("Use samples filter with rig data", this.lyr_filter_ds,
"Raw measured data may not need filtering when ground truth disparity is available");
gd.addCheckbox ("Filter lazy eye pairs by their values wen GT data is available", this.lyr_filter_lyf,
"Same as \"Filter lazy eye pairs by their values\" above, but for the rig-guided adjustments");
// gd.addNumericField("Use square this size side to detect outliers", this.fcorr_sample_size, 0);
// gd.addNumericField("Keep tiles only if there are more in each square", this.fcorr_mintiles, 0);
// gd.addNumericField("Remove this fraction of tiles from each sample", this.fcorr_reloutliers, 3);
......@@ -5090,7 +5127,7 @@ public class EyesisCorrectionParameters {
gd.addMessage ("--- Planes merge costs ---");
gd.addNumericField(" Disparity (pix) - closer cost will use more of the real world, farther - disparity",this.plCostDist, 6);
gd.addNumericField("Cost of merge quality sqrt(weighted*equal) in disparity space", this.plCostKrq, 6);
gd.addNumericField("Cost of merge quality averaje of weighted and equal weight in disparity space",this.plCostKrqEq, 6);
gd.addNumericField("Cost of merge quality average of weighted and equal weight in disparity space",this.plCostKrqEq, 6);
gd.addNumericField("Cost of merge quality sqrt(weighted*equal) in world space", this.plCostWrq, 6);
gd.addNumericField("Cost of merge quality average of weighted and equal weight in world space", this.plCostWrqEq, 6);
gd.addNumericField("Cost of sin squared between normals", this.plCostSin2, 6);
......@@ -5438,6 +5475,10 @@ public class EyesisCorrectionParameters {
this.lyf_min_samples= (int) gd.getNextNumber();
this.lyf_norm_center= gd.getNextBoolean();
this.ly_corr_scale= gd.getNextNumber();
this.lyr_filter_ds= gd.getNextBoolean();
this.lyr_filter_lyf= gd.getNextBoolean();
// this.fcorr_sample_size= (int)gd.getNextNumber();
// this.fcorr_mintiles= (int) gd.getNextNumber();
// this.fcorr_reloutliers= gd.getNextNumber();
......
......@@ -570,7 +570,7 @@ private Panel panel1,
addButton("CLT batch process", panelClt3, color_process);
addButton("CM Test", panelClt3, color_stop);
addButton("Show scan", panelClt3, color_configure);
addButton("Show all scans", panelClt3, color_configure);
add(panelClt3);
}
......@@ -4480,6 +4480,10 @@ private Panel panel1,
showScan();
return;
/* ======================================================================== */
} else if (label.equals("Show all scans")) {
showAllScans();
return;
/* ======================================================================== */
} else if (label.equals("Import Aux")) {
importAux();
......@@ -5944,8 +5948,6 @@ private Panel panel1,
}
}
public boolean getDCTShiftwDialog(double [] shiftXY) {
GenericDialog gd = new GenericDialog("Set DCT shift");
gd.addNumericField("X-shift", shiftXY[0], 2); //2
......@@ -5968,8 +5970,8 @@ private Panel panel1,
System.out.println(msg);
return false;
}
int scan_index = 0;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",400,100);
int scan_index = QUAD_CLT.tp.clt_3d_passes.size()-1;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Select scan to show",400,100);
gd.addNumericField("Scan index (0..."+(QUAD_CLT.tp.clt_3d_passes.size()-1), scan_index, 0, 2, "",
"Display scan by index");
......@@ -5982,6 +5984,58 @@ private Panel panel1,
}
public boolean showAllScans() {
if ((QUAD_CLT == null) || (QUAD_CLT.tp == null) || (QUAD_CLT.tp.clt_3d_passes == null)) {
String msg = "DSI data is not available. Please run \"CLT 3D\" first";
IJ.showMessage("Error",msg);
System.out.println(msg);
return false;
}
int scan_index = 0;
String [] titles = QUAD_CLT.tp.getScanTitles();
GenericJTabbedDialog gd = new GenericJTabbedDialog("Select scan slice to show",400,800);
gd.addMessage("Select scan types to show");
gd.addCheckbox("All scans", true, "Include all types of scans");
gd.addCheckbox("Measured scans", false,"Include measured scans");
gd.addCheckbox("Processed scans", false,"Include processed scans");
gd.addCheckbox("Combo scans", false,"Include combo scans");
gd.addMessage("Select slice to show (only first selected will be shown)");
for (int i = 0; i < titles.length; i++ ) {
gd.addCheckbox(i+": "+titles[i], false); // 0
}
gd.showDialog();
if (gd.wasCanceled()) return false;
boolean all = gd.getNextBoolean();
boolean measured = gd.getNextBoolean();
boolean processed = gd.getNextBoolean();
boolean combo = gd.getNextBoolean();
boolean [] bslice = new boolean [titles.length];
for (int i = 0; i < titles.length;i++) {
bslice[i] = gd.getNextBoolean();
}
int slice =-1;
for (int i = 0; i < bslice.length; i++) if (bslice[i]) {
slice = i;
break;
}
if (slice < 0) {
System.out.println("Slice not selected");
return false;
}
QUAD_CLT.tp.showAllScans(
"SCANS", // String title,
slice, // int slice,
all, // boolean all,
measured, // boolean measured,
processed, // boolean processed,
combo); // boolean combo);
return true;
}
public boolean cm_test() {
double hsize_x = 1.5;
double hsize_y = 1.5;
......
......@@ -610,8 +610,8 @@ public class GeometryCorrection {
diff_x, // used only with target_disparity == 0
diff_y,
target_disparity);
if (debugLevel>-1) {
System.out.println("getRigCorrection(): Current RMS = "+rms);
if (debugLevel>-4) {
System.out.println("getRigCorrection(): Current RMS = "+rms+ "(debugLevel= "+debugLevel+")");
};
double [][] jt = getJacobianTransposed( // npe
qc_main.geometryCorrection, // GeometryCorrection gc_main,
......@@ -707,7 +707,7 @@ public class GeometryCorrection {
rXY_aux[i][0] = xc_pix + Math.cos(aux_roll)*rXY[i][0] + ssr*Math.sin(aux_roll)*rXY[i][1];
rXY_aux[i][1] = yc_pix - ssr*Math.sin(aux_roll)*rXY[i][0] + Math.cos(aux_roll)*rXY[i][1];
}
if (debugLevel > -2) {
if (debugLevel > 0) {
System.out.println("Auxiliary camera offsets per 1 nominal disparity pixel");
for (int i = 0; i <rXY_aux.length;i++) {
System.out.println(String.format("Camera %1d x = %8f y = %8f",i,rXY_aux[i][0],rXY_aux[i][1]));
......
......@@ -1538,11 +1538,12 @@ public class ImageDtt {
final double scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
final double diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
final double diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
final boolean diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
final boolean diff_gauss, // true; // when averaging images, use Gaussian around average as weight (false - sharp all/nothing)
final double min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
final boolean dust_remove, // Do not reduce average weight when only one image differes much from the average
final boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
final boolean keep_weights, // Add port weights to RGBA stack (debug feature)
final GeometryCorrection geometryCorrection,
final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
final int kernel_step,
final int transform_size,
......@@ -1729,7 +1730,13 @@ public class ImageDtt {
System.out.println("macro_mode="+macro_mode);
}
final Matrix [] corr_rots = geometryCorrection.getCorrVector().getRotMatrices(); // get array of per-sensor rotation matrices
Matrix [] corr_rots_aux = null;
if (geometryCorrection_main != null) {
corr_rots_aux = geometryCorrection.getCorrVector().getRotMatrices(geometryCorrection.getRotMatrix(true));
}
final boolean use_main = corr_rots_aux != null;
final Matrix [] corr_rots = use_main ? corr_rots_aux : geometryCorrection.getCorrVector().getRotMatrices(); // get array of per-sensor rotation matrices
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
......@@ -1793,6 +1800,19 @@ public class ImageDtt {
centerY,
macro_scale* disparity_array[tileY][tileX] + disparity_corr);
} else {
if (use_main) { // this is AUX camera that uses main coordinates
centersXY = geometryCorrection.getPortsCoordinatesAndDerivatives(
geometryCorrection_main, // GeometryCorrection gc_main,
true, // boolean use_rig_offsets,
corr_rots, // Matrix [] rots,
null, // Matrix [][] deriv_rots,
null, // double [][] pXYderiv, // if not null, should be double[8][]
centerX,
centerY,
disparity_array[tileY][tileX] + disparity_corr); // _aux); // + disparity_corr);
} else {
centersXY = geometryCorrection.getPortsCoordinatesAndDerivatives(
geometryCorrection, // GeometryCorrection gc_main,
......@@ -1803,6 +1823,7 @@ public class ImageDtt {
centerX,
centerY,
disparity_array[tileY][tileX] + disparity_corr);
}
if ((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)) {
for (int i = 0; i < quad; i++) {
......@@ -5567,6 +5588,7 @@ public class ImageDtt {
final boolean dust_remove, // Do not reduce average weight when only one image differes much from the average
final boolean keep_weights, // Add port weights to RGBA stack (debug feature)
final GeometryCorrection geometryCorrection,
final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
final int kernel_step,
final int transform_size,
......@@ -5632,6 +5654,7 @@ public class ImageDtt {
dust_remove, // Do not reduce average weight when only one image differes much from the average
keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection,
geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
kernel_step,
transform_size,
......
......@@ -113,6 +113,11 @@ public class MacroCorrelation {
final double [][][] input_data = new double [ImageDtt.QUAD][num_chn][mTiles*tileSize*tileSize];
// double [][] tiles_tone = src_scan.getTileRBGA( No, we need individual subcameras
// 4); // int num_layers);
// TODO: add other channels (average tone)
// Maybe filter bright matching from infinity
for (int sub_cam =0; sub_cam < input_data.length; sub_cam++){
for (int pty = 0; pty < pTilesY; pty++){
for (int ptx = 0; ptx < pTilesX; ptx++){
......@@ -259,6 +264,7 @@ public class MacroCorrelation {
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
null, // clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
......
......@@ -4035,6 +4035,7 @@ public class QuadCLT {
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
......@@ -5170,6 +5171,7 @@ public class QuadCLT {
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
......@@ -5836,7 +5838,10 @@ public class QuadCLT {
}
//TODO: Move away from here?
boolean no_image_save = true;
ImagePlus imp_bgnd = getBackgroundImage(
no_image_save, // boolean no_image,
clt_parameters,
colorProcParameters,
rgbParameters,
......@@ -5860,6 +5865,10 @@ public class QuadCLT {
tp.clt_3d_passes);
x3dOutput.generateBackground(clt_parameters.infinityDistance <= 0.0); // needs just first (background) scan
/* */
// refine first measurement
int bg_pass = tp.clt_3d_passes.size() - 1; // 0
int refine_pass = tp.clt_3d_passes.size(); // 1
......@@ -6529,14 +6538,20 @@ public class QuadCLT {
comp_diff += new_corr[0][0][i] * new_corr[0][0][i];
}
comp_diff = Math.sqrt(comp_diff);
if (debugLevel > -10) { // should work even in batch mode
System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]+ " (debugLevel = "+debugLevel+")");
}
if (debugLevel > -2) {
if ((debugLevel > -1) || (comp_diff < min_sym_update)) {
System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]);
// System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
// comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]);
System.out.println("New extrinsic corrections:");
System.out.println(geometryCorrection.getCorrVector().toString());
}
}
if (comp_diff < min_sym_update) {
break;
}
......@@ -6554,9 +6569,12 @@ public class QuadCLT {
final boolean updateStatus,
final int debugLevel)
{
final boolean filter_ds = clt_parameters.lyr_filter_ds; // = false; // true;
final boolean filter_lyf = clt_parameters.lyr_filter_lyf; // = false; // ~clt_parameters.lyf_filter, but may be different, now off for a single cameras
final boolean batch_mode = clt_parameters.batch_run;
int debugLevelInner = batch_mode ? -5: debugLevel;
// boolean update_disp_from_latest = clt_parameters.lym_update_disp ; // true;
int max_tries = clt_parameters.lym_iter; // 25;
double min_sym_update = clt_parameters.lym_change; // 4e-6; // stop iterations if no angle changes more than this
double min_poly_update = clt_parameters.lym_poly_change; // Parameter vector difference to exit from polynomial correction
......@@ -6580,6 +6598,20 @@ public class QuadCLT {
}
}
}
GeometryCorrection geometryCorrection_main = null;
if (geometryCorrection.getRotMatrix(true) != null) {
geometryCorrection_main = twoQuadCLT.quadCLT_main.getGeometryCorrection();
double disparityScale = geometryCorrection.getDisparityRadius()/geometryCorrection_main.getDisparityRadius();
for (int i = 0; i < rig_disp_strength[0].length; i++) {
rig_disp_strength[0][i] *= disparityScale;
}
if (debugLevel > -2) {
System.out.println("This is an AUX camera, using MAIN camera coordinates");
}
}
CLTPass3d comboScan = tp.compositeScan(
rig_disp_strength[0], // final double [] disparity,
......@@ -6602,6 +6634,7 @@ public class QuadCLT {
false, // final boolean save_textures,
true, // final boolean save_corr,
combo_mismatch, // final double [][] mismatch, // null or double [12][]
geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // If not null - covert to main camera coordinates
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner - 1);
......@@ -6623,11 +6656,10 @@ public class QuadCLT {
}
double [][][] new_corr;
final boolean filter_ds = false; // true;
final boolean filter_lyf = false; // ~clt_parameters.lyf_filter, but may be different, now off for a single cameras
final double inf_max_disparity = 2.0;
double [][][] gt_disparity_strength = {rig_disp_strength};
new_corr = ac.lazyEyeCorrectionFromGT(
geometryCorrection_main, //final GeometryCorrection geometryCorrection_main, // if not null - this is an AUX camera of a rig
adjust_poly, // final boolean use_poly,
true, // final boolean restore_disp_inf, // Restore subtracted disparity for scan #0 (infinity)
clt_parameters.fcorr_radius, // final double fcorr_radius,
......@@ -6693,10 +6725,15 @@ public class QuadCLT {
comp_diff += new_corr[0][0][i] * new_corr[0][0][i];
}
comp_diff = Math.sqrt(comp_diff);
if (debugLevel > -10) { // should work even in batch mode
System.out.println("#### extrinsicsCLTfromGT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]+ " (debugLevel = "+debugLevel+")");
}
if (debugLevel > -2) {
if ((debugLevel > -1) || (comp_diff < min_sym_update)) {
System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]);
// System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
// comp_diff + " ("+min_sym_update+"), previous RMS = " + new_corr[0][1][0]);
System.out.println("New extrinsic corrections:");
System.out.println(geometryCorrection.getCorrVector().toString());
}
......@@ -6715,16 +6752,13 @@ public class QuadCLT {
public boolean expandCLTQuad3d(
// ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
// EyesisCorrectionParameters.NonlinParameters nonlinParameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
// final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
......@@ -7774,6 +7808,7 @@ public class QuadCLT {
public ImagePlus getBackgroundImage(
boolean no_image_save,
EyesisCorrectionParameters.CLTParameters clt_parameters,
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
......@@ -7905,8 +7940,6 @@ public class QuadCLT {
if (num_bgnd < clt_parameters.min_bgnd_tiles){
return null; // no background to generate
}
ImageDtt image_dtt = new ImageDtt();
double [][] texture_overlap = image_dtt.combineRGBATiles(
texture_tiles_bgnd, // texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
......@@ -7969,12 +8002,14 @@ public class QuadCLT {
clt_parameters.show_textures,
jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
}
if (!no_image_save) {
eyesisCorrections.saveAndShow(
imp_texture_bgnd_ext,
path,
correctionsParameters.png && !clt_parameters.black_back,
clt_parameters.show_textures,
jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
}
return imp_texture_bgnd_ext;
}
......@@ -8256,6 +8291,7 @@ public class QuadCLT {
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
......@@ -8470,6 +8506,7 @@ public class QuadCLT {
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
......@@ -8505,6 +8542,7 @@ public class QuadCLT {
final boolean save_textures,
final boolean save_corr,
final double [][] mismatch, // null or double [12][]
final GeometryCorrection geometryCorrection_main, // If not null - covert to main camera coordinates
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
......@@ -8599,6 +8637,7 @@ public class QuadCLT {
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
geometryCorrection_main, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
clt_parameters.transform_size,
......
......@@ -30,6 +30,29 @@ import java.util.concurrent.atomic.AtomicInteger;
public class TileProcessor {
public static String [] SCAN_TITLES = {
"tile_op", // 0
"final", // 1 - calculated, filtered, combined disparity
"disparity", // 2
"disp_cm", // 3
"disp_hor", // 4
"disp_vert", // 5
"final_strength",// 6
"strength", // 7
"strength_hor", // 8
"strength_vert", // 9
"selection", // 10
"border_tiles", // 11
"max_tried", // 12
"diff0", // 13
"diff1", // 14
"diff2", // 15
"diff3", // 16
"diff2max", // 17
"diff2maxAvg", // 18
"normStrength", // 19
"overexp"}; // 20
public ArrayList <CLTPass3d> clt_3d_passes = null;
public double [][] rig_disparity_strength = null; // Disparity and strength created by a two-camera rig, with disparity scale and distortions of the main camera
public double [][] rig_pre_poles_ds = null; // Rig disparity and strength before processing poles
......@@ -2163,44 +2186,68 @@ public class TileProcessor {
}
return num_op_tiles; // num_extended;
}
public void showAllScans(
String in_title,
int slice,
boolean all,
boolean measured,
boolean processed,
boolean combo)
{
String title = in_title+"_"+getScanTitles()[slice];
String [] titles = new String[clt_3d_passes.size()];
double [][] dbg_img = new double [titles.length][];
int num_slices=0;
for (int nscan = 0; nscan < titles.length; nscan++) {
CLTPass3d scan = clt_3d_passes.get(nscan);
if (all ||
(measured && scan.isMeasured()) ||
(processed && scan.isProcessed()) ||
(combo && scan.isCombo())) {
titles[nscan] = nscan+"_";
if (scan.isMeasured()) titles[nscan] += "+M"; else titles[nscan]+="-M";
if (scan.isProcessed()) titles[nscan] += "+P"; else titles[nscan]+="-P";
if (scan.isCombo()) titles[nscan] += "+C"; else titles[nscan]+="-C";
if (scan.getTextureTiles()!=null) titles[nscan] += "+T"; else titles[nscan]+="-T";
dbg_img[nscan] = getShowScan(scan)[slice];
if (dbg_img[nscan] != null) num_slices++;
}
}
if (num_slices > 0) {
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX, tilesY, true, title, titles);
}
// QUAD_CLT.tp.showScan(QUAD_CLT.tp.clt_3d_passes.get(scan_index),"Scan-"+scan_index);
}
public String [] getScanTitles() {
return SCAN_TITLES;
}
public void showScan(
CLTPass3d scan,
String in_title)
{
showDoubleFloatArrays sdfa_instance = null;
sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
String [] titles = {
"tile_op", // 0
"final", // 1 - calculated, filtered, combined disparity
"disparity", // 2
"disp_cm", // 3
"disp_hor", // 4
"disp_vert", // 5
"final_strength",// 6
"strength", // 7
"strength_hor", // 8
"strength_vert", // 9
"selection", // 10
"border_tiles", // 11
"max_tried", // 12
"diff0", // 13
"diff1", // 14
"diff2", // 15
"diff3", // 16
"diff2max", // 17
"diff2maxAvg", // 18
"normStrength", // 19
"overexp"}; // 20
String [] titles = getScanTitles();
String title=in_title;
if (scan.isMeasured()) title+="+M"; else title+="-M";
if (scan.isProcessed()) title+="+P"; else title+="-P";
if (scan.isCombo()) title+="+C"; else title+="-C";
if (scan.getTextureTiles()!=null) title+="+T"; else title+="-T";
double [][] dbg_img = getShowScan(scan);
(new showDoubleFloatArrays()).showArrays(dbg_img, tilesX, tilesY, true, title,titles);
System.out.println("showScan("+title+"): isMeasured()="+scan.isMeasured()+", isProcessed()="+scan.isProcessed()+", isCombo()="+scan.isCombo());
}
public double [][] getShowScan(
CLTPass3d scan)
{
int NUM_SLICES=getScanTitles().length;
int tlen = tilesX*tilesY;
double [][] dbg_img = new double[titles.length][];
double [][] dbg_img = new double[NUM_SLICES][];
if (scan.tile_op != null) dbg_img[ 0] = new double[tlen];
if (scan.disparity != null) dbg_img[ 2] = new double[tlen];
if (scan.selected != null) dbg_img[10] = new double[tlen];
......@@ -2247,18 +2294,12 @@ public class TileProcessor {
}
}
}
// title += "-";
// if (scan.isMeasured()) title += "M";
// if (scan.isProcessed()) title += "P";
// if (scan.isCombo()) title += "C";
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, title,titles);
System.out.println("showScan("+title+"): isMeasured()="+scan.isMeasured()+", isProcessed()="+scan.isProcessed()+", isCombo()="+scan.isCombo());
return dbg_img;
}
public boolean [] getBackgroundMask( // which tiles do belong to the background
double bgnd_range, // disparity range to be considered background
double bgnd_sure, // minimal strength to be considered definitely background
......
......@@ -885,7 +885,7 @@ public class TwoQuadCLT {
saturation_imp_aux, //output // boolean [][] saturation_imp,
debugLevel); // int debugLevel);
// Tempporarily processing individually with the old code
// Temporary processing individually with the old code
processInfinityRig(
quadCLT_main, // QuadCLT quadCLT_main,
quadCLT_aux, // QuadCLT quadCLT_aux,
......@@ -1072,6 +1072,10 @@ if (debugLevel > -100) return true; // temporarily !
double [][] disparity_bimap = null;
int [] num_new = new int[1];
for (int num_full_cycle = 0; num_full_cycle < clt_parameters.rig.rig_adjust_full_cycles;num_full_cycle++) {
if (debugLevel > -5) {
System.out.println("processInfinityRig(), reselecting and re-measuring tiles (may increase RMS), full_cycle "+
(num_full_cycle + 1)+" of "+clt_parameters.rig.rig_adjust_full_cycles);
}
disparity_bimap = null;
ArrayList<Integer> tile_list = new ArrayList<Integer>();
// measure and refine
......@@ -2174,7 +2178,7 @@ if (debugLevel > -100) return true; // temporarily !
}
}
if (clt_parameters.show_map && (debugLevel > -3) && clt_parameters.rig.rig_mode_debug){
if (clt_parameters.show_map && (debugLevel > -3) && clt_parameters.rig.rig_mode_debug && !clt_parameters.batch_run){
(new showDoubleFloatArrays()).showArrays(
disparity_bimap,
tilesX,
......@@ -5350,7 +5354,7 @@ if (debugLevel > -100) return true; // temporarily !
boolean [][] saturation_imp_aux = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles_main.length][] : null;
double [] scaleExposures_main = new double[channelFiles_main.length];
double [] scaleExposures_aux = new double[channelFiles_main.length];
if (updateStatus) IJ.showStatus("Conditioning main camera image set for "+quadCLT_main.image_name);
ImagePlus [] imp_srcs_main = quadCLT_main.conditionImageSet(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
sourceFiles, // String [] sourceFiles,
......@@ -5360,7 +5364,7 @@ if (debugLevel > -100) return true; // temporarily !
scaleExposures_main, //output // double [] scaleExposures
saturation_imp_main, //output // boolean [][] saturation_imp,
debugLevelInner); // int debugLevel);
if (updateStatus) IJ.showStatus("Conditioning aux camera image set for "+quadCLT_main.image_name);
ImagePlus [] imp_srcs_aux = quadCLT_aux.conditionImageSet(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
sourceFiles, // String [] sourceFiles,
......@@ -5372,10 +5376,14 @@ if (debugLevel > -100) return true; // temporarily !
debugLevelInner); // int debugLevel);
// optionally adjust main, aux, rig here
// Early main camera adjustment, rig data is not available
for (int num_adjust_main = 0; num_adjust_main < quadCLT_main.correctionsParameters.rig_batch_adjust_main; num_adjust_main++) {
// FIXME: add optional second run of adjustments using rig data getBiScan() -> non-null, and so skip *.preExpandCLTQuad3d()
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_main+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_main);
if (debugLevel > -5) {
System.out.println("Building basic DSI for the main camera image set "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_main+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_main);
}
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
......@@ -5387,19 +5395,32 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
// adjust extrinsics here
System.out.println("Adjust main extrinsics here");
if (updateStatus) IJ.showStatus("Adjusting main camera image set for "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_main+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_main);
if (debugLevel > -5) {
System.out.println("Adjusting main camera image set for "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_main+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_main);
}
quadCLT_main.extrinsicsCLT(
// this, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
}
// Early aux camera adjustment, rig data is not available
for (int num_adjust_aux = 0; num_adjust_aux < quadCLT_main.correctionsParameters.rig_batch_adjust_aux; num_adjust_aux++) {
if (updateStatus) IJ.showStatus("Building basic DSI for the aux camera image set "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_aux+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_aux);
if (debugLevel > -5) {
System.out.println("Building basic DSI for the aux camera image set "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_aux+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_aux);
}
quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
......@@ -5411,17 +5432,30 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus,
debugLevelInner);
// adjust extrinsics here
System.out.println("Adjust aux extrinsics here");
if (updateStatus) IJ.showStatus("Adjusting aux camera image set for "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_aux+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_aux);
if (debugLevel > -5) {
System.out.println("Adjusting aux camera image set for "+quadCLT_main.image_name+
" (w/o rig), pass "+(num_adjust_aux+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_aux);
}
quadCLT_aux.extrinsicsCLT(
// this, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevelInner); // final int debugLevel)
// clear memory for aux
quadCLT_aux.tp.resetCLTPasses();
}
// Early rig adjustment, main/aux are not adjusted with rig data
for (int num_adjust_rig = 0; num_adjust_rig < quadCLT_main.correctionsParameters.rig_batch_adjust_rig; num_adjust_rig++) {
if (updateStatus) IJ.showStatus("Adjusting dual camera rig infinity (early) for "+quadCLT_main.image_name+
", pass "+(num_adjust_rig+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_rig);
if (debugLevel > -5) {
System.out.println("Adjusting dual camera rig infinity (early) for "+quadCLT_main.image_name+
", pass "+(num_adjust_rig+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_rig);
}
processInfinityRig(
quadCLT_main, // QuadCLT quadCLT_main,
quadCLT_aux, // QuadCLT quadCLT_aux,
......@@ -5434,14 +5468,131 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus,
debugLevelInner-2); // final int debugLevel);
}
// Delete previous results if any camera adjustments were made
if ( (quadCLT_main.correctionsParameters.rig_batch_adjust_main > 0) ||
(quadCLT_main.correctionsParameters.rig_batch_adjust_aux > 0) ||
(quadCLT_main.correctionsParameters.rig_batch_adjust_rig > 0)) {
if (debugLevel > -5) {
System.out.println("\n---- Field adjustments after the first round ----");
quadCLT_main.showExtrinsicCorr("main"); // show_fine_corr("main");
quadCLT_aux.showExtrinsicCorr("aux"); // show_fine_corr("aux");
quadCLT_aux.geometryCorrection.showRig();// show_fine_corr("aux");
}
biCamDSI_persistent = null;
quadCLT_main.tp.resetCLTPasses();
quadCLT_aux.tp.resetCLTPasses();
}
if ((quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt > 0) ||
(quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt > 0)){
{
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+ " (post rig adjustment)");
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
if (updateStatus) IJ.showStatus("Expanding DSI for the main camera image set "+quadCLT_main.image_name+ " (post rig adjustment)");
quadCLT_main.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters,
debayerParameters,
colorProcParameters,
channelGainParameters,
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (updateStatus) IJ.showStatus("Refining main camera DSI with the rig for "+quadCLT_main.image_name);
// Prepare DSI from the main camera, then refine it with the rig to get the "GT" data for the main/aux
BiScan scan = rigInitialScan(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
if (scan == null) {
System.out.println("***** Failed to get main camera DSI and refine it with the rig, aborting this image set *****");
continue;
}
}
}
for (int num_adjust_main = 0; num_adjust_main < quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt; num_adjust_main++) {
if (updateStatus) IJ.showStatus("Adjusting main camera image set for "+quadCLT_main.image_name+
" (with rig DSI), pass "+(num_adjust_main+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt);
if (debugLevel > -5) {
System.out.println("Adjusting main camera image set for "+quadCLT_main.image_name+
" (with rig DSI), pass "+(num_adjust_main+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt);
}
quadCLT_main.extrinsicsCLTfromGT(
this, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
}
for (int num_adjust_aux = 0; num_adjust_aux < quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt; num_adjust_aux++) {
if (updateStatus) IJ.showStatus("Adjusting aux camera image set for "+quadCLT_main.image_name+
" (with rig DSI), pass "+(num_adjust_aux+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt);
if (debugLevel > -5) {
System.out.println("Adjusting aux camera image set for "+quadCLT_main.image_name+
" (with rig DSI), pass "+(num_adjust_aux+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt);
}
quadCLT_aux.extrinsicsCLTfromGT(
this, // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
}
// Late rig adjustment, after main/aux are adjusted with rig data as ground truth
// keeping the same DSI, required measurements will be performed anyway
for (int num_adjust_rig = 0; num_adjust_rig < quadCLT_main.correctionsParameters.rig_batch_adjust_rig_gt; num_adjust_rig++) {
if (updateStatus) IJ.showStatus("Adjusting dual camera rig infinity (late, after re-adjustment of the main/aux) for "+quadCLT_main.image_name+
", pass "+(num_adjust_rig+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_rig_gt);
if (debugLevel > -5) {
System.out.println("Adjusting dual camera rig infinity (late, after re-adjustment of the main/aux) for "+quadCLT_main.image_name+
", pass "+(num_adjust_rig+1)+" of "+quadCLT_main.correctionsParameters.rig_batch_adjust_rig_gt);
}
processInfinityRig(
quadCLT_main, // QuadCLT quadCLT_main,
quadCLT_aux, // QuadCLT quadCLT_aux,
imp_srcs_main, // ImagePlus [] imp_quad_main,
imp_srcs_aux, // ImagePlus [] imp_quad_aux,
saturation_imp_main, // boolean [][] saturation_main, // (near) saturated pixels or null
saturation_imp_aux, // boolean [][] saturation_aux, // (near) saturated pixels or null
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevelInner-2); // final int debugLevel);
}
// Delete previous results if any of the late adjustments were performed
if ( (quadCLT_main.correctionsParameters.rig_batch_adjust_main_gt > 0) ||
(quadCLT_main.correctionsParameters.rig_batch_adjust_aux_gt > 0) ||
(quadCLT_main.correctionsParameters.rig_batch_adjust_rig_gt > 0)) {
if (debugLevel > -5) {
System.out.println("\n---- Field adjustments after the second round ----");
quadCLT_main.showExtrinsicCorr("main"); // show_fine_corr("main");
quadCLT_aux.showExtrinsicCorr("aux"); // show_fine_corr("aux");
quadCLT_aux.geometryCorrection.showRig();// show_fine_corr("aux");
}
biCamDSI_persistent = null;
quadCLT_main.tp.resetCLTPasses();
quadCLT_aux.tp.resetCLTPasses();
......@@ -5449,6 +5600,7 @@ if (debugLevel > -100) return true; // temporarily !
// Generate 8 images and thumbnails
if (quadCLT_main.correctionsParameters.clt_batch_4img){
if (updateStatus) IJ.showStatus("Rendering 8 image set (disparity = 0) for "+quadCLT_main.image_name);
processCLTQuadCorrPair(
quadCLT_main, // QuadCLT quadCLT_main,
quadCLT_aux, // QuadCLT quadCLT_aux,
......@@ -5474,6 +5626,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main.tp.resetCLTPasses();
quadCLT_aux.tp.resetCLTPasses();
if (quadCLT_main.correctionsParameters.clt_batch_explore) {
if (updateStatus) IJ.showStatus("Building basic DSI for the main camera image set "+quadCLT_main.image_name+" (after all adjustments)");
quadCLT_main.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
......@@ -5484,6 +5637,7 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
if (updateStatus) IJ.showStatus("Expanding DSI for the main camera image set "+quadCLT_main.image_name+" (after all adjustments)");
quadCLT_main.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters,
debayerParameters,
......@@ -5493,7 +5647,7 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (updateStatus) IJ.showStatus("Creating \"ground truth\" DSI using dual-camera rig "+quadCLT_main.image_name);
groundTruth( // actually there is no sense to process multiple image sets. Combine with other processing?
quadCLT_main, // QuadCLT quadCLT_main,
quadCLT_aux, // QuadCLT quadCLT_aux,
......@@ -5501,16 +5655,17 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevelInner-2); // final int debugLevel);
} else {
continue;
}
// biCamDSI_persistent = null; // to save memory
resetRig (false);
resetRig (false); // includes biCamDSI_persistent = null
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (quadCLT_main.correctionsParameters.clt_batch_surf) {
if (updateStatus) IJ.showStatus("Creating and filtering supertile plane surfaces from the DSI "+quadCLT_main.image_name);
quadCLT_main.tp.showPlanes(
clt_parameters,
quadCLT_main.geometryCorrection,
......@@ -5521,6 +5676,7 @@ if (debugLevel > -100) return true; // temporarily !
} else continue; // if (correctionsParameters.clt_batch_surf)
if (quadCLT_main.correctionsParameters.clt_batch_assign) {
if (updateStatus) IJ.showStatus("Assigning tiles to candidate surfaces "+quadCLT_main.image_name);
boolean ok = quadCLT_main.tp.assignTilesToSurfaces(
clt_parameters,
quadCLT_main.geometryCorrection,
......@@ -5531,6 +5687,7 @@ if (debugLevel > -100) return true; // temporarily !
} else continue; // if (correctionsParameters.clt_batch_assign)
if (quadCLT_main.correctionsParameters.clt_batch_gen3d) {
if (updateStatus) IJ.showStatus("Generating and exporting 3D scene model "+quadCLT_main.image_name);
boolean ok = quadCLT_main.output3d(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......
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