Commit 6293946d authored by Andrey Filippov's avatar Andrey Filippov

Debugging LY adjustment, tested semi-manual OK

parent 71ac4a10
...@@ -292,6 +292,8 @@ public class CLTParameters { ...@@ -292,6 +292,8 @@ public class CLTParameters {
public double ly_norm_disp = 5.0; // Reduce weight of higher disparity tiles public double ly_norm_disp = 5.0; // Reduce weight of higher disparity tiles
// Lazy eye multi-step fitting // Lazy eye multi-step fitting
public String lym_dbg_path = ""; // read saved extrinsics_bgnd_combo.tif to bypass long preparation
public double lym_overexp = 0.0001; // Any (near) saturated pixels - discard tile (see sat_level also) public double lym_overexp = 0.0001; // Any (near) saturated pixels - discard tile (see sat_level also)
public boolean lym_update_disp = true; // Update target disparity after each step public boolean lym_update_disp = true; // Update target disparity after each step
public int lym_iter = 25; // Maximal number of iterations public int lym_iter = 25; // Maximal number of iterations
...@@ -1188,6 +1190,9 @@ public class CLTParameters { ...@@ -1188,6 +1190,9 @@ public class CLTParameters {
properties.setProperty(prefix+"ly_disp_rvar_gt", this.ly_disp_rvar_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+"ly_norm_disp", this.ly_norm_disp +"");
properties.setProperty(prefix+"lym_overexp", this.lym_overexp +""); properties.setProperty(prefix+"lym_overexp", this.lym_overexp +"");
properties.setProperty(prefix+"lym_dbg_path", this.lym_dbg_path +"");
properties.setProperty(prefix+"lym_update_disp", this.lym_update_disp+""); properties.setProperty(prefix+"lym_update_disp", this.lym_update_disp+"");
properties.setProperty(prefix+"lym_iter", this.lym_iter+""); properties.setProperty(prefix+"lym_iter", this.lym_iter+"");
properties.setProperty(prefix+"lym_change", this.lym_change +""); properties.setProperty(prefix+"lym_change", this.lym_change +"");
...@@ -1997,6 +2002,7 @@ public class CLTParameters { ...@@ -1997,6 +2002,7 @@ public class CLTParameters {
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_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+"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_overexp")!=null) this.lym_overexp=Double.parseDouble(properties.getProperty(prefix+"lym_overexp"));
if (properties.getProperty(prefix+"lym_dbg_path")!=null) this.lym_dbg_path= (String) properties.getProperty(prefix+"lym_dbg_path");
if (properties.getProperty(prefix+"lym_update_disp")!=null) this.lym_update_disp=Boolean.parseBoolean(properties.getProperty(prefix+"lym_update_disp")); if (properties.getProperty(prefix+"lym_update_disp")!=null) this.lym_update_disp=Boolean.parseBoolean(properties.getProperty(prefix+"lym_update_disp"));
if (properties.getProperty(prefix+"lym_iter")!=null) this.lym_iter=Integer.parseInt(properties.getProperty(prefix+"lym_iter")); if (properties.getProperty(prefix+"lym_iter")!=null) this.lym_iter=Integer.parseInt(properties.getProperty(prefix+"lym_iter"));
if (properties.getProperty(prefix+"lym_change")!=null) this.lym_change=Double.parseDouble(properties.getProperty(prefix+"lym_change")); if (properties.getProperty(prefix+"lym_change")!=null) this.lym_change=Double.parseDouble(properties.getProperty(prefix+"lym_change"));
...@@ -2895,6 +2901,8 @@ public class CLTParameters { ...@@ -2895,6 +2901,8 @@ public class CLTParameters {
"Full allowed mismatch is a sum of absolute and disparity times relative (relaxed when ground truth is available)"); "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,8,""); gd.addNumericField("Reduce weight of higher disparity tiles", this.ly_norm_disp, 5,8,"");
gd.addMessage ("--- Lazy eye multi-step fitting ---"); gd.addMessage ("--- Lazy eye multi-step fitting ---");
gd.addStringField ("Read extrinsics_bgnd_combo instead of building it", this.lym_dbg_path, 80);
gd.addNumericField("Any (near) saturated pixels - discard tile (see sat_level also)", this.lym_overexp, 10,12,""); gd.addNumericField("Any (near) saturated pixels - discard tile (see sat_level also)", this.lym_overexp, 10,12,"");
gd.addCheckbox ("Update target disparity after each step", this.lym_update_disp); gd.addCheckbox ("Update target disparity after each step", this.lym_update_disp);
gd.addNumericField("Maximal number of iterations", this.lym_iter, 0); gd.addNumericField("Maximal number of iterations", this.lym_iter, 0);
...@@ -3833,6 +3841,8 @@ public class CLTParameters { ...@@ -3833,6 +3841,8 @@ public class CLTParameters {
this.ly_disp_var_gt= gd.getNextNumber(); this.ly_disp_var_gt= gd.getNextNumber();
this.ly_disp_rvar_gt= gd.getNextNumber(); this.ly_disp_rvar_gt= gd.getNextNumber();
this.ly_norm_disp= gd.getNextNumber(); this.ly_norm_disp= gd.getNextNumber();
this.lym_dbg_path = gd.getNextString();
this.lym_overexp= gd.getNextNumber(); this.lym_overexp= gd.getNextNumber();
this.lym_update_disp= gd.getNextBoolean(); this.lym_update_disp= gd.getNextBoolean();
this.lym_iter= (int) gd.getNextNumber(); this.lym_iter= (int) gd.getNextNumber();
......
...@@ -902,8 +902,10 @@ public class CLTPass3d{ ...@@ -902,8 +902,10 @@ public class CLTPass3d{
*/ */
public void updateDisparity() public void updateDisparity()
{ {
if (disparity_map != null) {
setTileOpDisparity(null, getDisparity(0)); setTileOpDisparity(null, getDisparity(0));
} }
}
public double [] getSecondMaxDiff ( public double [] getSecondMaxDiff (
......
...@@ -1101,8 +1101,12 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1101,8 +1101,12 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
} }
if (par_list.size() < par_mask.length) { if (par_list.size() < par_mask.length) {
int[] sub_pars = par_list.stream().mapToInt(i -> i).toArray(); // Java8 int[] sub_pars = new int [par_list.size()];
from_sym = from_sym.getMatrix(0, par_mask.length,sub_pars); // remove masked columns for (int i = 0; i < sub_pars.length; i++) {
sub_pars[i] = par_list.get(i);
}
// int[] sub_pars = par_list.stream().mapToInt(i -> i).toArray(); // Java8
from_sym = from_sym.getMatrix(0, par_mask.length-1,sub_pars); // remove masked columns
} }
} }
Matrix pcd = new Matrix (port_coord_deriv); // rows: px0,py0,... px[n-1], py[n-1], columns: tar Matrix pcd = new Matrix (port_coord_deriv); // rows: px0,py0,... px[n-1], py[n-1], columns: tar
...@@ -1187,7 +1191,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1187,7 +1191,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
if (par_list.size() < par_mask.length) { if (par_list.size() < par_mask.length) {
int[] sub_pars = par_list.stream().mapToInt(i -> i).toArray(); // Java8 int[] sub_pars = par_list.stream().mapToInt(i -> i).toArray(); // Java8
to_sym = to_sym.getMatrix(sub_pars, 0, par_mask.length); // remove masked rows to_sym = to_sym.getMatrix(sub_pars, 0, par_mask.length-1); // remove masked rows
} }
} }
Matrix tar = new Matrix(tar_array,tar_array.length); Matrix tar = new Matrix(tar_array,tar_array.length);
...@@ -1209,7 +1213,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1209,7 +1213,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
if (par_list.size() < par_mask.length) { if (par_list.size() < par_mask.length) {
int[] sub_pars = par_list.stream().mapToInt(i -> i).toArray(); // Java8 int[] sub_pars = par_list.stream().mapToInt(i -> i).toArray(); // Java8
from_sym = from_sym.getMatrix(0, par_mask.length,sub_pars); // remove masked columns from_sym = from_sym.getMatrix(0, par_mask.length-1,sub_pars); // remove masked columns
} }
} }
Matrix sym = new Matrix(sym_array,sym_array.length); Matrix sym = new Matrix(sym_array,sym_array.length);
......
...@@ -2806,6 +2806,35 @@ public class GeometryCorrection { ...@@ -2806,6 +2806,35 @@ public class GeometryCorrection {
return jt; return jt;
} }
public double [][] getPortsXYDerivativesNew( // USED in lwir
GeometryCorrection gc_main,
boolean use_rig_offsets,
Matrix [] rots,
Matrix [][] deriv_rots,
double [] py_offset, // array of per-port average pY offset from the center (to correct ERS) or null (for no ERS)
double [] imu, // may be null
double [] xyz, // world XYZ for ERS correction
double px,
double py,
double disparity)
{
// make sure initPrePostMatrices(true) already ran (in constructor). (true) means that minus sign is already incorporated
double [][] pXYNDderiv = new double [2*numSensors][]; // CorrVector.LENGTH][];
getPortsNonDistortedCoordinatesAndDerivativesNew( // USED in lwir
gc_main,
use_rig_offsets,
rots,
deriv_rots,
pXYNDderiv, // if not null, should be double[8][]
py_offset, // // array of per-port average pY offset from the center (to correct ERS) or null (for no ERS)
imu,
xyz,
px,
py,
disparity);
return(new Matrix(pXYNDderiv)).getArray();
}
......
...@@ -4042,6 +4042,28 @@ public class ImageDttCPU { ...@@ -4042,6 +4042,28 @@ public class ImageDttCPU {
disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = ds[0][1]; disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = ds[0][1];
if (debugTile0) { if (debugTile0) {
lma2.printStats(ds,1); lma2.printStats(ds,1);
double [][] ddnd = lma2.getDdNd();
if (ddnd != null) {
double [][] dxy= new double [ddnd.length][2];
for (int i = 0; i < dxy.length; i++) {
dxy[i][0] = ddnd[i][0] * rXY[i][0] - ddnd[i][1] * rXY[i][1];
dxy[i][1] = ddnd[i][0] * rXY[i][1] + ddnd[i][1] * rXY[i][0];
}
System.out.print(" Port: ");
for (int i = 0; i < dxy.length; i++) System.out.print(String.format(" %2d ", i)); System.out.println();
System.out.print("Radial_in = [");
for (int i = 0; i < dxy.length; i++) System.out.print(String.format(" %6.3f,", ddnd[i][0])); System.out.println("]");
System.out.print("Tangent_CW = [");
for (int i = 0; i < dxy.length; i++) System.out.print(String.format(" %6.3f,", ddnd[i][1])); System.out.println("]");
System.out.print("X = [");
for (int i = 0; i < dxy.length; i++) System.out.print(String.format(" %6.3f,", dxy[i][0])); System.out.println("]");
System.out.print("Y = [");
for (int i = 0; i < dxy.length; i++) System.out.print(String.format(" %6.3f,", dxy[i][1])); System.out.println("]");
System.out.println();
}
} }
} }
} }
......
...@@ -103,7 +103,7 @@ public class SymmVector { ...@@ -103,7 +103,7 @@ public class SymmVector {
full_type2, full_type2,
debug_level); debug_level);
rvs.xy = sv.exportXY(); rvs.xy = sv.exportXY();
rvs.rt = sv.exportRT(); rvs.rt = sv.exportRT(); // radius/tangential (out, cw, out, cw
rvs.dir_rt = sv.exportDirRT(); rvs.dir_rt = sv.exportDirRT();
rvs.rots = sv.exportRZ(false); // include common roll rvs.rots = sv.exportRZ(false); // include common roll
rvs.zooms = sv.exportRZ(true); // no common zoom rvs.zooms = sv.exportRZ(true); // no common zoom
...@@ -1153,7 +1153,8 @@ public class SymmVector { ...@@ -1153,7 +1153,8 @@ public class SymmVector {
xy2ta.set( i, 2* i + 1, TILT_SIGN); xy2ta.set( i, 2* i + 1, TILT_SIGN);
xy2ta.set(N-1+i, 2 *i + 0, AZIMUTH_SIGN); xy2ta.set(N-1+i, 2 *i + 0, AZIMUTH_SIGN);
} }
return xy2ta.times(sym2xy); Matrix sym2ta = xy2ta.times(sym2xy);
return sym2ta;
} }
/** /**
...@@ -1195,6 +1196,7 @@ public class SymmVector { ...@@ -1195,6 +1196,7 @@ public class SymmVector {
to_sym.setMatrix(i1,i2-1,i1,i2-1, sym2roll.inverse()); to_sym.setMatrix(i1,i2-1,i1,i2-1, sym2roll.inverse());
to_sym.setMatrix(i2,i3-1,i2,i3-1, sym2zoom.inverse()); to_sym.setMatrix(i2,i3-1,i2,i3-1, sym2zoom.inverse());
to_sym.setMatrix(i3,i4-1,i3,i4-1, sym2ers.inverse()); to_sym.setMatrix(i3,i4-1,i3,i4-1, sym2ers.inverse());
// Matrix dbg = from_sym.times(to_sym);
return new Matrix[] {from_sym,to_sym}; return new Matrix[] {from_sym,to_sym};
} }
//getColumnDimension //getColumnDimension
......
...@@ -9495,6 +9495,12 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9495,6 +9495,12 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Building basic DSI for the AUX camera image set "+quadCLT_main.image_name+ System.out.println("Building basic DSI for the AUX camera image set "+quadCLT_main.image_name+
" using main camera DSI, pass "+(num_adjust_aux+1)+" of "+adjust_aux); " using main camera DSI, pass "+(num_adjust_aux+1)+" of "+adjust_aux);
} }
String dbg_path = clt_parameters.lym_dbg_path; // /home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif
if (dbg_path.length()==0) {
dbg_path = null;
}
// dbg_path = "/home/elphel/lwir16-proc/proc1/results_cuda/25/extrinsics_bgnd_combo.tif";
if (dbg_path == null) {
quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown quadCLT_aux.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path" imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
...@@ -9513,23 +9519,25 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -9513,23 +9519,25 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println("Adjusting AUX camera image set for "+quadCLT_aux.image_name+ System.out.println("Adjusting AUX camera image set for "+quadCLT_aux.image_name+
", pass "+(num_adjust_aux+1)+" of "+adjust_aux); ", pass "+(num_adjust_aux+1)+" of "+adjust_aux);
} }
}
if (quadCLT_aux.ds_from_main == null) { if (quadCLT_aux.ds_from_main == null) {
System.out.println("BUG: quadCLT_aux.ds_from_main should be not null here!"); System.out.println("BUG: quadCLT_aux.ds_from_main should be not null here!");
double inf_min = -1.0; double inf_min = -1.0;
double inf_max = 1.0; double inf_max = 1.0;
if (num_adjust_aux >= (adjust_aux/2)) { if (num_adjust_aux >= (adjust_aux/2)) {
inf_min = -0.2; inf_min = -0.2;
inf_max = 0.05; inf_max = 0.2; // 0.05; Changed for LWIR16
} }
// adjust w/o main camera - maybe will be used in the future // adjust w/o main camera - maybe will be used in the future
boolean ok = quadCLT_aux.extrinsicsCLT( boolean ok = quadCLT_aux.extrinsicsCLT(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
dbg_path,
false, // adjust_poly, false, // adjust_poly,
inf_min, // double inf_min, inf_min, // double inf_min,
inf_max, // double inf_max, inf_max, // double inf_max,
threadsMax, //final int threadsMax, // maximal number of threads to launch threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus, updateStatus,// final boolean updateStatus,
debugLevelInner); // final int debugLevel) 1); // debugLevelInner); // final int debugLevel)
if (!ok) break; if (!ok) break;
} else { } else {
boolean ok = quadCLT_aux.extrinsicsCLTfromGT( boolean ok = quadCLT_aux.extrinsicsCLTfromGT(
......
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