Commit 26cdc535 authored by Andrey Filippov's avatar Andrey Filippov

Implementing batch mode for EO/LWIR images

parent be9da419
......@@ -181,7 +181,15 @@ public class CLTParameters {
public int ly_par_sel = 0; // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use checkbox selections above)
public boolean ly_right_left= false; // equalize weights of right/left FoV (use with horizon in both halves and gross infinity correction)
public double ly_inf_frac = 0.5; // Relative weight of infinity calibration data
public int ly_per_quad = 10; // minimal tiles per quadrant (not counting the worst) tp proceed
public double ly_per_quad_r = 0.01; // minimal relative tiles per quadrant (not counting the worst) tp proceed
public int ly_inf = 10; // minimal number of tiles at infinity to proceed
public double ly_inf_r = 0.01; // minimal relative number of tiles at infinity to proceed
public int ly_inf_scale = 20; // minimal number of tiles at infinity to apply weight scaling
public double ly_inf_scale_r = 0.02; // minimal relative number of tiles at infinity to apply weight scaling
public double ly_inf_frac = 0.7; // Relative weight of infinity calibration data
public double ly_inf_max_disparity = 0.2; // Maximal disparity to be treated as infinity when adjusting with rig data
public boolean ly_inf_disp= false; // Correct disparity for infinity tiles
public boolean ly_inf_force= false; // Force convergence correction during extrinsic, even with no infinity data
......@@ -191,8 +199,14 @@ public class CLTParameters {
public int ly_smpl_num = 5; // Number after removing worst (should be >1)
// public double ly_meas_disp = 1.5; // Maximal measured relative disparity - using (0.8*disp_scan_step)
public double ly_smpl_rms = 0.2; // 1; // Maximal RMS of the remaining tiles in a sample
public double ly_disp_var = 0.5; // 2; // Maximal full disparity difference to 8 neighbors
public double ly_disp_rvar = 0.02; // Maximal relative full disparity difference to 8 neighbors
public double ly_disp_var = 0.1; // Maximal full disparity difference to 8 neighbors
public double ly_disp_rvar = 0.01; // Maximal relative full disparity difference to 8 neighbors
public double ly_disp_var_gt = 0.5; // Maximal full disparity difference to 8 neighbors when GT is available
public double ly_disp_rvar_gt = 0.05; // Maximal relative full disparity difference to 8 neighbors when GT is available
public double ly_norm_disp = 5.0; // Reduce weight of higher disparity tiles
// Lazy eye multi-step fitting
......@@ -796,6 +810,15 @@ public class CLTParameters {
return aux ? lym_change_aux : lym_change;
}
public int getLyPerQuad (int num_tiles) {
return (int) Math.max(ly_per_quad_r * num_tiles , ly_per_quad );
}
public int getLyInf (int num_tiles) {
return (int) Math.max(ly_inf_r * num_tiles , ly_inf );
}
public int getLyInfScale (int num_tiles) {
return (int) Math.max(ly_inf_scale_r * num_tiles , ly_inf_scale );
}
public CLTParameters(){}
public void setProperties(String prefix,Properties properties){
......@@ -945,6 +968,13 @@ public class CLTParameters {
properties.setProperty(prefix+"ly_par_sel", this.ly_par_sel+"");
properties.setProperty(prefix+"ly_right_left", this.ly_right_left+"");
properties.setProperty(prefix+"ly_per_quad", this.ly_per_quad +"");
properties.setProperty(prefix+"ly_per_quad_r", this.ly_per_quad_r +"");
properties.setProperty(prefix+"ly_inf", this.ly_inf +"");
properties.setProperty(prefix+"ly_inf_r", this.ly_inf_r +"");
properties.setProperty(prefix+"ly_inf_scale", this.ly_inf_scale +"");
properties.setProperty(prefix+"ly_inf_scale_r", this.ly_inf_scale_r +"");
properties.setProperty(prefix+"ly_inf_frac", this.ly_inf_frac +"");
properties.setProperty(prefix+"ly_inf_max_disparity", this.ly_inf_max_disparity +"");
......@@ -957,6 +987,8 @@ public class CLTParameters {
properties.setProperty(prefix+"ly_smpl_rms", this.ly_smpl_rms +"");
properties.setProperty(prefix+"ly_disp_var", this.ly_disp_var +"");
properties.setProperty(prefix+"ly_disp_rvar", this.ly_disp_rvar +"");
properties.setProperty(prefix+"ly_disp_var_gt", this.ly_disp_var_gt +"");
properties.setProperty(prefix+"ly_disp_rvar_gt", this.ly_disp_rvar_gt +"");
properties.setProperty(prefix+"ly_norm_disp", this.ly_norm_disp +"");
properties.setProperty(prefix+"lym_overexp", this.lym_overexp +"");
properties.setProperty(prefix+"lym_update_disp", this.lym_update_disp+"");
......@@ -1653,6 +1685,13 @@ public class CLTParameters {
if (properties.getProperty(prefix+"ly_par_sel")!=null) this.ly_par_sel=Integer.parseInt(properties.getProperty(prefix+"ly_par_sel"));
if (properties.getProperty(prefix+"ly_right_left")!=null) this.ly_right_left=Boolean.parseBoolean(properties.getProperty(prefix+"ly_right_left"));
if (properties.getProperty(prefix+"ly_per_quad")!=null) this.ly_per_quad=Integer.parseInt(properties.getProperty(prefix+"ly_per_quad"));
if (properties.getProperty(prefix+"ly_per_quad_r")!=null) this.ly_per_quad_r=Double.parseDouble(properties.getProperty(prefix+"ly_per_quad_r"));
if (properties.getProperty(prefix+"ly_inf")!=null) this.ly_inf=Integer.parseInt(properties.getProperty(prefix+"ly_inf"));
if (properties.getProperty(prefix+"ly_inf_r")!=null) this.ly_inf_r=Double.parseDouble(properties.getProperty(prefix+"ly_inf_r"));
if (properties.getProperty(prefix+"ly_inf_scale")!=null) this.ly_inf_scale=Integer.parseInt(properties.getProperty(prefix+"ly_inf_scale"));
if (properties.getProperty(prefix+"ly_inf_scale_r")!=null) this.ly_inf_scale_r=Double.parseDouble(properties.getProperty(prefix+"ly_inf_scale_r"));
if (properties.getProperty(prefix+"ly_inf_frac")!=null) this.ly_inf_frac=Double.parseDouble(properties.getProperty(prefix+"ly_inf_frac"));
if (properties.getProperty(prefix+"ly_inf_max_disparity")!=null) this.ly_inf_max_disparity=Double.parseDouble(properties.getProperty(prefix+"ly_inf_max_disparity"));
......@@ -1668,6 +1707,8 @@ public class CLTParameters {
if (properties.getProperty(prefix+"ly_smpl_rms")!=null) this.ly_smpl_rms=Double.parseDouble(properties.getProperty(prefix+"ly_smpl_rms"));
if (properties.getProperty(prefix+"ly_disp_var")!=null) this.ly_disp_var=Double.parseDouble(properties.getProperty(prefix+"ly_disp_var"));
if (properties.getProperty(prefix+"ly_disp_rvar")!=null) this.ly_disp_rvar=Double.parseDouble(properties.getProperty(prefix+"ly_disp_rvar"));
if (properties.getProperty(prefix+"ly_disp_var_gt")!=null) this.ly_disp_var_gt=Double.parseDouble(properties.getProperty(prefix+"ly_disp_var_gt"));
if (properties.getProperty(prefix+"ly_disp_rvar_gt")!=null) this.ly_disp_rvar_gt=Double.parseDouble(properties.getProperty(prefix+"ly_disp_rvar_gt"));
if (properties.getProperty(prefix+"ly_norm_disp")!=null) this.ly_norm_disp=Double.parseDouble(properties.getProperty(prefix+"ly_norm_disp"));
if (properties.getProperty(prefix+"lym_overexp")!=null) this.lym_overexp=Double.parseDouble(properties.getProperty(prefix+"lym_overexp"));
if (properties.getProperty(prefix+"lym_update_disp")!=null) this.lym_update_disp=Boolean.parseBoolean(properties.getProperty(prefix+"lym_update_disp"));
......@@ -2227,6 +2268,8 @@ public class CLTParameters {
// GenericDialog gd = new GenericDialog("Set CLT parameters");
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",800,900);
gd.addTab ("General", "General parameters");
gd.addNumericField("Nominal (rectilinear) disparity between side of square cameras (pix)", this.disparity, 3,7,"pix",
"Used when rendering 4 images");
gd.addNumericField("Transform size (default 8)", this.transform_size, 0, 6, "pixels","Should always be 8");
gd.addNumericField("Lapped transform window type (0- rectangular, 1 - sinus)", this.clt_window, 0);
gd.addNumericField("shift_x", this.shift_x, 4);
......@@ -2261,8 +2304,6 @@ public class CLTParameters {
gd.addNumericField("Value (max) in vignetting data to correspond to 1x in the kernel", this.vignetting_max, 3);
gd.addNumericField("Do not try to correct vignetting smaller than this fraction of max", this.vignetting_range, 3);
gd.addNumericField("Kernel step in pixels (has 1 kernel margin on each side)", this.kernel_step, 0);
gd.addNumericField("Nominal (rectilinear) disparity between side of square cameras (pix)", this.disparity, 3,7,"pix",
"Used when rendering 4 images");
gd.addNumericField("Inverse distance to infinity (misalignment correction)", this.z_correction, 6);
gd.addCheckbox ("Perform correlation", this.correlate);
gd.addNumericField("Bitmask of pairs to combine in the composite (top, bottom, left,righth)", this.corr_mask, 0);
......@@ -2406,12 +2447,20 @@ public class CLTParameters {
gd.addCheckbox ("Equalize weights of right/left FoV", this.ly_right_left,
"Use this mode use with horizon visible in both FoV halves when gross infinity correction is needed");
gd.addNumericField("Relative weight of infinity calibration data", this.ly_inf_frac, 3);
gd.addNumericField("Minimal tiles per quadrant (not counting the worst) tp proceed", this.ly_per_quad, 0);
gd.addNumericField("Minimal tiles per quadrant (not counting the worst) tp proceed - fraction of all tiles", this.ly_per_quad_r, 3);
gd.addNumericField("Minimal number of tiles at infinity to proceed", this.ly_inf, 0);
gd.addNumericField("Minimal number of tiles at infinity to proceed - fraction of all tiles", this.ly_inf_r, 3);
gd.addNumericField("Minimal number of tiles at infinity to apply weight scaling", this.ly_inf_scale, 0);
gd.addNumericField("Minimal number of tiles at infinity to apply weight scaling - fraction of all tiles", this.ly_inf_scale_r, 3);
gd.addNumericField("Relative weight of infinity calibration data", this.ly_inf_frac, 3);
gd.addNumericField("Maximal disparity to be treated as infinity when adjusting with the rig data", this.ly_inf_max_disparity, 8,3,"pix",
"Only used in guided (by rig data) mode");
gd.addCheckbox ("Correct disparity for infinity tiles )has to disable until code fixed)", this.ly_inf_disp);
gd.addCheckbox ("Correct disparity for infinity tiles )has to disable until code fixed)", this.ly_inf_disp);
gd.addCheckbox ("Force convergence correction during extrinsic, even with no infinity data", this.ly_inf_force);
gd.addCheckbox ("*Use polynomial correction, false - correct tilt/azimuth/roll of each sensor)", this.ly_poly);
......@@ -2425,6 +2474,10 @@ public class CLTParameters {
"Full allowed mismatch is a sum of absolute and disparity times relative");
gd.addNumericField("Maximal relative full disparity difference to 8 neighbors", this.ly_disp_rvar, 8,5,"",
"Full allowed mismatch is a sum of absolute and disparity times relative");
gd.addNumericField("Maximal full disparity difference to 8 neighbors with GT", this.ly_disp_var_gt, 8,5,"pix",
"Full allowed mismatch is a sum of absolute and disparity times relative (relaxed when ground truth is available)");
gd.addNumericField("Maximal relative full disparity difference to 8 neighbors with GT", this.ly_disp_rvar_gt, 8,5,"",
"Full allowed mismatch is a sum of absolute and disparity times relative (relaxed when ground truth is available)");
gd.addNumericField("Reduce weight of higher disparity tiles", this.ly_norm_disp, 5);
gd.addMessage ("--- Lazy eye multi-step fitting ---");
gd.addNumericField("Any (near) saturated pixels - discard tile (see sat_level also)", this.lym_overexp, 10);
......@@ -2496,8 +2549,8 @@ public class CLTParameters {
gd.addCheckbox ("Use old ortho features processing (ortho_* parameters, false - use or_*)", this.ortho_old);
gd.addMessage ("--- old ones, new are in \"Ortho+4\" tab---");
gd.addNumericField("Minimal strength of hor correlation to be used instead of full 4-pair correlation", this.ortho_min_hor, 3);
gd.addNumericField("Minimal strength of vert correlation to be used instead of full 4-pair correlation", this.ortho_min_vert, 3);
gd.addNumericField("Minimal strength of hor correlation to be used instead of full 4-pair correlation", this.ortho_min_hor, 3);
gd.addNumericField("Minimal strength of vert correlation to be used instead of full 4-pair correlation", this.ortho_min_vert, 3);
gd.addNumericField("Vert/hor (or hor/vert) strength to be used instead of the full correlation", this.ortho_asym, 3);
gd.addNumericField("Vert/hor (or hor/vert) strength exceeding scaled 4-pair strength", this.ortho_over4, 3);
......@@ -3067,6 +3120,7 @@ public class CLTParameters {
gd.showDialog();
*/
if (gd.wasCanceled()) return false;
this.disparity= gd.getNextNumber();
this.transform_size= (int) gd.getNextNumber();
this.clt_window= (int) gd.getNextNumber();
this.shift_x = gd.getNextNumber();
......@@ -3086,7 +3140,7 @@ public class CLTParameters {
this.norm_kern= gd.getNextBoolean();
this.gain_equalize= gd.getNextBoolean();
this.colors_equalize= gd.getNextBoolean();
this.nosat_equalize= gd.getNextBoolean();
this.nosat_equalize= gd.getNextBoolean();
this.sat_level= gd.getNextNumber();
this.max_overexposure= gd.getNextNumber();
......@@ -3099,7 +3153,6 @@ public class CLTParameters {
this.vignetting_max= gd.getNextNumber();
this.vignetting_range= gd.getNextNumber();
this.kernel_step= (int) gd.getNextNumber();
this.disparity= gd.getNextNumber();
this.z_correction= gd.getNextNumber();
this.correlate= gd.getNextBoolean();
this.corr_mask= (int) gd.getNextNumber();
......@@ -3216,6 +3269,14 @@ public class CLTParameters {
this.ly_par_sel= (int) gd.getNextNumber();
this.ly_right_left= gd.getNextBoolean();
this.ly_per_quad= (int) gd.getNextNumber();
this.ly_per_quad_r= gd.getNextNumber();
this.ly_inf= (int) gd.getNextNumber();
this.ly_inf_r= gd.getNextNumber();
this.ly_inf_scale= (int) gd.getNextNumber();
this.ly_inf_scale_r= gd.getNextNumber();
this.ly_inf_frac= gd.getNextNumber();
this.ly_inf_max_disparity= gd.getNextNumber();
......@@ -3228,6 +3289,8 @@ public class CLTParameters {
this.ly_smpl_rms= gd.getNextNumber();
this.ly_disp_var= gd.getNextNumber();
this.ly_disp_rvar= gd.getNextNumber();
this.ly_disp_var_gt= gd.getNextNumber();
this.ly_disp_rvar_gt= gd.getNextNumber();
this.ly_norm_disp= gd.getNextNumber();
this.lym_overexp= gd.getNextNumber();
this.lym_update_disp= gd.getNextBoolean();
......
......@@ -169,6 +169,7 @@ public class EyesisCorrectionParameters {
public String mlDirectory="ml";
public boolean thumb_overwrite = true;
public int thumb_width = 200;
public int thumb_height = 100;
public double thumb_h_center = 0.5;
......@@ -296,6 +297,17 @@ public class EyesisCorrectionParameters {
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;
cp.thumb_overwrite = this.thumb_overwrite;
cp.thumb_width = this.thumb_width;
cp.thumb_height = this.thumb_height;
cp.thumb_h_center = this.thumb_h_center;
cp.thumb_v_center = this.thumb_v_center;
cp.thumb_size = this.thumb_size;
cp.default_rating = this.default_rating;
}
......@@ -462,6 +474,7 @@ public class EyesisCorrectionParameters {
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_overwrite", this.thumb_overwrite+"");
properties.setProperty(prefix+"thumb_width", this.thumb_width+"");
properties.setProperty(prefix+"thumb_height", this.thumb_height+"");
properties.setProperty(prefix+"thumb_h_center", this.thumb_h_center+"");
......@@ -616,6 +629,7 @@ public class EyesisCorrectionParameters {
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_overwrite")!= null) this.thumb_overwrite=Boolean.parseBoolean(properties.getProperty(prefix+"thumb_overwrite"));
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_h_center")!=null) this.thumb_h_center= Double.parseDouble(properties.getProperty(prefix+"thumb_h_center"));
......@@ -769,6 +783,7 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Swap top and equator images", this.swapSubchannels01);
gd.addTab("Thumbnails","Thumbnail image generation");
gd.addCheckbox("Overwrite existing thumbnail images",this.thumb_overwrite);
gd.addNumericField("Thumbnail image width", this.thumb_width, 0,4,"pix",
"");
gd.addNumericField("Thumbnail image height", this.thumb_height, 0,4,"pix",
......@@ -871,6 +886,7 @@ public class EyesisCorrectionParameters {
this.removeUnusedSensorData= gd.getNextBoolean();
this.swapSubchannels01= gd.getNextBoolean();
this.thumb_overwrite = gd.getNextBoolean();
this.thumb_width= (int) gd.getNextNumber();
this.thumb_height= (int) gd.getNextNumber();
this.thumb_h_center= gd.getNextNumber();
......
......@@ -705,6 +705,10 @@ private Panel panel1,
addButton("GPU files", panelClt_GPU, color_conf_process);
addButton("Rig8 gpu", panelClt_GPU, color_conf_process);
addButton("ShowGPU", panelClt_GPU, color_conf_process);
addButton("LWIR_TEST", panelClt_GPU, color_conf_process);
addButton("LWIR_ACQUIRE", panelClt_GPU, color_conf_process);
plugInFrame.add(panelClt_GPU);
}
if (LWIR_MODE) {
......@@ -730,13 +734,13 @@ private Panel panel1,
addButton("AUX OUT 3D", panelLWIR, color_process_aux);
addButton("Main img AUX", panelLWIR, color_process_aux);
addButton("Main to AUX", panelLWIR, color_process_aux);
addButton("LWIR_TEST", panelLWIR, color_conf_process);
addButton("LWIR_ACQUIRE", panelLWIR, color_conf_process);
addButton("LWIR batch", panelClt4, color_process);
// addButton("LWIR_TEST", panelLWIR, color_conf_process);
// addButton("LWIR_ACQUIRE", panelLWIR, color_conf_process);
plugInFrame.add(panelLWIR);
}
plugInFrame.pack();
//"LWIR batch"
GUI.center(plugInFrame);
plugInFrame.setVisible(true);
FHT_INSTANCE= new DoubleFHT();
......@@ -3960,12 +3964,6 @@ private Panel panel1,
IJ.showMessage("Warning",msg);
return;
}
/*
EYESIS_CORRECTIONS.initSensorFiles(DEBUG_LEVEL,
true, // true - ignore missing files
true, // boolean all_sensors,
COLOR_PROC_PARAMETERS.correct_vignetting); //boolean correct_vignetting
*/
QUAD_CLT.resetGeometryCorrection();
QUAD_CLT.initGeometryCorrection(DEBUG_LEVEL+2);
......@@ -5016,6 +5014,14 @@ private Panel panel1,
batchRig();
return;
/* ======================================================================== */
} else if (label.equals("LWIR batch")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
CLT_PARAMETERS.batch_run = true;
batchLwir();
return;
/* ======================================================================== */
} else if (label.equals("CLT rig edit")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
......@@ -5464,7 +5470,7 @@ private Panel panel1,
return true;
}
// inverted false/true in initSensorFiles(), should work with LWIR also
public boolean prepareRigImages() {
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
......@@ -5489,8 +5495,6 @@ private Panel panel1,
System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
}
}
// QuadCLT dbg_QUAD_CLT = QUAD_CLT;
// QuadCLT dbg_QUAD_CLT_AUX = QUAD_CLT_AUX;
String configPath=getSaveCongigPath();
if (configPath.equals("ABORT")) return false;
if (DEBUG_LEVEL > -2){
......@@ -5498,15 +5502,15 @@ private Panel panel1,
}
EYESIS_CORRECTIONS.initSensorFiles(
DEBUG_LEVEL+2,
true,
false,
false, // true,
true, // false,
COLOR_PROC_PARAMETERS.correct_vignetting); //boolean correct_vignetting
if (DEBUG_LEVEL > -2){
System.out.println("++++++++++++++ Running initSensorFiles for the auxiliary camera ++++++++++++++");
}
EYESIS_CORRECTIONS_AUX.initSensorFiles(DEBUG_LEVEL+2,
true,
false,
false, // true,
true, // false,
COLOR_PROC_PARAMETERS_AUX.correct_vignetting); //boolean correct_vignetting
......@@ -6149,6 +6153,52 @@ private Panel panel1,
return true;
}
public boolean batchLwir() {
long startTime=System.nanoTime();
// load needed sensor and kernels files
if (!prepareRigImages()) return false;
String configPath=getSaveCongigPath();
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){
System.out.println("++++++++++++++ Running batch processing of dual-quad EO/LWIR camera rig ++++++++++++++");
}
// parameters are different
/// if (COLOR_PROC_PARAMETERS_AUX == null) {
/// COLOR_PROC_PARAMETERS_AUX = COLOR_PROC_PARAMETERS.clone();
/// }
try {
TWO_QUAD_CLT.batchLwirRig(
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
COLOR_PROC_PARAMETERS_AUX, //EyesisCorrectionParameters.ColorProcParameters colorProcParameters_aux,
CHANNEL_GAINS_PARAMETERS, //CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
PROPERTIES, // Properties properties,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //final int debugLevel);
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
System.out.println("batchRig(): Processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+" sec, --- Free memory="+
Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true;
}
......@@ -6337,7 +6387,9 @@ private Panel panel1,
String mask = ".*EXTRINSICS\\.corr-xml";
String full_conf_suffix = ".corr-xml";
String dsi_suffix = "-DSI_COMBO.tiff";
// String dsi_suffix = "-DSI_COMBO.tiff";
String dsi_suffix = TwoQuadCLT.DSI_COMBO_SUFFIX+".tiff";
String correction_parameters_prefix = "CORRECTION_PARAMETERS.";
System.out.println("File mask = "+mask);
......
......@@ -23,6 +23,7 @@ package com.elphel.imagej.tileprocessor;
**
*/
import java.util.ArrayList;
import java.util.Arrays;
import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.common.DoubleGaussianBlur;
......@@ -1775,6 +1776,11 @@ B = |+dy0 -dy1 -2*dy3 |
final int hist_min_samples,
final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
final double inf_fraction, // fraction of the weight for the infinity tiles
final int min_per_quadrant, // minimal tiles per quadrant (not counting the worst) tp proceed
final int min_inf, // minimal number of tiles at infinity to proceed
final int min_inf_to_scale, // minimal number of tiles at infinity to apply weight scaling
final boolean right_left, // equalize weights of right/left FoV (use with horizon in both halves and gross infinity correction)
CLTParameters clt_parameters,
double [][] scans_14,
......@@ -2172,12 +2178,44 @@ B = |+dy0 -dy1 -2*dy3 |
// adjust weight to balance infinity data and lazy eye one. As some tiles were discarded by selectInfinityTiles() list and not the original
// array has to be used to find the total weight of the infinity tile. Other ones will be used with no extra filtering
double [] total_weights = new double[2];
int num_inf = 0;
int [] per_quad = new int[4];
for (Sample s: inf_samples_list) {
total_weights[0] += s.weight;
if (s.weight > 0.0) {
num_inf ++;
int hx = (s.tile % tilesX) / (tilesX/2);
int hy = (s.tile / tilesX) / (tilesY/2);
per_quad[hx + 2*hy]++;
}
}
for (int nTile = 0; nTile < num_tiles; nTile++) if (center_mask[nTile]){ // calculate total weight of non-infinity
total_weights[1]+= inf_and_ly[1 * NUM_SLICES + 1][nTile];
if (inf_and_ly[1 * NUM_SLICES + 1][nTile] > 0.0) {
int hx = (nTile % tilesX) / (tilesX/2);
int hy = (nTile / tilesX) / (tilesY/2);
per_quad[hx + 2*hy]++;
}
}
int [] pq = per_quad.clone();
Arrays.sort(per_quad);
if (debugLevel > -20) {
System.out.print(String.format("Tiles per quadrants :[%d, %d, %d, %d], tiles at infinity %d", pq[0],pq[1],pq[2],pq[3],num_inf));
}
if (per_quad[1] < min_per_quadrant) {
if (debugLevel > -20) {
System.out.print(String.format("Too few tiles in quadrants :[%d, %d, %d, %d], minimum for the second worst is %d", pq[0],pq[1],pq[2],pq[3],min_per_quadrant));
}
return null;
}
if (num_inf < min_inf) {
if (debugLevel > -20) {
System.out.print(String.format("Too few tiles at infinity: %d minimum is %d", num_inf, min_inf));
}
return null;
}
double inf_fraction_limited = (inf_fraction >= 0.0) ?((inf_fraction > 1.0) ? 1.0 : inf_fraction):0.0;
......@@ -2187,16 +2225,29 @@ B = |+dy0 -dy1 -2*dy3 |
(1.0 - inf_fraction_limited) * (total_weights[0] + total_weights[1]) / total_weights[1],
};
for (int ns = 0; ns <2; ns++) {
for (int nTile = 0; nTile < num_tiles; nTile++) {
inf_and_ly[ns * NUM_SLICES + 1][nTile] *= weights[ns];
if (num_inf < min_inf_to_scale) {
if (debugLevel>-1) {
System.out.println("Too few infinity tiles to boost ("+num_inf+" < "+min_inf_to_scale+", keeping original weights");
}
} else if (weights[0] > weights[1]) {
if (debugLevel>-1) {
System.out.println("Boosting weights of far tiles (weights[0]="+weights[0]+", weights[1]="+weights[1]);
}
for (int ns = 0; ns <2; ns++) {
for (int nTile = 0; nTile < num_tiles; nTile++) {
inf_and_ly[ns * NUM_SLICES + 1][nTile] *= weights[ns];
}
}
for (Sample s: inf_samples_list) {
s.weight *= weights[0];
}
} else {
if (debugLevel>-1) {
System.out.println("There are already more far tiles than requested (weights[0]="+weights[0]+", weights[1]="+weights[1]+", so keeping original weights");
}
}
for (Sample s: inf_samples_list) {
s.weight *= weights[0];
}
// } else {
// inf_samples_list = new ArrayList<Sample>(); // do not use infinity at all
}
///-----
......@@ -2325,7 +2376,11 @@ B = |+dy0 -dy1 -2*dy3 |
System.out.println(corr_vector.toString());
}
if (apply_extrinsic){
qc.geometryCorrection.getCorrVector().incrementVector(corr_vector, clt_parameters.ly_corr_scale);
boolean ok = qc.geometryCorrection.getCorrVector().incrementVector(corr_vector, clt_parameters.ly_corr_scale);
if (!ok) {
System.out.println("Failed to solve correction, corr_vector:"+corr_vector.toString());
return null;
}
if (debugLevel > -1){
System.out.println("New extrinsic corrections:");
System.out.println(qc.geometryCorrection.getCorrVector().toString());
......@@ -2351,7 +2406,46 @@ B = |+dy0 -dy1 -2*dy3 |
/**
*
* @param use_poly
* @param restore_disp_inf
* @param fcorr_radius
* @param min_strength_in
* @param strength_pow
* @param lazyEyeCompDiff
* @param lazyEyeSmplSide
* @param lazyEyeSmplNum
* @param lazyEyeSmplRms
* @param lazyEyeDispVariation
* @param lazyEyeDispRelVariation
* @param ly_norm_disp
* @param smplSide
* @param smplNum
* @param smplRms
* @param hist_smpl_side
* @param hist_disp_min
* @param hist_disp_step
* @param hist_num_bins
* @param hist_sigma
* @param hist_max_diff
* @param hist_min_samples
* @param hist_norm_center
* @param inf_fraction
* @param min_per_quadrant
* @param min_inf
* @param min_inf_to_scale
* @param inf_max_disparity
* @param clt_parameters
* @param scans_14
* @param gt_disparity_strength
* @param filter_ds
* @param filter_lyf
* @param tilesX
* @param magic_coeff
* @param debugLevel
* @return will return null if can not adjust
*/
......@@ -2386,9 +2480,12 @@ B = |+dy0 -dy1 -2*dy3 |
final double hist_max_diff,
final int hist_min_samples,
final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
final double inf_fraction, // fraction of the weight for the infinity tiles
final double inf_fraction, // fraction of the weight for the infinity tiles
final int min_per_quadrant, // minimal tiles per quadrant (not counting the worst) tp proceed
final int min_inf, // minimal number of tiles at infinity to proceed
final int min_inf_to_scale, // minimal number of tiles at infinity to apply weight scaling
final double inf_max_disparity, // use all smaller disparities as inf_fraction
CLTParameters clt_parameters,
CLTParameters clt_parameters,
double [][] scans_14, // here - always 14 - infinity and non-infinity
double [][][] gt_disparity_strength, // 1 pair for each 14 entries of scans_14 (normally - just 1 scan
final boolean filter_ds, //
......@@ -2542,6 +2639,13 @@ B = |+dy0 -dy1 -2*dy3 |
}
}
}
if (debugLevel > 0) { // 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new ShowDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "removed_residual"+lazyEyeCompDiff, prefixes);
}
for (int nTile = 0; nTile < num_tiles; nTile++) {
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrectionFromGT().2: nTile="+nTile);
......@@ -2559,6 +2663,10 @@ B = |+dy0 -dy1 -2*dy3 |
}
}
if (debugLevel > 0) { // 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new ShowDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "removed_residual-1"+lazyEyeCompDiff, prefixes);
}
// reduce influence of high disparity, using combined disparity
// double norm_ly_disparity = 100.0; // disabling
......@@ -2567,6 +2675,10 @@ B = |+dy0 -dy1 -2*dy3 |
combo_mismatch[1][nTile] *= ly_norm_disp/combo_mismatch[0][nTile];
}
}
if (debugLevel > 0) { // 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new ShowDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "removed_residual-2"+lazyEyeCompDiff, prefixes);
}
// instance of class to operate navigation over tiles
......@@ -2681,13 +2793,36 @@ B = |+dy0 -dy1 -2*dy3 |
// final double inf_fraction, // fraction of the weight for the infinity tiles
// final double inf_max_disparity, // use all smaller disparities as inf_fraction
double [] total_weights = new double[2];
for (int nTile = 0; nTile < combo_mismatch[INDEX_10_WEIGHT].length; nTile++ ) if (center_mask[nTile]){
int num_inf = 0;
int [] per_quad = new int[4];
for (int nTile = 0; nTile < combo_mismatch[INDEX_10_WEIGHT].length; nTile++ ) if (center_mask[nTile] && (combo_mismatch[INDEX_10_WEIGHT][nTile] > 0.0)){
if (combo_mismatch[INDEX_10_DISPARITY][nTile] <= inf_max_disparity) {
total_weights[0] += combo_mismatch[INDEX_10_WEIGHT][nTile];
num_inf ++;
} else {
total_weights[1] += combo_mismatch[INDEX_10_WEIGHT][nTile];
}
int hx = (nTile % tilesX) / (tilesX/2);
int hy = (nTile / tilesX) / (tilesY/2);
per_quad[hx + 2*hy]++;
}
int [] pq = per_quad.clone();
Arrays.sort(per_quad);
if (per_quad[1] < min_per_quadrant) {
if (debugLevel > -20) {
System.out.print(String.format("Too few tiles in quadrants :[%d, %d, %d, %d], minimum for the second worst is %d", pq[0],pq[1],pq[2],pq[3],min_per_quadrant));
}
return null;
}
if (num_inf < min_inf) {
if (debugLevel > -20) {
System.out.print(String.format("Too few tiles at infinity (<%4f): %d minimum is %d", inf_max_disparity, num_inf, min_inf));
}
return null;
}
if (debugLevel > -20) {
System.out.print(String.format("Tiles per quadrants :[%d, %d, %d, %d], tiles at infinity %d", pq[0],pq[1],pq[2],pq[3],num_inf));
}
double inf_fraction_limited = (inf_fraction >= 0.0) ?((inf_fraction > 1.0) ? 1.0 : inf_fraction):0.0;
......@@ -2696,10 +2831,13 @@ B = |+dy0 -dy1 -2*dy3 |
inf_fraction_limited * (total_weights[0] + total_weights[1]) / total_weights[0],
(1.0 - inf_fraction_limited) * (total_weights[0] + total_weights[1]) / total_weights[1],
};
if (weights[0]> weights[1]) {