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

Multiple ref scenes

parent 1ff463f4
......@@ -170,12 +170,16 @@ public class EyesisCorrectionParameters {
public boolean clt_batch_pose_pairs_main = false; // calculate pair-wise camera poses
public boolean clt_batch_pose_last_main = false; // calculate camera poses realtive to the last scene
public boolean clt_batch_pose_scene_main = false; // calculate camera poses relative to all other ones
public int clt_batch_offset_main = 0; // when selecting multiple reference scene, offset from the last one
public int clt_batch_step_main = 3; // step (decreasing timestamp) to select reference frames in a sequence
public boolean clt_batch_ml_last_main = false; // export ML files for the last (reference scene)
public boolean clt_batch_ml_all_main = false; // export ML files for all available reference scenes
public boolean clt_batch_pose_pairs_aux = false; // calculate pair-wise camera poses
public boolean clt_batch_pose_last_aux = false; // calculate camera poses realtive to the last scene
public boolean clt_batch_pose_scene_aux = false; // calculate camera poses relative to all other ones
public int clt_batch_offset_aux = 0; // when selecting multiple reference scene, offset from the last one
public int clt_batch_step_aux = 10; // step (decreasing timestamp) to select reference frames in a sequence
public boolean clt_batch_ml_last_aux = false; // export ML files for the last (reference scene)
public boolean clt_batch_ml_all_aux = false; // export ML files for all available reference scenes
......@@ -325,6 +329,10 @@ public class EyesisCorrectionParameters {
cp.clt_batch_pose_pairs_main= this.clt_batch_pose_pairs_main;
cp.clt_batch_pose_last_main= this.clt_batch_pose_last_main;
cp.clt_batch_pose_scene_main= this.clt_batch_pose_scene_main;
cp.clt_batch_offset_main= this.clt_batch_offset_main;
cp.clt_batch_step_main= this.clt_batch_step_main;
cp.clt_batch_ml_last_main= this.clt_batch_ml_last_main;
cp.clt_batch_ml_all_main= this.clt_batch_ml_all_main;
......@@ -332,6 +340,8 @@ public class EyesisCorrectionParameters {
cp.clt_batch_pose_pairs_aux= this.clt_batch_pose_pairs_aux;
cp.clt_batch_pose_last_aux= this.clt_batch_pose_last_aux;
cp.clt_batch_pose_scene_aux= this.clt_batch_pose_scene_aux;
cp.clt_batch_offset_aux= this.clt_batch_offset_aux;
cp.clt_batch_step_aux= this.clt_batch_step_aux;
cp.clt_batch_ml_last_aux= this.clt_batch_ml_last_aux;
cp.clt_batch_ml_all_aux= this.clt_batch_ml_all_aux;
......@@ -520,12 +530,18 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"clt_batch_pose_pairs_main", this.clt_batch_pose_pairs_main+"");
properties.setProperty(prefix+"clt_batch_pose_last_main", this.clt_batch_pose_last_main+"");
properties.setProperty(prefix+"clt_batch_pose_scene_main", this.clt_batch_pose_scene_main+"");
properties.setProperty(prefix+"clt_batch_offset_main", this.clt_batch_offset_main+"");
properties.setProperty(prefix+"clt_batch_step_main", this.clt_batch_step_main+"");
properties.setProperty(prefix+"clt_batch_ml_last_main", this.clt_batch_ml_last_main+"");
properties.setProperty(prefix+"clt_batch_ml_all_main", this.clt_batch_ml_all_main+"");
properties.setProperty(prefix+"clt_batch_pose_pairs_aux", this.clt_batch_pose_pairs_aux+"");
properties.setProperty(prefix+"clt_batch_pose_last_aux", this.clt_batch_pose_last_aux+"");
properties.setProperty(prefix+"clt_batch_pose_scene_aux", this.clt_batch_pose_scene_aux+"");
properties.setProperty(prefix+"clt_batch_offset_aux", this.clt_batch_offset_aux+"");
properties.setProperty(prefix+"clt_batch_step_aux", this.clt_batch_step_aux+"");
properties.setProperty(prefix+"clt_batch_ml_last_aux", this.clt_batch_ml_last_aux+"");
properties.setProperty(prefix+"clt_batch_ml_all_aux", this.clt_batch_ml_all_aux+"");
......@@ -693,12 +709,16 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"clt_batch_pose_pairs_main")!= null) this.clt_batch_pose_pairs_main=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_pose_pairs_main"));
if (properties.getProperty(prefix+"clt_batch_pose_last_main")!= null) this.clt_batch_pose_last_main=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_pose_last_main"));
if (properties.getProperty(prefix+"clt_batch_pose_scene_main")!= null) this.clt_batch_pose_scene_main=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_pose_scene_main"));
if (properties.getProperty(prefix+"clt_batch_offset_main")!=null) this.clt_batch_offset_main=Integer.parseInt(properties.getProperty(prefix+"clt_batch_offset_main"));
if (properties.getProperty(prefix+"clt_batch_step_main")!=null) this.clt_batch_step_main=Integer.parseInt(properties.getProperty(prefix+"clt_batch_step_main"));
if (properties.getProperty(prefix+"clt_batch_ml_last_main")!= null) this.clt_batch_ml_last_main=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_ml_last_main"));
if (properties.getProperty(prefix+"clt_batch_ml_all_main")!= null) this.clt_batch_ml_all_main=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_ml_all_main"));
if (properties.getProperty(prefix+"clt_batch_pose_pairs_aux")!= null) this.clt_batch_pose_pairs_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_pose_pairs_aux"));
if (properties.getProperty(prefix+"clt_batch_pose_last_aux")!= null) this.clt_batch_pose_last_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_pose_last_aux"));
if (properties.getProperty(prefix+"clt_batch_pose_scene_aux")!= null) this.clt_batch_pose_scene_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_pose_scene_aux"));
if (properties.getProperty(prefix+"clt_batch_offset_aux")!=null) this.clt_batch_offset_aux=Integer.parseInt(properties.getProperty(prefix+"clt_batch_offset_aux"));
if (properties.getProperty(prefix+"clt_batch_step_aux")!=null) this.clt_batch_step_aux=Integer.parseInt(properties.getProperty(prefix+"clt_batch_step_aux"));
if (properties.getProperty(prefix+"clt_batch_ml_last_aux")!= null) this.clt_batch_ml_last_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_ml_last_aux"));
if (properties.getProperty(prefix+"clt_batch_ml_all_aux")!= null) this.clt_batch_ml_all_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_ml_all_aux"));
......@@ -1086,6 +1106,7 @@ public class EyesisCorrectionParameters {
gd.addMessage ("============ LWIR16 processing ============");
gd.addCheckbox ("Skip scenes processing", this.clt_batch_skip_scenes,
"Skip all per-scene processing, go directly to processing sequences");
gd.addMessage ("============ RGB cameras ============");
gd.addCheckbox ("RGB: Calculate pair-wise camera poses", this.clt_batch_pose_pairs_main,
"RGB: Relative poses are calculated for pairs of consecututive scenes. Requires DSI for each scene");
......@@ -1093,6 +1114,13 @@ public class EyesisCorrectionParameters {
"RGB: Relative camera poses to the reference (last) scene");
gd.addCheckbox ("RGB: Scene poses relative to others", this.clt_batch_pose_scene_main,
"RGB: Camera poses relative to all other scenes in the series, not just relative to the latest (not yet implemented)");
gd.addNumericField("RGB: Offset latest reference scene", this.clt_batch_offset_main, 0, 3, "scenes",
"When selecting multiple reference scenes for ML files generation, offset from the last scene in the series");
gd.addNumericField("RGB: Step between reference scenes", this.clt_batch_step_main, 0, 3, "scenes",
"When selecting multiple reference scenes for ML files generation, step between scenes");
gd.addCheckbox ("RGB: Generate ML files for the last scene", this.clt_batch_ml_last_main,
"RGB: Generate ML output files for the last scene, requres 'Scene poses relative to the last'");
gd.addCheckbox ("RGB: Generate ML files for each scene", this.clt_batch_ml_all_main,
......@@ -1105,6 +1133,12 @@ public class EyesisCorrectionParameters {
"LWIR: Relative camera poses to the reference (last) scene");
gd.addCheckbox ("LWIR: Scene poses relative to others", this.clt_batch_pose_scene_aux,
"LWIR: Camera poses relative to all other scenes in the series, not just relative to the latest (not yet implemented)");
gd.addNumericField("LWIR: Offset latest reference scene", this.clt_batch_offset_aux, 0, 3, "scenes",
"When selecting multiple reference scenes for ML files generation, offset from the last scene in the series");
gd.addNumericField("LWIR: Step between reference scenes", this.clt_batch_step_aux, 0, 3, "scenes",
"When selecting multiple reference scenes for ML files generation, step between scenes");
gd.addCheckbox ("LWIR: Generate ML files for the last scene", this.clt_batch_ml_last_aux,
"LWIR: Generate ML output files for the last scene, requres 'Scene poses relative to the last'");
gd.addCheckbox ("LWIR: Generate ML files for each scene", this.clt_batch_ml_all_aux,
......@@ -1200,12 +1234,16 @@ public class EyesisCorrectionParameters {
this.clt_batch_pose_pairs_main= gd.getNextBoolean();
this.clt_batch_pose_last_main= gd.getNextBoolean();
this.clt_batch_pose_scene_main= gd.getNextBoolean();
this.clt_batch_offset_main= (int) gd.getNextNumber();
this.clt_batch_step_main = (int) gd.getNextNumber();
this.clt_batch_ml_last_main= gd.getNextBoolean();
this.clt_batch_ml_all_main= gd.getNextBoolean();
this.clt_batch_pose_pairs_aux= gd.getNextBoolean();
this.clt_batch_pose_last_aux= gd.getNextBoolean();
this.clt_batch_pose_scene_aux= gd.getNextBoolean();
this.clt_batch_offset_aux= (int) gd.getNextNumber();
this.clt_batch_step_aux = (int) gd.getNextNumber();
this.clt_batch_ml_last_aux= gd.getNextBoolean();
this.clt_batch_ml_all_aux= gd.getNextBoolean();
......
......@@ -6967,7 +6967,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.interSeriesLMA(quadCLT, // QUAD_CLT, // QuadCLT quadCLT_main,
// QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
-1, // int ref_index,
0, // int ref_step,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
......@@ -7144,6 +7146,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
TWO_QUAD_CLT.interIntraExportML(
quadCLT, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
0, // int ref_step,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......
......@@ -250,10 +250,10 @@ public class BiQuadParameters {
// calculating GT
public double mll_min_disp_change_pre = 0.01; // stop re-measure when difference is below
public int mll_max_refines_pre = 10;
public double mll_min_disp_change_lma = 0.001; // stop re-measure when difference is below
public int mll_max_refines_lma = 5;
public double mll_min_disp_change_pre = 0.03; // stop re-measure when difference is below, no-LMA, 40 pairs
public int mll_max_refines_pre = 5;
public double mll_min_disp_change_lma = 0.003; // stop re-measure when difference is below, LMA, 120 pairs
public int mll_max_refines_lma = 4;
public boolean mll_generate_scene_outlines = false; // Uses 2 GB - change format, add dimensions (separate color for ref)
// Exporting ML files
......
......@@ -32,6 +32,9 @@ import java.util.Comparator;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.DoubleAccumulator;
import org.apache.commons.math3.complex.Quaternion;
import java.util.concurrent.ThreadLocalRandom;
import com.elphel.imagej.cameras.CLTParameters;
......@@ -3054,7 +3057,7 @@ public class OpticalFlow {
debug_level+1);
}
}
/*
public void adjustSeries(
CLTParameters clt_parameters,
double k_prev,
......@@ -3091,26 +3094,6 @@ public class OpticalFlow {
double [] new_from_last_xyz = ers_scene_last_known.getSceneXYZ(scene_ts);
double [] new_from_last_atr = ers_scene_last_known.getSceneATR(scene_ts);
/*
double [][] last_from_new = ErsCorrection.invertXYZATR(new_from_last_xyz, new_from_last_atr);
double [][] vfy_new_from_last = ErsCorrection.invertXYZATR(last_from_new[0], last_from_new[1]);
System.out.println(new_from_last_xyz[0]+","+new_from_last_xyz[1]+","+new_from_last_xyz[2]+","+
new_from_last_atr[0]+","+new_from_last_atr[1]+","+new_from_last_atr[2]);
System.out.println(last_from_new[0][0]+","+last_from_new[0][1]+","+last_from_new[0][2]+","+
last_from_new[1][0]+","+last_from_new[1][1]+","+last_from_new[1][2]);
System.out.println(vfy_new_from_last[0][0]+","+vfy_new_from_last[0][1]+","+vfy_new_from_last[0][2]+","+
vfy_new_from_last[1][0]+","+vfy_new_from_last[1][1]+","+vfy_new_from_last[1][2]);
double [][] last_from_new1 = ErsCorrection.invertXYZATR(vfy_new_from_last[0],vfy_new_from_last[1]);
double [][] vfy_new_from_last1 = ErsCorrection.invertXYZATR(last_from_new1[0], last_from_new1[1]);
System.out.println(last_from_new1[0][0]+","+last_from_new1[0][1]+","+last_from_new1[0][2]+","+
last_from_new1[1][0]+","+last_from_new1[1][1]+","+last_from_new1[1][2]);
System.out.println(vfy_new_from_last1[0][0]+","+vfy_new_from_last1[0][1]+","+vfy_new_from_last1[0][2]+","+
vfy_new_from_last1[1][0]+","+vfy_new_from_last1[1][1]+","+vfy_new_from_last1[1][2]);
*/
// combine two rotations and two translations
System.out.println("Processing scene "+i+": "+scene_QuadClt.getImageName());
double [][] combo_XYZATR = ErsCorrection.combineXYZATR(
......@@ -3187,7 +3170,7 @@ public class OpticalFlow {
System.out.println("adjustSeries() Done.");
}
}
*/
public void adjustSeries(
CLTParameters clt_parameters,
double k_prev,
......@@ -3196,13 +3179,16 @@ public class OpticalFlow {
int debug_level
)
{
if (ref_index < 0) {
ref_index += scenes.length;
}
double [][][] scenes_xyzatr = new double [scenes.length][][]; // previous scene relative to the next one
QuadCLT reference_QuadClt = scenes[ref_index]; // scenes.length-1]; // last acquired
ErsCorrection ers_reference = reference_QuadClt.getErsCorrection();
// modify LMA parameters to freeze reference ERS, remove pull on scene ERS
boolean[] param_select2 = clt_parameters.ilp.ilma_lma_select.clone(); // final boolean[] param_select,
double [] param_regweights2 = clt_parameters.ilp.ilma_regularization_weights; // final double [] param_regweights,
boolean delete_scene_asap = (debug_level < 10); // to save memory
boolean delete_scene_asap = false; // (debug_level < 10); // to save memory
// freeze reference ERS, free scene ERS
for (int j = 0; j <3; j++) {
param_select2[ErsCorrection.DP_DVX + j] = false;
......@@ -3344,7 +3330,7 @@ public class OpticalFlow {
reference_QuadClt.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory
debug_level+1);
if (!delete_scene_asap && (debug_level > -1)) {
if (!delete_scene_asap && (debug_level > 1000)) { // Null pointer at compareRefSceneTiles ->ers_scene.setupERS();-> Quaternion quat_center1 = ...
System.out.println("adjustSeries(): preparing image set...");
int nscenes = scenes.length;
int indx_ref = nscenes - 1;
......@@ -3987,8 +3973,8 @@ public class OpticalFlow {
)
{
// empiric correction for both lma and non-lma step
double corr_nonlma = 1.23;
double corr_lma = 1.23;
double corr_nonlma = 1.0; // 1.23;
double corr_lma = 1.0; // 1.23;
// reference scene is always added to tghe end, even is out of timestamp order
int indx_ref = scenes.length - 1; // Always added to the end even if out-of order
QuadCLT ref_scene = scenes[indx_ref]; // ordered by increasing timestamps
......@@ -4110,7 +4096,16 @@ public class OpticalFlow {
clt_parameters.img_dtt.setMcorrDia (num_sensors,true); // remove even more?
boolean save_run_lma = clt_parameters.correlate_lma;
clt_parameters.correlate_lma = false;
double [] disp_err = new double [combo_dsn[0].length]; // last time measure disparity error from correlation (scaled for CM)
double [] corr_scale = new double [combo_dsn[0].length]; // applied correction scale
boolean [] was_lma = new boolean [combo_dsn[0].length]; // previous measurement used LMA (not to match LMA/non-LMA measurements)
Arrays.fill(disp_err, Double.NaN);
Arrays.fill(corr_scale, 1.0);
double min_scale = 0.75, max_scale = 1.5; // reset correction scale to 1.0 if calculated is too big/small (jumping FG/BG)
double [][] dbg_corr_scale = null;
if (debug_level > 0) {
dbg_corr_scale = new double[max_refines][];
}
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
if (nrefine == clt_parameters.rig.mll_max_refines_pre) {
min_disp_change = clt_parameters.rig.mll_min_disp_change_lma;
......@@ -4144,7 +4139,7 @@ public class OpticalFlow {
false, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
debug_level-8); // final int debug_level)
if (debug_level > -3) {
if (debug_level > 0) { //-3) {
(new ShowDoubleFloatArrays()).showArrays(
disparity_map,
tilesX,
......@@ -4162,16 +4157,31 @@ public class OpticalFlow {
Arrays.fill(target_disparity, Double.NaN);
for (int nTile =0; nTile < combo_dsn_change[0].length; nTile++) {
if (defined_tiles[nTile]) { // originally defined, maybe not measured last time
// if (!Double.isNaN(combo_dsn_change[combo_dsn_indx_disp][nTile])) { // remeasured
// if ((map_disparity_lma != null) || !Double.isNaN(map_disparity[nTile])) { // remeasured
if (!Double.isNaN(map_disparity[nTile])) { // remeasured
if ((map_disparity_lma != null) && !Double.isNaN(map_disparity_lma[nTile])) {
if (!Double.isNaN(map_disparity[nTile])) { // re-measured
boolean is_lma = (map_disparity_lma != null) && !Double.isNaN(map_disparity_lma[nTile]);
if (is_lma) {
combo_dsn_change[combo_dsn_indx_change][nTile] = map_disparity_lma[nTile] * corr_nonlma;
} else if (!Double.isNaN(map_disparity[nTile])) {
combo_dsn_change[combo_dsn_indx_change][nTile] = map_disparity[nTile] / clt_parameters.ofp.magic_scale * corr_lma;
}
if (!Double.isNaN(combo_dsn_change[combo_dsn_indx_change][nTile])) {
combo_dsn_change[combo_dsn_indx_disp][nTile] += combo_dsn_change[combo_dsn_indx_change][nTile];
// corr_scale[nTile] = 1.0; // use default scale for the error to calculate new target disparity
// will keep previous new_corr_scale value when no previous data or switching non-LMA/LMA. Should be initialized to 1.0
if (!Double.isNaN(disp_err[nTile]) && (is_lma == was_lma[nTile])) {
// current target_disparity: combo_dsn_change[combo_dsn_indx_disp][nTile]
double this_target_disparity = combo_dsn_change[combo_dsn_indx_disp][nTile];
double previous_target_disparity = this_target_disparity - corr_scale[nTile] * disp_err[nTile];
double prev_disp_err = disp_err[nTile];
double this_disp_err = combo_dsn_change[combo_dsn_indx_change][nTile];
double new_corr_scale = (previous_target_disparity - this_target_disparity) / (this_disp_err - prev_disp_err);
if ((new_corr_scale <= max_scale) && (new_corr_scale >= min_scale)) {
corr_scale[nTile] = new_corr_scale;
}
}
combo_dsn_change[combo_dsn_indx_disp][nTile] += combo_dsn_change[combo_dsn_indx_change][nTile] * corr_scale[nTile];
was_lma[nTile] = is_lma;
combo_dsn_change[combo_dsn_indx_strength][nTile] = map_strength[nTile]; // combine CM/LMA
combo_dsn_final[combo_dsn_indx_disp][nTile] = combo_dsn_change[combo_dsn_indx_disp][nTile];
......@@ -4183,18 +4193,33 @@ public class OpticalFlow {
combo_dsn_final[combo_dsn_indx_valid][nTile] = combo_dsn[combo_dsn_indx_valid][nTile]; // not much sense
combo_dsn_final[combo_dsn_indx_change][nTile] = combo_dsn_change[combo_dsn_indx_change][nTile];
}
disp_err[nTile] = combo_dsn_change[combo_dsn_indx_change][nTile];
if (Math.abs(combo_dsn_change[combo_dsn_indx_change][nTile]) >= min_disp_change) {
target_disparity[nTile] = combo_dsn_change[combo_dsn_indx_disp][nTile];
target_disparity[nTile] = combo_dsn_change[combo_dsn_indx_disp][nTile] ;
num_tomeas ++;
} else {
num_tomeas+=0;
}
} else { // originally defined, but not re-measured
num_tomeas+=0;
}
}
}
if (dbg_corr_scale != null) {
dbg_corr_scale[nrefine] = corr_scale.clone();
}
/*
System.arraycopy(combo_dsn_change[combo_dsn_indx_change], 0, prev_diff, 0, combo_dsn_change[combo_dsn_indx_change].length); // lma
System.arraycopy(combo_dsn_change[combo_dsn_indx_strength], 0, prev_strength, 0, combo_dsn_change[combo_dsn_indx_change].length); // lma
if (map_disparity_lma != null) {
for (int nTile =0; nTile < prev_lma.length; nTile++) {
prev_lma[nTile] = !Double.isNaN(map_disparity_lma[nTile]);
}
}
*/
// Copy disparity to disparity_lma and just mask out tiles with no LMA data (keep all if LMA did not run at all)
System.arraycopy(combo_dsn_change[combo_dsn_indx_disp], 0, combo_dsn_change[combo_dsn_indx_lma], 0, combo_dsn_change[combo_dsn_indx_disp].length); // lma
if (map_disparity_lma != null) {
......@@ -4224,8 +4249,17 @@ public class OpticalFlow {
if (num_tomeas == 0) {
break;
}
}
if (dbg_corr_scale != null) {
(new ShowDoubleFloatArrays()).showArrays(
dbg_corr_scale,
tilesX,
tilesY,
true,
"Correction scales"
);
}
// Do above twice: with 40 pairs, no-lma and then with all pairs+LMA
if (debug_level > 1) {
......
......@@ -8394,6 +8394,7 @@ if (debugLevel > -100) return true; // temporarily !
}
/*
public void interSeriesLMA(
QuadCLT quadCLT_main, // tiles should be set
CLTParameters clt_parameters,
......@@ -8457,10 +8458,12 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.ofp.debug_level_optical); // 1); // -1); // int debug_level);
System.out.println("End of interSeriesLMA()");
}
*/
public void interSeriesLMA(
QuadCLT quadCLT_main, // tiles should be set
int ref_index,
int ref_index, // -1 - last
int ref_step,
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
......@@ -8504,22 +8507,29 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
if (ref_index < 0) {
ref_index += quadCLTs.length;
}
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
opticalFlow.adjustSeries(
clt_parameters, // CLTParameters clt_parameters,
clt_parameters.ofp.k_prev, // k_prev,\
// FIXME: *********** update adjustSeries to use QUADCLTCPU ! **********
// (QuadCLT [])
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ref_index, // int ref_index,
clt_parameters.ofp.debug_level_optical); // 1); // -1); // int debug_level);
for (int ri = ref_index; ri >= 0; ri -= ref_step) {
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
opticalFlow.adjustSeries(
clt_parameters, // CLTParameters clt_parameters,
clt_parameters.ofp.k_prev, // k_prev,\
// FIXME: *********** update adjustSeries to use QUADCLTCPU ! **********
// (QuadCLT [])
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ri, // ref_index, // int ref_index,
clt_parameters.ofp.debug_level_optical); // 1); // -1); // int debug_level);
if (ref_step <= 0) {
break;
}
}
System.out.println("End of interSeriesLMA()");
}
......@@ -9008,7 +9018,8 @@ if (debugLevel > -100) return true; // temporarily !
public void interIntraExportML(
QuadCLT quadCLT_main, // tiles should be set
int indx_ref, // = num_scenes - 1;
int ref_index, // = num_scenes - 1;
int ref_step,
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
......@@ -9036,64 +9047,64 @@ if (debugLevel > -100) return true; // temporarily !
return;
}
QuadCLT.SetChannels [] set_channels=quadCLT_main.setChannels(debugLevel); // TODO: use just the last one (to need this is no time)
if (indx_ref < 00) {
indx_ref = set_channels.length + indx_ref; // count from the last
if (ref_index < 0) {
ref_index = set_channels.length + ref_index; // count from the last
}
QuadCLT ref_quadCLT = quadCLT_main.spawnQuadCLT( // gets all relative poses (98)
// set_channels[set_channels.length-1].set_name,
set_channels[indx_ref].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
clt_parameters.inp.noise_debug_level); // debugLevel);
// temporarily fix wrong sign:
// ErsCorrection ers = (ErsCorrection) (ref_quadCLT.getGeometryCorrection());
ref_quadCLT.setDSRBG( // runs GPU to calculate average R,B,G
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
clt_parameters.inp.noise_debug_level); // debugLevel); // int debugLevel)
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus);
ErsCorrection ers_reference = ref_quadCLT.getErsCorrection();
String [] sts = ref_only ? (new String [0]) : ers_reference.getScenes(); // others, referenced by reference
// get list of all other scenes
int num_scenes = sts.length + 1; // including reference
// int indx_ref = num_scenes - 1;
// if (indx_ref < 0) {
// indx_ref = num_scenes - 1;
// }
QuadCLT [] scenes = new QuadCLT [num_scenes];
scenes[scenes.length - 1] = ref_quadCLT; // always added to the end, even if out of order
for (int i = 0; i < sts.length; i++) {
scenes[i] = ref_quadCLT.spawnQuadCLT( // spawnQuadCLT(
sts[i],
for (int indx_ref = ref_index; indx_ref >= 0; indx_ref -= ref_step) {
QuadCLT ref_quadCLT = quadCLT_main.spawnQuadCLT( // gets all relative poses (98)
set_channels[indx_ref].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
-1); // debug_level);
scenes[i].setDSRBG(
clt_parameters.inp.noise_debug_level); // debugLevel);
// temporarily fix wrong sign:
// ErsCorrection ers = (ErsCorrection) (ref_quadCLT.getGeometryCorrection());
ref_quadCLT.setDSRBG( // runs GPU to calculate average R,B,G
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
-1); // debug_level); // int debugLevel)
clt_parameters.inp.noise_debug_level); // debugLevel); // int debugLevel)
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
clt_parameters.ofp.scale_no_lma_disparity, // double scale_no_lma_disparity,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus);
ErsCorrection ers_reference = ref_quadCLT.getErsCorrection();
String [] sts = ref_only ? (new String [0]) : ers_reference.getScenes(); // others, referenced by reference
// get list of all other scenes
int num_scenes = sts.length + 1; // including reference
// int indx_ref = num_scenes - 1;
// if (indx_ref < 0) {
// indx_ref = num_scenes - 1;
// }
QuadCLT [] scenes = new QuadCLT [num_scenes];
scenes[scenes.length - 1] = ref_quadCLT; // always added to the end, even if out of order
for (int i = 0; i < sts.length; i++) {
scenes[i] = ref_quadCLT.spawnQuadCLT( // spawnQuadCLT(
sts[i],
clt_parameters,
colorProcParameters, //
threadsMax,
-1); // debug_level);
scenes[i].setDSRBG(
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
-1); // debug_level); // int debugLevel)
}
// Does not need to specify reference scene - it is always the last even if out of timestamp order
opticalFlow.intersceneExport(
clt_parameters, // CLTParameters clt_parameters,
ers_reference, // ErsCorrection ers_reference,
scenes, // QuadCLT [] scenes,
colorProcParameters, // ColorProcParameters colorProcParameters,
clt_parameters.inp.noise_debug_level // clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
);
}
// Does not need to specify reference scene - it is always the last even if out of timestamp order
opticalFlow.intersceneExport(
clt_parameters, // CLTParameters clt_parameters,
ers_reference, // ErsCorrection ers_reference,
scenes, // QuadCLT [] scenes,
colorProcParameters, // ColorProcParameters colorProcParameters,
clt_parameters.inp.noise_debug_level // clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
);
System.out.println("End of interIntraExportML()");
}
......@@ -11887,6 +11898,8 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_pose_last_main) {
interSeriesLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
......@@ -11903,9 +11916,11 @@ if (debugLevel > -100) return true; // temporarily !
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_scene_main) {
int ref_index = 50; // temporarily, will make evently distributed
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_main -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_main;
interSeriesLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
ref_index, // int ref_index,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
......@@ -11925,6 +11940,26 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_ml_last_main) {
interIntraExportML(quadCLT_main, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
channelGainParameters, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
equirectangularParameters, // EyesisCorrectionParameters.EquirectangularParameters
// equirectangularParameters,
properties, // Properties properties,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_ml_all_main) {
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_main -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_main;
interIntraExportML(quadCLT_main, // QuadCLT quadCLT_main,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -11937,6 +11972,7 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus,
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_pairs_aux) {
TestInterLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
......@@ -11957,6 +11993,8 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_pose_last_aux) {
interSeriesLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
-1, // int ref_index,
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
......@@ -11973,9 +12011,11 @@ if (debugLevel > -100) return true; // temporarily !
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_scene_aux) {
int ref_index = 50; // temporarily, will make evently distributed
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_aux -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_aux;
interSeriesLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
ref_index, // int ref_index,
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
......@@ -11994,6 +12034,7 @@ if (debugLevel > -100) return true; // temporarily !
if (quadCLT_main.correctionsParameters.clt_batch_ml_last_aux) {
interIntraExportML(quadCLT_aux, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
0, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -12007,9 +12048,11 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_ml_all_aux) {
int ref_index = 50; // temporarily, will make evently distributed
int ref_index_start = -quadCLT_main.correctionsParameters.clt_batch_offset_aux -1; // 0 means last (pass -1 to interSeriesLMA())
int ref_index_step = quadCLT_main.correctionsParameters.clt_batch_step_aux;
interIntraExportML(quadCLT_aux, // QuadCLT quadCLT_main,
ref_index, // TODO: Make with some strp from latest, matching clt_batch_pose_scene_aux
ref_index_start, // int ref_index,
ref_index_step, // int ref_step,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -12022,18 +12065,6 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus,
debugLevel);
}
/*
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) { //TODO: is it needed here? WAs not needed before - verify
quadCLT_main.getGPU().resetGeometryCorrection();
quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_main.resetBayer();
}
if ((quadCLT_aux != null) && (quadCLT_aux.getGPU() != null)) {
quadCLT_aux.getGPU().resetGeometryCorrection();
quadCLT_aux.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_aux.resetBayer();
}
*/
System.out.println("batchLwirRig(): processing "+(num_main + num_aux)+" files ("+set_channels.length+" file sets) finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
......
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