Commit fec6933a authored by Andrey Filippov's avatar Andrey Filippov

DSI filtering with intrascene correlations

parent a2860c84
...@@ -166,6 +166,14 @@ public class CLTParameters { ...@@ -166,6 +166,14 @@ public class CLTParameters {
public int ih_min_samples = 10; // Minimal number of remaining samples public int ih_min_samples = 10; // Minimal number of remaining samples
public boolean ih_norm_center = true; // Replace samples with a single average with equal weight public boolean ih_norm_center = true; // Replace samples with a single average with equal weight
public boolean inf_restore_disp = true; // Add disparity back to d{x,y}[i] (debug feature) public boolean inf_restore_disp = true; // Add disparity back to d{x,y}[i] (debug feature)
// intraframe filtering, reusing LY clusters
public double intra_keep_strength = 0.4; // do not remeasure if stronger than
public double intra_keep_conditional_strength = 0.3; // keep if has a close neighbor in clusters
public double intra_absolute_disparity_tolerance = 1.0; //
public double intra_relative_disparity_tolerance = 0.1; //
public int intra_cluster_size = 4;
// Lazy eye parameters // Lazy eye parameters
public boolean ly_lma_ers = true; // Use 2020 LMA-based measurement of mismatch (GPU-supported) public boolean ly_lma_ers = true; // Use 2020 LMA-based measurement of mismatch (GPU-supported)
...@@ -833,6 +841,8 @@ public class CLTParameters { ...@@ -833,6 +841,8 @@ public class CLTParameters {
public int dbg_early_exit = 0; // Exit from early stages public int dbg_early_exit = 0; // Exit from early stages
public boolean show_first_bg = false; // show extrinsic adjustment differences public boolean show_first_bg = false; // show extrinsic adjustment differences
public boolean show_interframe = false; // show interframe processing
public boolean show_filter_ly = false; // show dsi filtering by LY clusters
public boolean show_extrinsic = false; // show extrinsic adjustment differences public boolean show_extrinsic = false; // show extrinsic adjustment differences
public boolean show_ortho_combine = false; // Show 'ortho_combine' public boolean show_ortho_combine = false; // Show 'ortho_combine'
public boolean show_refine_supertiles = false; // show 'refine_disparity_supertiles' public boolean show_refine_supertiles = false; // show 'refine_disparity_supertiles'
...@@ -1053,6 +1063,12 @@ public class CLTParameters { ...@@ -1053,6 +1063,12 @@ public class CLTParameters {
properties.setProperty(prefix+"ih_norm_center", this.ih_norm_center+""); properties.setProperty(prefix+"ih_norm_center", this.ih_norm_center+"");
properties.setProperty(prefix+"inf_restore_disp", this.inf_restore_disp+""); properties.setProperty(prefix+"inf_restore_disp", this.inf_restore_disp+"");
properties.setProperty(prefix+"intra_keep_strength", this.intra_keep_strength+"");
properties.setProperty(prefix+"intra_keep_conditional_strength", this.intra_keep_conditional_strength+"");
properties.setProperty(prefix+"intra_absolute_disparity_tolerance", this.intra_absolute_disparity_tolerance+"");
properties.setProperty(prefix+"intra_relative_disparity_tolerance", this.intra_relative_disparity_tolerance+"");
properties.setProperty(prefix+"intra_cluster_size", this.intra_cluster_size+"");
properties.setProperty(prefix+"ly_lma_ers", this.ly_lma_ers+""); properties.setProperty(prefix+"ly_lma_ers", this.ly_lma_ers+"");
properties.setProperty(prefix+"ly_gt_strength", this.ly_gt_strength+""); properties.setProperty(prefix+"ly_gt_strength", this.ly_gt_strength+"");
properties.setProperty(prefix+"ly_gt_use_wnd", this.ly_gt_use_wnd+""); properties.setProperty(prefix+"ly_gt_use_wnd", this.ly_gt_use_wnd+"");
...@@ -1656,6 +1672,8 @@ public class CLTParameters { ...@@ -1656,6 +1672,8 @@ public class CLTParameters {
properties.setProperty(prefix+"dbg_early_exit", this.dbg_early_exit+""); properties.setProperty(prefix+"dbg_early_exit", this.dbg_early_exit+"");
properties.setProperty(prefix+"show_first_bg", this.show_first_bg+""); properties.setProperty(prefix+"show_first_bg", this.show_first_bg+"");
properties.setProperty(prefix+"show_interframe", this.show_interframe+"");
properties.setProperty(prefix+"show_filter_ly", this.show_filter_ly+"");
properties.setProperty(prefix+"show_extrinsic", this.show_extrinsic+""); properties.setProperty(prefix+"show_extrinsic", this.show_extrinsic+"");
properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+""); properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+"");
properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+""); properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+"");
...@@ -1823,8 +1841,6 @@ public class CLTParameters { ...@@ -1823,8 +1841,6 @@ public class CLTParameters {
if (properties.getProperty(prefix+"fcorr_inf_quad")!=null) this.fcorr_inf_quad=Boolean.parseBoolean(properties.getProperty(prefix+"fcorr_inf_quad")); if (properties.getProperty(prefix+"fcorr_inf_quad")!=null) this.fcorr_inf_quad=Boolean.parseBoolean(properties.getProperty(prefix+"fcorr_inf_quad"));
if (properties.getProperty(prefix+"fcorr_inf_vert")!=null) this.fcorr_inf_vert=Boolean.parseBoolean(properties.getProperty(prefix+"fcorr_inf_vert")); if (properties.getProperty(prefix+"fcorr_inf_vert")!=null) this.fcorr_inf_vert=Boolean.parseBoolean(properties.getProperty(prefix+"fcorr_inf_vert"));
if (properties.getProperty(prefix+"inf_disp_apply")!=null) this.inf_disp_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_disp_apply")); if (properties.getProperty(prefix+"inf_disp_apply")!=null) this.inf_disp_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_disp_apply"));
if (properties.getProperty(prefix+"inf_repeat")!=null) this.inf_repeat=Integer.parseInt(properties.getProperty(prefix+"inf_repeat")); if (properties.getProperty(prefix+"inf_repeat")!=null) this.inf_repeat=Integer.parseInt(properties.getProperty(prefix+"inf_repeat"));
// if (properties.getProperty(prefix+"inf_mism_apply")!=null) this.inf_mism_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_mism_apply")); // if (properties.getProperty(prefix+"inf_mism_apply")!=null) this.inf_mism_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_mism_apply"));
...@@ -1848,6 +1864,12 @@ public class CLTParameters { ...@@ -1848,6 +1864,12 @@ public class CLTParameters {
if (properties.getProperty(prefix+"ih_norm_center")!=null) this.ih_norm_center=Boolean.parseBoolean(properties.getProperty(prefix+"ih_norm_center")); if (properties.getProperty(prefix+"ih_norm_center")!=null) this.ih_norm_center=Boolean.parseBoolean(properties.getProperty(prefix+"ih_norm_center"));
if (properties.getProperty(prefix+"inf_restore_disp")!=null) this.inf_restore_disp=Boolean.parseBoolean(properties.getProperty(prefix+"inf_restore_disp")); if (properties.getProperty(prefix+"inf_restore_disp")!=null) this.inf_restore_disp=Boolean.parseBoolean(properties.getProperty(prefix+"inf_restore_disp"));
if (properties.getProperty(prefix+"intra_keep_strength")!=null) this.intra_keep_strength=Double.parseDouble(properties.getProperty(prefix+"intra_keep_strength"));
if (properties.getProperty(prefix+"intra_keep_conditional_strength")!=null) this.intra_keep_conditional_strength=Double.parseDouble(properties.getProperty(prefix+"intra_keep_conditional_strength"));
if (properties.getProperty(prefix+"intra_absolute_disparity_tolerance")!=null) this.intra_absolute_disparity_tolerance=Double.parseDouble(properties.getProperty(prefix+"intra_absolute_disparity_tolerance"));
if (properties.getProperty(prefix+"intra_relative_disparity_tolerance")!=null) this.intra_relative_disparity_tolerance=Double.parseDouble(properties.getProperty(prefix+"intra_relative_disparity_tolerance"));
if (properties.getProperty(prefix+"intra_cluster_size")!=null) this.intra_cluster_size=Integer.parseInt(properties.getProperty(prefix+"intra_cluster_size"));
if (properties.getProperty(prefix+"ly_lma_ers")!=null) this.ly_lma_ers=Boolean.parseBoolean(properties.getProperty(prefix+"ly_lma_ers")); if (properties.getProperty(prefix+"ly_lma_ers")!=null) this.ly_lma_ers=Boolean.parseBoolean(properties.getProperty(prefix+"ly_lma_ers"));
if (properties.getProperty(prefix+"ly_gt_strength")!=null) this.ly_gt_strength=Double.parseDouble(properties.getProperty(prefix+"ly_gt_strength")); if (properties.getProperty(prefix+"ly_gt_strength")!=null) this.ly_gt_strength=Double.parseDouble(properties.getProperty(prefix+"ly_gt_strength"));
if (properties.getProperty(prefix+"ly_gt_use_wnd")!=null) this.ly_gt_use_wnd=Boolean.parseBoolean(properties.getProperty(prefix+"ly_gt_use_wnd")); if (properties.getProperty(prefix+"ly_gt_use_wnd")!=null) this.ly_gt_use_wnd=Boolean.parseBoolean(properties.getProperty(prefix+"ly_gt_use_wnd"));
...@@ -2467,6 +2489,8 @@ public class CLTParameters { ...@@ -2467,6 +2489,8 @@ public class CLTParameters {
if (properties.getProperty(prefix+"dbg_early_exit")!=null) this.dbg_early_exit=Integer.parseInt(properties.getProperty(prefix+"dbg_early_exit")); if (properties.getProperty(prefix+"dbg_early_exit")!=null) this.dbg_early_exit=Integer.parseInt(properties.getProperty(prefix+"dbg_early_exit"));
if (properties.getProperty(prefix+"show_first_bg")!=null) this.show_first_bg=Boolean.parseBoolean(properties.getProperty(prefix+"show_first_bg")); if (properties.getProperty(prefix+"show_first_bg")!=null) this.show_first_bg=Boolean.parseBoolean(properties.getProperty(prefix+"show_first_bg"));
if (properties.getProperty(prefix+"show_interframe")!=null) this.show_interframe=Boolean.parseBoolean(properties.getProperty(prefix+"show_interframe"));
if (properties.getProperty(prefix+"show_filter_ly")!=null) this.show_filter_ly=Boolean.parseBoolean(properties.getProperty(prefix+"show_filter_ly"));
if (properties.getProperty(prefix+"show_extrinsic")!=null) this.show_extrinsic=Boolean.parseBoolean(properties.getProperty(prefix+"show_extrinsic")); if (properties.getProperty(prefix+"show_extrinsic")!=null) this.show_extrinsic=Boolean.parseBoolean(properties.getProperty(prefix+"show_extrinsic"));
if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine")); if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles")); if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles"));
...@@ -2684,6 +2708,18 @@ public class CLTParameters { ...@@ -2684,6 +2708,18 @@ public class CLTParameters {
gd.addCheckbox ("Replace samples with a single average with equal weight", this.ih_norm_center); gd.addCheckbox ("Replace samples with a single average with equal weight", this.ih_norm_center);
gd.addCheckbox ("Add disparity back to d{x,y}[i] (debug feature)", this.inf_restore_disp); gd.addCheckbox ("Add disparity back to d{x,y}[i] (debug feature)", this.inf_restore_disp);
gd.addTab ("Intra", "Intrascene DSI filtering");
gd.addNumericField("Keep tile if it is stronger than", this.intra_keep_strength, 3,5,"",
"Regardless of the clustered (4x4 typical) average value");
gd.addNumericField("Keep tile conditionally if it is stonger than", this.intra_keep_conditional_strength, 3,5,"",
"Keep tile disparity if it has close disparity among 9 neighbor clusters");
gd.addNumericField("Absolute disparity tolearance", this.intra_absolute_disparity_tolerance, 3,5,"pix",
"Use when comparing with neighbor clusters");
gd.addNumericField("Relative disparity tolearance", this.intra_relative_disparity_tolerance, 3,5,"pix/pix",
"Add to absolute disparity tolerance, multiply by disparity (relaxes for near tiles)");
gd.addNumericField("Cluster size for consolidation", this.intra_cluster_size, 0, 5,"",
"Typically 4 for 4x4 clusters");
gd.addTab ("Lazy eye", "Lazy eye parameters"); gd.addTab ("Lazy eye", "Lazy eye parameters");
...@@ -3471,6 +3507,8 @@ public class CLTParameters { ...@@ -3471,6 +3507,8 @@ public class CLTParameters {
gd.addNumericField("Temporay exit stage (0- normal execution)", this.dbg_early_exit, 0,6,"","Temporary exit at intermediate stage (0 - normal)"); gd.addNumericField("Temporay exit stage (0- normal execution)", this.dbg_early_exit, 0,6,"","Temporary exit at intermediate stage (0 - normal)");
gd.addCheckbox ("Show first infinity scan", this.show_first_bg, "Show results of the first calculated background scan"); gd.addCheckbox ("Show first infinity scan", this.show_first_bg, "Show results of the first calculated background scan");
gd.addCheckbox ("Show interframe processing", this.show_interframe, "Debugging interframe functionality");
gd.addCheckbox ("Show DSI filtering by LY clusters", this.show_filter_ly, "Filtering DSI by comparing with clusters prepared for LY adjustment");
gd.addCheckbox ("Show extrinsic adjustment differences", this.show_extrinsic); gd.addCheckbox ("Show extrinsic adjustment differences", this.show_extrinsic);
gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine); gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine);
gd.addCheckbox ("Show 'refine_disparity_supertiles'", this.show_refine_supertiles); gd.addCheckbox ("Show 'refine_disparity_supertiles'", this.show_refine_supertiles);
...@@ -3644,6 +3682,12 @@ public class CLTParameters { ...@@ -3644,6 +3682,12 @@ public class CLTParameters {
this.ih_norm_center= gd.getNextBoolean(); this.ih_norm_center= gd.getNextBoolean();
this.inf_restore_disp= gd.getNextBoolean(); this.inf_restore_disp= gd.getNextBoolean();
this.intra_keep_strength= gd.getNextNumber();
this.intra_keep_conditional_strength= gd.getNextNumber();
this.intra_absolute_disparity_tolerance= gd.getNextNumber();
this.intra_relative_disparity_tolerance= gd.getNextNumber();
this.intra_cluster_size= (int) gd.getNextNumber();
this.ly_lma_ers = gd.getNextBoolean(); this.ly_lma_ers = gd.getNextBoolean();
this.ly_gt_strength= gd.getNextNumber(); this.ly_gt_strength= gd.getNextNumber();
this.ly_gt_use_wnd= gd.getNextBoolean(); this.ly_gt_use_wnd= gd.getNextBoolean();
...@@ -4255,6 +4299,8 @@ public class CLTParameters { ...@@ -4255,6 +4299,8 @@ public class CLTParameters {
this.dbg_early_exit = (int) gd.getNextNumber(); this.dbg_early_exit = (int) gd.getNextNumber();
this.show_first_bg= gd.getNextBoolean(); this.show_first_bg= gd.getNextBoolean();
this.show_interframe= gd.getNextBoolean();
this.show_filter_ly= gd.getNextBoolean();
this.show_extrinsic= gd.getNextBoolean(); this.show_extrinsic= gd.getNextBoolean();
this.show_ortho_combine= gd.getNextBoolean(); this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles=gd.getNextBoolean(); this.show_refine_supertiles=gd.getNextBoolean();
......
...@@ -142,10 +142,12 @@ public class EyesisCorrectionParameters { ...@@ -142,10 +142,12 @@ public class EyesisCorrectionParameters {
public int rig_batch_adjust_aux = 0; public int rig_batch_adjust_aux = 0;
public int rig_batch_adjust_rig = 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_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_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 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_dsi1 = true; // experimental for interscene
public boolean clt_batch_apply_man = false; // Apply (and disable) manual pixel shift 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_extrinsic = false; // Calibrate extrinsic parameters for each set
public boolean clt_batch_poly = false; // Calculate fine polynomial correction for each set public boolean clt_batch_poly = false; // Calculate fine polynomial correction for each set
...@@ -285,6 +287,7 @@ public class EyesisCorrectionParameters { ...@@ -285,6 +287,7 @@ public class EyesisCorrectionParameters {
cp.rig_batch_adjust_aux_gt = this.rig_batch_adjust_aux_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.rig_batch_adjust_rig_gt = this.rig_batch_adjust_rig_gt;
cp.clt_batch_dsi1= this.clt_batch_dsi1;
cp.clt_batch_apply_man= this.clt_batch_apply_man; cp.clt_batch_apply_man= this.clt_batch_apply_man;
cp.clt_batch_extrinsic= this.clt_batch_extrinsic; cp.clt_batch_extrinsic= this.clt_batch_extrinsic;
cp.clt_batch_poly= this.clt_batch_poly; cp.clt_batch_poly= this.clt_batch_poly;
...@@ -463,6 +466,7 @@ public class EyesisCorrectionParameters { ...@@ -463,6 +466,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"rig_batch_adjust_aux_gt", this.rig_batch_adjust_aux_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+"rig_batch_adjust_rig_gt", this.rig_batch_adjust_rig_gt+"");
properties.setProperty(prefix+"clt_batch_dsi1", this.clt_batch_dsi1+"");
properties.setProperty(prefix+"clt_batch_apply_man", this.clt_batch_apply_man+""); 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_extrinsic", this.clt_batch_extrinsic+"");
properties.setProperty(prefix+"clt_batch_poly", this.clt_batch_poly+""); properties.setProperty(prefix+"clt_batch_poly", this.clt_batch_poly+"");
...@@ -620,6 +624,7 @@ public class EyesisCorrectionParameters { ...@@ -620,6 +624,7 @@ public class EyesisCorrectionParameters {
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_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+"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_dsi1")!= null) this.clt_batch_dsi1=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi1"));
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_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")); if (properties.getProperty(prefix+"clt_batch_extrinsic")!= null) this.clt_batch_extrinsic=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_extrinsic"));
if (properties.getProperty(prefix+"clt_batch_poly")!= null) this.clt_batch_poly=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_poly")); if (properties.getProperty(prefix+"clt_batch_poly")!= null) this.clt_batch_poly=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_poly"));
...@@ -991,6 +996,7 @@ public class EyesisCorrectionParameters { ...@@ -991,6 +996,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Repeat aux camera field adjustment (late, with GT disparity from rig)", this.rig_batch_adjust_aux_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.addNumericField("Repeat 2-quad camera rig field adjustment (late, after all others)", this.rig_batch_adjust_rig_gt, 0);
gd.addCheckbox ("Experimental DSI", this.clt_batch_dsi1); // 21
gd.addCheckbox ("Apply (and disable) manual pixel shift", this.clt_batch_apply_man); // 21 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 gd.addCheckbox ("Calibrate extrinsic parameters for each set", this.clt_batch_extrinsic); // 22
gd.addCheckbox ("Calculate fine polynomial correction for each set", this.clt_batch_poly); // 23 gd.addCheckbox ("Calculate fine polynomial correction for each set", this.clt_batch_poly); // 23
...@@ -1083,6 +1089,7 @@ public class EyesisCorrectionParameters { ...@@ -1083,6 +1089,7 @@ public class EyesisCorrectionParameters {
this.rig_batch_adjust_aux_gt = (int) gd.getNextNumber(); this.rig_batch_adjust_aux_gt = (int) gd.getNextNumber();
this.rig_batch_adjust_rig_gt = (int) gd.getNextNumber(); this.rig_batch_adjust_rig_gt = (int) gd.getNextNumber();
this.clt_batch_dsi1= gd.getNextBoolean(); // 21
this.clt_batch_apply_man= gd.getNextBoolean(); // 21 this.clt_batch_apply_man= gd.getNextBoolean(); // 21
this.clt_batch_extrinsic= gd.getNextBoolean(); // 22 this.clt_batch_extrinsic= gd.getNextBoolean(); // 22
this.clt_batch_poly= gd.getNextBoolean(); // 23 this.clt_batch_poly= gd.getNextBoolean(); // 23
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
package com.elphel.imagej.tileprocessor; package com.elphel.imagej.tileprocessor;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.commons.math3.complex.Quaternion; import org.apache.commons.math3.complex.Quaternion;
import org.apache.commons.math3.geometry.euclidean.threed.Rotation; import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention; import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
...@@ -43,6 +46,51 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -43,6 +46,51 @@ public class ErsCorrection extends GeometryCorrection {
Quaternion[] ers_quaternion_dt; // per scan line Quaternion[] ers_quaternion_dt; // per scan line
double [][] ers_atr; // azimuth-tilt-roll per scan line double [][] ers_atr; // azimuth-tilt-roll per scan line
double [][] ers_atr_dt; // angular velocities per scan line double [][] ers_atr_dt; // angular velocities per scan line
/**
* Position+orientation (world XYZ, Azimuth, Tilt, Roll) of other scenes relative to the position of this camera.
* Positions/orientations are sampled during scanning of the center line
*/
HashMap <String, XyzAtr> scenes_poses = null;
public class XyzAtr {
double [] xyz;
double [] atr;
public XyzAtr() {
xyz = new double[3];
atr = new double[3];
}
public XyzAtr(String s) {
ArrayList<Double> lxyzatr = new ArrayList<Double>();
for (String snumber : s.split(","))
lxyzatr.add(Double.parseDouble(snumber));
Double [] xyzatr = new Double[6];
xyzatr = lxyzatr.toArray(xyzatr);
xyz = new double [] {xyzatr[0],xyzatr[1],xyzatr[2]};
atr = new double [] {xyzatr[3],xyzatr[4],xyzatr[5]};
}
public String toString() {
return String.format("%f, %f, %f, %f, %f, %f",xyz[0],xyz[1],xyz[2],atr[0],atr[1],atr[2]);
}
public double [] getXYZ() {
return xyz;
}
public double [] getATR() {
return atr;
}
public void setXYZ(double [] d) {
xyz[0] = d[0];
xyz[1] = d[1];
xyz[2] = d[2];
}
public void setATR(double [] d) {
atr[0] = d[0];
atr[1] = d[1];
atr[2] = d[2];
}
}
public ErsCorrection(GeometryCorrection gc) { public ErsCorrection(GeometryCorrection gc) {
debugLevel = gc.debugLevel; debugLevel = gc.debugLevel;
line_time = gc.line_time; // 26.5E-6; // duration of sensor scan line (for ERS) line_time = gc.line_time; // 26.5E-6; // duration of sensor scan line (for ERS)
......
...@@ -7640,18 +7640,8 @@ public class QuadCLTCPU { ...@@ -7640,18 +7640,8 @@ public class QuadCLTCPU {
return measurements; return measurements;
} }
/** public void extrinsics_prepare( // USED in lwir TODO: provide boolean
*
* @param clt_parameters
* @param adjust_poly
* @param threadsMax
* @param updateStatus
* @param debugLevel
* @return true on success, false - on failure
*/
public boolean extrinsicsCLT( // USED in lwir TODO: provide boolean
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean adjust_poly,
double inf_min, // = -1.0; double inf_min, // = -1.0;
double inf_max, // = 1.0; double inf_max, // = 1.0;
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
...@@ -7660,10 +7650,6 @@ public class QuadCLTCPU { ...@@ -7660,10 +7650,6 @@ public class QuadCLTCPU {
{ {
final boolean batch_mode = clt_parameters.batch_run; final boolean batch_mode = clt_parameters.batch_run;
int debugLevelInner = batch_mode ? -5: debugLevel; 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.getLymChange(is_aux); // 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
int bg_scan = 0; int bg_scan = 0;
int combo_scan= tp.clt_3d_passes.size()-1; int combo_scan= tp.clt_3d_passes.size()-1;
...@@ -7769,19 +7755,7 @@ public class QuadCLTCPU { ...@@ -7769,19 +7755,7 @@ public class QuadCLTCPU {
if (debugLevel > -3) { // -1 if (debugLevel > -3) { // -1
System.out.println("Number of background tiles = " + num_bg+", number of lazy eye tiles = " + num_combo); System.out.println("Number of background tiles = " + num_bg+", number of lazy eye tiles = " + num_combo);
} }
// measure combo
/*
CLTMeasure( // perform single pass according to prepared tiles operations and disparity **** CPU?
clt_parameters,
combo_scan,
false, // final boolean save_textures,
true, // final boolean save_corr,
null, // final double [][] mismatch, // null or double [12][]
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner - 1);
*/
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters, clt_parameters,
combo_scan, combo_scan,
...@@ -7796,6 +7770,10 @@ public class QuadCLTCPU { ...@@ -7796,6 +7770,10 @@ public class QuadCLTCPU {
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan, tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"combo_scan-"+combo_scan+"_post"); //String title) "combo_scan-"+combo_scan+"_post"); //String title)
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"combo_measured_scan-"+combo_scan+"_post", //String title)
true); // measured only
} }
double [][] filtered_combo_scand_isp_strength = tp.getFilteredDisparityStrength( double [][] filtered_combo_scand_isp_strength = tp.getFilteredDisparityStrength(
...@@ -7881,6 +7859,46 @@ public class QuadCLTCPU { ...@@ -7881,6 +7859,46 @@ public class QuadCLTCPU {
dbg_combo_use}; dbg_combo_use};
(new ShowDoubleFloatArrays()).showArrays(dbg_img, tp.getTilesX(), tp.getTilesY(), true, "extrinsics_bgnd_combo",titles); (new ShowDoubleFloatArrays()).showArrays(dbg_img, tp.getTilesX(), tp.getTilesY(), true, "extrinsics_bgnd_combo",titles);
} }
}
/**
*
* @param clt_parameters
* @param adjust_poly
* @param threadsMax
* @param updateStatus
* @param debugLevel
* @return true on success, false - on failure
*/
public boolean extrinsicsCLT( // USED in lwir TODO: provide boolean
CLTParameters clt_parameters,
boolean adjust_poly,
double inf_min, // = -1.0;
double inf_max, // = 1.0;
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
extrinsics_prepare(
clt_parameters,
inf_min, // = -1.0;
inf_max, // = 1.0;
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
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.getLymChange(is_aux); // 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
int bg_scan = 0;
int combo_scan= tp.clt_3d_passes.size()-1;
AlignmentCorrection ac = null; AlignmentCorrection ac = null;
if (!clt_parameters.ly_lma_ers ) { if (!clt_parameters.ly_lma_ers ) {
ac = new AlignmentCorrection(this); ac = new AlignmentCorrection(this);
...@@ -7894,11 +7912,10 @@ public class QuadCLTCPU { ...@@ -7894,11 +7912,10 @@ public class QuadCLTCPU {
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan, tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"combo_scan-"+combo_scan+"_post"); //String title) "combo_scan-"+combo_scan+"_post"); //String title)
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"combo_measured_scan-"+combo_scan+"_post"); //String title)
} }
// tp.showScan(
// tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan,
// "bg_scan_post"); //String title)
double comp_diff = min_sym_update + 1; // (> min_sym_update) double comp_diff = min_sym_update + 1; // (> min_sym_update)
...@@ -7916,10 +7933,15 @@ public class QuadCLTCPU { ...@@ -7916,10 +7933,15 @@ public class QuadCLTCPU {
tp.threadsMax, // maximal number of threads to launch tp.threadsMax, // maximal number of threads to launch
false, // updateStatus, false, // updateStatus,
debugLevelInner -1); // - 1); // -5-1 debugLevelInner -1); // - 1); // -5-1
if (debugLevel > -2) { /// if (debugLevel > -2){
if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-2)) {
tp.showScan( tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan, tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"LY_combo_scan-"+combo_scan+"_post"); //String title) "LY_combo_scan-"+combo_scan+"_post"); //String title)
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"LY_measured_combo_scan-"+combo_scan+"_post", //String title)
true);
} }
int tilesX = tp.getTilesX(); int tilesX = tp.getTilesX();
...@@ -7939,7 +7961,7 @@ public class QuadCLTCPU { ...@@ -7939,7 +7961,7 @@ public class QuadCLTCPU {
boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0); boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0);
CLTPass3d scan = tp.clt_3d_passes.get(combo_scan); CLTPass3d scan = tp.clt_3d_passes.get(combo_scan);
// for the second half of runs (always for single run) - limit infinity min/max // for the second half of runs (always for single run) - limit infinity min/max
if (debugLevel > 9) { if (!batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) {
ea.showInput(scan.getLazyEyeData(),"first_data"); ea.showInput(scan.getLazyEyeData(),"first_data");
} }
...@@ -8228,6 +8250,377 @@ public class QuadCLTCPU { ...@@ -8228,6 +8250,377 @@ public class QuadCLTCPU {
} }
public double [][] filterByLY(
CLTParameters clt_parameters,
double inf_min, // = -1.0;
double inf_max, // = 1.0;
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
extrinsics_prepare(
clt_parameters,
inf_min, // = -1.0;
inf_max, // = 1.0;
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
// FIXME: Cleanup - reduce number of measurements (when using neighbors, there are many duplicates.
// Use existing multi-pass refinement (now unconditionally two times after calculated)
// Other cleanup to match older code
// Implement dedicated flexible multi-tile consolidation similar to infinity in LY
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 bg_scan = 0 ;
int combo_scan= tp.clt_3d_passes.size()-1;
// iteration steps
// if (true) { // !batch_mode && clt_parameters.show_extrinsic && (debugLevel >-1)) {
if (!batch_mode && clt_parameters.show_filter_ly && (debugLevel >-1)) {
tp.showScan(
tp.clt_3d_passes.get(bg_scan), // CLTPass3d scan,
"bg_scan_post"); //String title)
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"combo_scan-"+combo_scan+"_post"); //String title)
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"combo_measured_scan-"+combo_scan+"_post"); //String title)
}
if (update_disp_from_latest) {
tp.clt_3d_passes.get(combo_scan).updateDisparity(); // tile_op from disparity
}
CLTPass3d scan = tp.clt_3d_passes.get(combo_scan);
// before CLTMeasureLY that assignes clusters wityh BG to BG
double [] disparity = scan.getDisparity().clone();
double [] strength = scan.getStrength().clone();
CLTMeasureLY( // perform single pass according to prepared tiles operations and disparity // USED in lwir
clt_parameters,
combo_scan, // final int scanIndex,
// only combine and calculate once, next passes keep
// remeasure each pass - target disparity is the same, but vector changes
bg_scan, // (num_iter >0)? -1: bg_scan, // final int bgIndex, // combine, if >=0
tp.threadsMax, // maximal number of threads to launch
false, // updateStatus,
debugLevelInner -1); // - 1); // -5-1
if (!batch_mode && clt_parameters.show_filter_ly && (debugLevel >-1)) {
// if (debugLevel > -3){
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"LY_combo_scan-"+combo_scan+"_post"); //String title)
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"LY_measured_combo_scan-"+combo_scan+"_post", //String title)
true);
}
// temporarily:
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
int cluster_size = clt_parameters.tileStep;
final int clustersX= (tilesX + cluster_size - 1) / cluster_size;
final int clustersY= (tilesY + cluster_size - 1) / cluster_size;
// if (true) {
if (!batch_mode && clt_parameters.show_filter_ly && (debugLevel >-1)) {
ExtrinsicAdjustment ea = new ExtrinsicAdjustment(
geometryCorrection, // GeometryCorrection gc,
clt_parameters.tileStep, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY);
ea.showInput(scan.getLazyEyeData(),"first_data");
}
int [][][] tile_ops = new int [9][][];
double [][][] disparity_maps = new double [9][][];
double [][] ly = scan.getLazyEyeData();
int op = ImageDtt.setImgMask(0, 0xf);
op = ImageDtt.setPairMask(op,0xf);
op = ImageDtt.setForcedDisparity(op,true);
double [][] ds_orig = {disparity.clone(),strength.clone()};
int num_meas = remeasureFromLY( // now - always 9, last is center
clt_parameters.intra_keep_strength, // final double keep_strength, // do not remeasure if stronger than
clt_parameters.intra_keep_conditional_strength, // final double keep_conditional_strength, // keep if has a close neighbor in clusters
clt_parameters.intra_absolute_disparity_tolerance, // final double absolute_disparity_tolerance, //
clt_parameters.intra_relative_disparity_tolerance, // final double relative_disparity_tolerance, //
clt_parameters.intra_cluster_size, // final int cluster_size, // 4
ly, // final double [][] lazy_eye_data, // measured by cltMeasureLazyEyeGPU
disparity, // final double [] disparity, modified!
strength, // final double [] strength, modified!
disparity_maps, // final double [][][] disparity_map, // should be [9][][]
tile_ops, // final int [][][] tile_op, // should be [9][][]
op, // final int tile_op_value,
threadsMax,
updateStatus,
debugLevel);
if (debugLevel >-1) {
System.out.println("remeasureFromLY Done");
}
for (int nm = 0; nm < num_meas; nm++) {
CLTPass3d pass = new CLTPass3d(tp);
pass.tile_op = tile_ops[nm];
pass.disparity = disparity_maps[nm];
tp.clt_3d_passes.add(pass);
}
if (debugLevel >-1) {
System.out.println("Preparation Done");
}
// measure prepared:
for (int nm = 0; nm < num_meas; nm++) {
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
combo_scan + 1 + nm,
false, // true, // final boolean save_textures,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
}
if (debugLevel >-1) {
System.out.println("Measurements Done");
}
double [][] disparities = new double[num_meas+2][]; // y = scan.getDisparity();
double [][] strengths = new double[num_meas+2][]; // scan.getStrength(); // has NaN!
for (int nm = 0; nm < num_meas; nm++) {
disparities[nm+2] = tp.clt_3d_passes.get(combo_scan + 1 + nm).getDisparity();
strengths [nm+2] = tp.clt_3d_passes.get(combo_scan + 1 + nm).getStrength();
}
disparities[0] = ds_orig[0]; // scan.getDisparity().clone();
strengths[0] = ds_orig[1]; // scan.getStrength().clone();
disparities[1] = disparity; // modified by remeasureFromLY()
strengths[1] = strength; // modified by remeasureFromLY()
double [] disparity_combo = disparities[1];
double [] strength_combo = strengths[1];
for (int nt = 0; nt < disparity_combo.length; nt++) {
/// if (nt == 11764) {
/// System.out.println("Debug1");
/// }
for (int nm = 0; nm < num_meas; nm++) {
if (strengths[nm+2][nt] > strength_combo[nt]) {
strength_combo[nt] = strengths[nm+2][nt];
disparity_combo[nt] = disparities[nm+2][nt];
}
}
}
// FIXME: probably a wrong way to set
scan.calc_disparity_combo = disparity_combo;
scan.strength = strength_combo;
scan.is_combo = true;//?
int [][] tile_ops_combo = new int[tilesY][tilesX];
double [][] disparity_map_combo = new double[tilesY][tilesX];
for (int nm = 0; nm < num_meas; nm++) {
for (int ty = 0; ty < tilesY; ty++) {
for (int tx = 0; tx < tilesX; tx++) {
tile_ops_combo[ty][tx] |= tile_ops[nm][ty][tx];
disparity_map_combo[ty][tx] = disparity_combo[ty*tilesX + tx];
}
}
}
if (!batch_mode && clt_parameters.show_filter_ly && (debugLevel >-1)) {
// if (debugLevel >-10) {
/*
for (int nm = 0; nm < num_meas; nm++) {
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"refine_from_LY-"+(combo_scan + 1 + nm)); //String title)
}
*/
tp.showScan(
tp.clt_3d_passes.get(combo_scan), // CLTPass3d scan,
"refined_from_LY-"+combo_scan); //String title)
(new ShowDoubleFloatArrays()).showArrays(
disparities,
tilesX,
tilesY,
true, "disparities"); // , titles);
(new ShowDoubleFloatArrays()).showArrays(
strengths,
tilesX,
tilesY,
true, "strengths"); // , titles);
}
CLTPass3d pass = new CLTPass3d(tp);
pass.tile_op = tile_ops_combo;
pass.disparity = disparity_map_combo;
tp.clt_3d_passes.add(pass);
int last_scan = tp.clt_3d_passes.size()-1;
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
last_scan,
false, // true, // final boolean save_textures,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
double [] disparity2 = tp.clt_3d_passes.get(last_scan).getDisparity();
double [] strength2 = tp.clt_3d_passes.get(last_scan).getStrength();
//strength_combo
// combine
for (int tl = 0; tl < strength2.length; tl++) {
if (strength2[tl] <= 0.0) {
strength2[tl] = strength_combo[tl];
}
}
if (!batch_mode && clt_parameters.show_filter_ly && (debugLevel >-1)) {
tp.showScan(
tp.clt_3d_passes.get(last_scan), // CLTPass3d scan,
"refined_twice-"+last_scan); //String title)
}
//----------------
double [][] disparity_map_combo2 = new double[tilesY][tilesX];
for (int nm = 0; nm < num_meas; nm++) {
for (int ty = 0; ty < tilesY; ty++) {
for (int tx = 0; tx < tilesX; tx++) {
disparity_map_combo2[ty][tx] = disparity2[ty*tilesX + tx];
}
}
}
CLTPass3d pass2 = new CLTPass3d(tp);
pass2.tile_op = tile_ops_combo;
pass2.disparity = disparity_map_combo2;
tp.clt_3d_passes.add(pass);
int last_scan2 = tp.clt_3d_passes.size()-1;
CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
clt_parameters,
last_scan2,
false, // true, // final boolean save_textures,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
double [] disparity3 = tp.clt_3d_passes.get(last_scan).getDisparity();
double [] strength3 = tp.clt_3d_passes.get(last_scan).getStrength();
// combine
for (int tl = 0; tl < strength3.length; tl++) {
if (strength3[tl] <= 0.0) {
strength3[tl] = strength2[tl];
}
}
// if (debugLevel >-10) {
if (!batch_mode && clt_parameters.show_filter_ly && (debugLevel >-1)) {
tp.showScan(
tp.clt_3d_passes.get(last_scan2), // CLTPass3d scan,
"refined_three-"+last_scan2); //String title)
}
if (debugLevel >-3) {
System.out.println("Done");
}
double [][] enhanced_dsi = {disparity3, strength3};
return enhanced_dsi;
}
//double [][] lazy_eye_data_final = new double [clustersY*clustersX][]
int remeasureFromLY(
final double keep_strength, // do not remeasure if stronger than
final double keep_conditional_strength, // keep if has a close neighbor in clusters
final double absolute_disparity_tolerance, //
final double relative_disparity_tolerance, //
final int cluster_size, // 4
final double [][] lazy_eye_data, // measured by cltMeasureLazyEyeGPU
final double [] disparity, // will be modified
final double [] strength, // will be modified
final double [][][] disparity_map, // should be [9][][]
final int [][][] tile_op, // should be [9][][]
final int tile_op_value,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
final int clustersX= (tilesX + cluster_size - 1) / cluster_size;
final int clustersY= (tilesY + cluster_size - 1) / cluster_size;
final int numTiles = tilesX*tilesY;
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int i = 0; i < disparity_map.length; i++) {
disparity_map[i] = new double [tilesY][tilesX];
tile_op[i] = new int [tilesY][tilesX];
}
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
TileNeibs tn = new TileNeibs(clustersX,clustersY);
double [] neibs_disp = new double [9];
double [] neibs_ordered;
for (int indx_tile = ai.getAndIncrement(); indx_tile < numTiles; indx_tile = ai.getAndIncrement()) {
if (indx_tile == 11764) {
System.out.println("DEBUG");
}
if (strength[indx_tile] >= keep_strength) { // already strong enough
continue;
}
// get cluster disparities around this cluster
int tileX = indx_tile % tilesX;
int tileY = indx_tile / tilesX;
int clusterX = tileX / cluster_size;
int clusterY = tileY / cluster_size;
int cluster = clusterX+ clustersX*clusterY;
for (int dir = 0; dir < 9; dir++) {
neibs_disp[dir] = Double.NaN;
int icl = tn.getNeibIndex(cluster, dir);
if (icl >= 0) {
if (lazy_eye_data[icl] != null) {
neibs_disp[dir] = lazy_eye_data[icl][ExtrinsicAdjustment.INDX_DISP];
}
}
}
boolean keep = false;
if (strength[indx_tile] >= keep_conditional_strength) {// See if any of the cluster disparities is within range
for (int dir = 0; dir < 9; dir++) if (!Double.isNaN(neibs_disp[dir])){
double maxdiff = absolute_disparity_tolerance + Math.abs(neibs_disp[dir]) * relative_disparity_tolerance;
if (Math.abs(neibs_disp[dir] - disparity[indx_tile]) <= maxdiff) {
keep = true;
break;
}
}
}
if (keep) {
continue;
}
// Compact and order neighbors and
int nneibs = 0;
for (int dir = 0; dir < 9; dir++) if (!Double.isNaN(neibs_disp[dir])){
nneibs++;
}
if (nneibs == 0) {
disparity[indx_tile] = Double.NaN;
strength[indx_tile] = 0.0;
continue;
}
for (int i = 0; i < neibs_disp.length; i++) if (!Double.isNaN(neibs_disp[i])){
disparity_map[i][tileY][tileX] = neibs_disp[i];
tile_op[i][tileY][tileX] = tile_op_value;
}
if (!Double.isNaN(neibs_disp[8])) { // center, where this tile is
disparity[indx_tile] = neibs_disp[8]; // if that tile original strength will win, use LY disparity
} else {
// Maybe improve -
disparity[indx_tile] = Double.NaN;
strength[indx_tile] = 0.0;
}
} // end of tile
}
};
}
ImageDtt.startAndJoin(threads);
return 9;
}
public double [][] getRigDSFromTwoQuadCL( // not used in lwir public double [][] getRigDSFromTwoQuadCL( // not used in lwir
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
CLTParameters clt_parameters, CLTParameters clt_parameters,
......
...@@ -3483,7 +3483,7 @@ ImageDtt.startAndJoin(threads); ...@@ -3483,7 +3483,7 @@ ImageDtt.startAndJoin(threads);
if (scan.isProcessed()) titles[nscan] += "+P"; else titles[nscan]+="-P"; if (scan.isProcessed()) titles[nscan] += "+P"; else titles[nscan]+="-P";
if (scan.isCombo()) titles[nscan] += "+C"; else titles[nscan]+="-C"; if (scan.isCombo()) titles[nscan] += "+C"; else titles[nscan]+="-C";
if (scan.getTextureTiles()!=null) titles[nscan] += "+T"; else titles[nscan]+="-T"; if (scan.getTextureTiles()!=null) titles[nscan] += "+T"; else titles[nscan]+="-T";
dbg_img[nscan] = getShowScan(scan)[slice]; dbg_img[nscan] = getShowScan(scan, false)[slice];
if (dbg_img[nscan] != null) num_slices++; if (dbg_img[nscan] != null) num_slices++;
} }
} }
...@@ -3502,10 +3502,21 @@ ImageDtt.startAndJoin(threads); ...@@ -3502,10 +3502,21 @@ ImageDtt.startAndJoin(threads);
return ds_only ? SCAN_TITLES_DS : SCAN_TITLES; return ds_only ? SCAN_TITLES_DS : SCAN_TITLES;
} }
public void showScan( public void showScan(
CLTPass3d scan, CLTPass3d scan,
String in_title) String in_title)
{
showScan(
scan,
in_title,
false);
}
public void showScan(
CLTPass3d scan,
String in_title,
boolean measured_only)
{ {
String [] titles = getScanTitles(); String [] titles = getScanTitles();
String title=in_title; String title=in_title;
...@@ -3514,7 +3525,7 @@ ImageDtt.startAndJoin(threads); ...@@ -3514,7 +3525,7 @@ ImageDtt.startAndJoin(threads);
if (scan.isCombo()) title+="+C"; else title+="-C"; if (scan.isCombo()) title+="+C"; else title+="-C";
if (scan.getTextureTiles()!=null) title+="+T"; else title+="-T"; if (scan.getTextureTiles()!=null) title+="+T"; else title+="-T";
double [][] dbg_img = getShowScan(scan); double [][] dbg_img = getShowScan(scan, measured_only);
(new ShowDoubleFloatArrays()).showArrays( (new ShowDoubleFloatArrays()).showArrays(
dbg_img, dbg_img,
tilesX, tilesX,
...@@ -3646,7 +3657,7 @@ ImageDtt.startAndJoin(threads); ...@@ -3646,7 +3657,7 @@ ImageDtt.startAndJoin(threads);
CLTPass3d scan, CLTPass3d scan,
boolean force_final) boolean force_final)
{ {
double [][] dbg_img = getShowScan(scan); double [][] dbg_img = getShowScan(scan, false);
double [][] ds = new double [2][]; double [][] ds = new double [2][];
if (!force_final && (dbg_img[2] != null)) { if (!force_final && (dbg_img[2] != null)) {
ds[0] = dbg_img[2]; // disparity ds[0] = dbg_img[2]; // disparity
...@@ -3662,7 +3673,8 @@ ImageDtt.startAndJoin(threads); ...@@ -3662,7 +3673,8 @@ ImageDtt.startAndJoin(threads);
} }
public double [][] getShowScan( public double [][] getShowScan(
CLTPass3d scan) CLTPass3d scan,
boolean measured_only)
{ {
int NUM_SLICES=getScanTitles().length; int NUM_SLICES=getScanTitles().length;
int this_IMG_TONE_RGB = 21; int this_IMG_TONE_RGB = 21;
...@@ -3682,6 +3694,8 @@ ImageDtt.startAndJoin(threads); ...@@ -3682,6 +3694,8 @@ ImageDtt.startAndJoin(threads);
// boolean [] ly_force = scan.getLazyEyeForceDisparity(); // boolean [] ly_force = scan.getLazyEyeForceDisparity();
int tlen = tilesX*tilesY; int tlen = tilesX*tilesY;
if (scan.tile_op == null) measured_only = false;
boolean [] measured = new boolean [tlen];
double [][] dbg_img = new double[NUM_SLICES][]; double [][] dbg_img = new double[NUM_SLICES][];
if (scan.tile_op != null) dbg_img[ 0] = new double[tlen]; if (scan.tile_op != null) dbg_img[ 0] = new double[tlen];
if (scan.disparity != null) dbg_img[ 2] = new double[tlen]; if (scan.disparity != null) dbg_img[ 2] = new double[tlen];
...@@ -3693,7 +3707,10 @@ ImageDtt.startAndJoin(threads); ...@@ -3693,7 +3707,10 @@ ImageDtt.startAndJoin(threads);
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx < tilesX; tx++){ for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx < tilesX; tx++){
int nt = ty*tilesX + tx; int nt = ty*tilesX + tx;
if (scan.tile_op != null) dbg_img[ 0][nt] = scan.tile_op[ty][tx]; if (scan.tile_op != null) {
dbg_img[ 0][nt] = scan.tile_op[ty][tx];
measured[nt] = scan.tile_op[ty][tx] > 0;
}
if (scan.disparity != null) dbg_img[ 2][nt] = scan.disparity[ty][tx]; if (scan.disparity != null) dbg_img[ 2][nt] = scan.disparity[ty][tx];
if (scan.selected != null) dbg_img[10][nt] = scan.selected[nt]? 1.0:0.0; if (scan.selected != null) dbg_img[10][nt] = scan.selected[nt]? 1.0:0.0;
if (scan.border_tiles != null) dbg_img[11][nt] = scan.border_tiles[nt]? 1.0:0.0; if (scan.border_tiles != null) dbg_img[11][nt] = scan.border_tiles[nt]? 1.0:0.0;
...@@ -3751,6 +3768,14 @@ ImageDtt.startAndJoin(threads); ...@@ -3751,6 +3768,14 @@ ImageDtt.startAndJoin(threads);
} }
} }
} }
if (measured_only) {
for (int n = 0; n < dbg_img.length; n++) if (dbg_img[n] != null) {
dbg_img[n] = dbg_img[n].clone(); // prevent modifications of the original data !
for (int i = 0; i < tlen; i++) if (!measured[i]){
dbg_img[n][i] = Double.NaN;
}
}
}
return dbg_img; return dbg_img;
} }
......
...@@ -8346,6 +8346,46 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8346,6 +8346,46 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_main.tp.resetCLTPasses(); quadCLT_main.tp.resetCLTPasses();
if (!ok) break; if (!ok) break;
} }
if (quadCLT_main.correctionsParameters.clt_batch_dsi1){
System.out.println("Trying experimental features DSI/ERS");
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);
double [][] dsi_ly = quadCLT_main.filterByLY(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.ly_inf_min_narrow, // double inf_min,
clt_parameters.ly_inf_max_narrow, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel)
dsi[DSI_DISPARITY_MAIN] = dsi_ly[0];
dsi[DSI_STRENGTH_MAIN] = dsi_ly[1];
// if (quadCLT_main.correctionsParameters.clt_batch_dsi) { // Should be always enabled ?
saveDSIMain ();
// }
// clear memory for main
quadCLT_main.tp.resetCLTPasses();
// copy regardless of ML generation
// See if it will copy all files, not just the main camera ones
if (clt_parameters.rig.ml_copyJP4) {
copyJP4src(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // final int debugLevel)
}
}
// Generate 4 main camera images and thumbnail // Generate 4 main camera images and thumbnail
if (quadCLT_main.correctionsParameters.clt_batch_4img){ if (quadCLT_main.correctionsParameters.clt_batch_4img){
if (clt_parameters.gpu_use_main) { if (clt_parameters.gpu_use_main) {
......
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