Commit f6e85676 authored by Andrey Filippov's avatar Andrey Filippov

bug fixes

parent 15b80649
...@@ -154,16 +154,7 @@ public class AlignmentCorrection { ...@@ -154,16 +154,7 @@ public class AlignmentCorrection {
} }
} }
/** public double [][] get_dMismatch_dXY()
* Convert transposed jacobian from {d_dx0,d_dy0, ...,d_dy3} to d_mvi (measurement vectors),
* where sum of measurement vectors squared is minimized. Same matrix multiplications
* is applied to each group of 8 columns. last column in each group is only non-zero if
* disparity is known to be 0;
* @param jt transposed Jacobian of 10/9 rows and 8*n columns
* @return converted transposed Jacobian of the same dimensions
*/
double [][] convertJt_mv(
double [][] jt)
{ {
double [][] dMismatch_dXY = { // extra 0.5 is because differences dxi, dyi are already *= 0.5/magic double [][] dMismatch_dXY = { // extra 0.5 is because differences dxi, dyi are already *= 0.5/magic
//x0 y0 x1 y1 x2 y2 x3 y3 //x0 y0 x1 y1 x2 y2 x3 y3
...@@ -175,6 +166,23 @@ public class AlignmentCorrection { ...@@ -175,6 +166,23 @@ public class AlignmentCorrection {
{ 0.0 , -0.25, 0.0 , -0.25, 0.0 , 0.25, 0.0 , 0.25 }, // mv5 = (dy3 - dy2)/2 = (y3 - y1 - y0 + y2) / 2 { 0.0 , -0.25, 0.0 , -0.25, 0.0 , 0.25, 0.0 , 0.25 }, // mv5 = (dy3 - dy2)/2 = (y3 - y1 - y0 + y2) / 2
{-0.125, 0.125, 0.125, 0.125, -0.125, -0.125, 0.125, -0.125 }, // mv6 = (dx0 + dx1 -dy2 - dy3)/4 = (x1 - x0 + x3 - x2 - y2 + y0 - y3 + y1)/4 {-0.125, 0.125, 0.125, 0.125, -0.125, -0.125, 0.125, -0.125 }, // mv6 = (dx0 + dx1 -dy2 - dy3)/4 = (x1 - x0 + x3 - x2 - y2 + y0 - y3 + y1)/4
{-0.0625, -0.0625, 0.0625,-0.0625,-0.0625, 0.0625, 0.0625, 0.0625}};// mv7 = (dx0 + dx1 +dy2 + dy3)/8= (x1 - x0 + x3 - x2 + y2 - y0 + y3 - y1)/8 {-0.0625, -0.0625, 0.0625,-0.0625,-0.0625, 0.0625, 0.0625, 0.0625}};// mv7 = (dx0 + dx1 +dy2 + dy3)/8= (x1 - x0 + x3 - x2 + y2 - y0 + y3 - y1)/8
return dMismatch_dXY;
}
/**
* Convert transposed jacobian from {d_dx0,d_dy0, ...,d_dy3} to d_mvi (measurement vectors),
* where sum of measurement vectors squared is minimized. Same matrix multiplications
* is applied to each group of 8 columns. last column in each group is only non-zero if
* disparity is known to be 0;
* @param jt transposed Jacobian of 10/9 rows and 8*n columns
* @return converted transposed Jacobian of the same dimensions
*/
double [][] convertJt_mv(
double [][] jt)
{
double [][] dMismatch_dXY = get_dMismatch_dXY();
double [][] jt_conv = new double [jt.length][jt[0].length/dMismatch_dXY[0].length*dMismatch_dXY.length]; // now dMismatch_dXY is square double [][] jt_conv = new double [jt.length][jt[0].length/dMismatch_dXY[0].length*dMismatch_dXY.length]; // now dMismatch_dXY is square
// multiplying by transposed dMismatch_dXY // multiplying by transposed dMismatch_dXY
for (int g = 0; g < jt[0].length/dMismatch_dXY[0].length; g++) { for (int g = 0; g < jt[0].length/dMismatch_dXY[0].length; g++) {
...@@ -2092,18 +2100,11 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2092,18 +2100,11 @@ B = |+dy0 -dy1 -2*dy3 |
String [] dbg_titles_tar=GeometryCorrection.CORR_NAMES; String [] dbg_titles_tar=GeometryCorrection.CORR_NAMES;
String [] dbg_titles_sym= {"sym0","sym1","sym2","sym3","sym4","sym5","sroll0","sroll1","sroll2","sroll3"}; String [] dbg_titles_sym= {"sym0","sym1","sym2","sym3","sym4","sym5","sroll0","sroll1","sroll2","sroll3"};
String [] dbg_titles_xy= {"x0","y0","x1","y1","x2","y2","x3","y3"}; String [] dbg_titles_xy= {"x0","y0","x1","y1","x2","y2","x3","y3"};
// String [] dbg_titles_mv= {"dy0","dy1","dx2","dx3","dx1-dx0","dy3-dy2","dh-dv","dhy+dv"};
double [][] dbg_img_deriv = null; // compare derivatives with delta-diffs double [][] dbg_img_deriv = null; // compare derivatives with delta-diffs
// double [][] dbg_xy = null; // jacobian dmv/dsym
// double [][] dbg_mv = null; // jacobian dmv/dsym
double [][] dbg_dxy_dsym = null; // jacobian dxy/dsym double [][] dbg_dxy_dsym = null; // jacobian dxy/dsym
// double [][] dbg_dmv_dsym = null; // jacobian dmv/dsym
if (dbg_images) { if (dbg_images) {
dbg_img_deriv = doubleNaN(dbg_titles_xy.length * dbg_titles_tar.length *2, dbg_length); // compare derivatives with delta-diffs dbg_img_deriv = doubleNaN(dbg_titles_xy.length * dbg_titles_tar.length *2, dbg_length); // compare derivatives with delta-diffs
// dbg_xy = doubleNaN(dbg_titles_xy.length, dbg_length); // jacobian dmv/dsym
// dbg_mv = doubleNaN(dbg_titles_mv.length, dbg_length); // jacobian dmv/dsym
dbg_dxy_dsym = doubleNaN(dbg_titles_xy.length * dbg_titles_sym.length, dbg_length); // jacobian dxy/dsym dbg_dxy_dsym = doubleNaN(dbg_titles_xy.length * dbg_titles_sym.length, dbg_length); // jacobian dxy/dsym
// dbg_dmv_dsym = doubleNaN(dbg_titles_mv.length * dbg_titles_sym.length, dbg_length); // jacobian dmv/dsym
} }
int num_pars = 0; int num_pars = 0;
...@@ -2142,30 +2143,8 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2142,30 +2143,8 @@ B = |+dy0 -dy1 -2*dy3 |
} }
} }
if (debugLevel > 0){ if (debugLevel > 0){
// double [][] j_partial_debug = new double [2 * NUM_SENSORS][];
double [][] deriv_dbg = new double [2 * NUM_SENSORS][]; double [][] deriv_dbg = new double [2 * NUM_SENSORS][];
double [] dbg_a_vector= null; double [] dbg_a_vector= null;
/*
double [] dbg_a_vector= {
0.0038591302038724394,
-0.08463081841166764,
0.06130822266181911,
-0.036393168371534744,
0.025155872946661495,
0.0,
0.0
};
double [] dbg_a_vector= {
0.5, // 0.0038591302038724394, // 0.0, //
0.0, // -0.08463081841166764,
0.0, // 0.06130822266181911,
0.0, // -0.036393168371534744,
0.0, // 0.025155872946661495,
0.0,
0.0
};
*/
geometryCorrection.getPortsCoordinatesAndDerivatives( geometryCorrection.getPortsCoordinatesAndDerivatives(
dbg_a_vector, // double [] dbg_a_vector, // replace actual radial distortion coefficients dbg_a_vector, // double [] dbg_a_vector, // replace actual radial distortion coefficients
1E-8, //6, // double delta, // 1e-6 1E-8, //6, // double delta, // 1e-6
...@@ -2224,8 +2203,6 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2224,8 +2203,6 @@ B = |+dy0 -dy1 -2*dy3 |
dbg_img_deriv_titles[2 * (i * dbg_titles_tar.length + j) + 1]= dbg_titles_xy[i] + "_" +dbg_titles_tar[j] + "delta"; dbg_img_deriv_titles[2 * (i * dbg_titles_tar.length + j) + 1]= dbg_titles_xy[i] + "_" +dbg_titles_tar[j] + "delta";
} }
} }
// dbg_xy = new double [dbg_titles_xy.length] [dbg_length]; // jacobian dmv/dsym
// dbg_mv = new double [dbg_titles_mv.length] [dbg_length]; // jacobian dmv/dsym
String [] dbg_dxy_dsym_titles = new String [dbg_titles_xy.length * dbg_titles_sym.length]; String [] dbg_dxy_dsym_titles = new String [dbg_titles_xy.length * dbg_titles_sym.length];
for (int i = 0; i < dbg_titles_xy.length; i++){ for (int i = 0; i < dbg_titles_xy.length; i++){
...@@ -2233,29 +2210,103 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2233,29 +2210,103 @@ B = |+dy0 -dy1 -2*dy3 |
dbg_dxy_dsym_titles[i * dbg_titles_sym.length + j]= dbg_titles_xy[i] + "_" +dbg_titles_sym[j]; dbg_dxy_dsym_titles[i * dbg_titles_sym.length + j]= dbg_titles_xy[i] + "_" +dbg_titles_sym[j];
} }
} }
// String [] dmv_dmv_dsym_titles = new String [dbg_titles_mv.length * dbg_titles_sym.length];
// for (int i = 0; i < dbg_titles_mv.length; i++){
// for (int j = 0; j < dbg_titles_sym.length; j++){
// dmv_dmv_dsym_titles[i * dbg_titles_sym.length + j]= dbg_titles_mv[i] + "_" +dbg_titles_sym[j];
// }
// }
dbgImgRemoveEmpty(dbg_img_deriv); dbgImgRemoveEmpty(dbg_img_deriv);
// dbgImgRemoveEmpty(dbg_xy);
// dbgImgRemoveEmpty(dbg_mv);
dbgImgRemoveEmpty(dbg_dxy_dsym); dbgImgRemoveEmpty(dbg_dxy_dsym);
// dbgImgRemoveEmpty(dbg_dmv_dsym);
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
sdfa_instance.showArrays(dbg_img_deriv, dbg_owidth, dbg_oheight, true, "dbg_img_deriv", dbg_img_deriv_titles); sdfa_instance.showArrays(dbg_img_deriv, dbg_owidth, dbg_oheight, true, "dbg_img_deriv", dbg_img_deriv_titles);
// sdfa_instance.showArrays(dbg_xy, dbg_owidth, dbg_oheight, true, "dbg_xy", dbg_titles_xy);
// sdfa_instance.showArrays(dbg_mv, dbg_owidth, dbg_oheight, true, "dbg_mv", dbg_titles_mv);
sdfa_instance.showArrays(dbg_dxy_dsym, dbg_owidth, dbg_oheight, true, "dbg_dxy_dsym", dbg_dxy_dsym_titles); sdfa_instance.showArrays(dbg_dxy_dsym, dbg_owidth, dbg_oheight, true, "dbg_dxy_dsym", dbg_dxy_dsym_titles);
// sdfa_instance.showArrays(dbg_dmv_dsym, dbg_owidth, dbg_oheight, true, "dbg_dmv_dsym", dmv_dmv_dsym_titles);
} }
return jt; return jt;
} }
double [][] debug_mv_from_sym_jacobian(
double delta,
boolean [] par_mask,
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
int debugLevel)
{
int num_pars = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) num_pars ++;
double [][] jt_mv = new double [num_pars][2 * NUM_SENSORS * mismatch_list.size()];
double [] sym_par_0 = corr_vector.toSymArray(par_mask);
for (int sym_par = 0; sym_par < num_pars; sym_par++ ) {
double [] sym_par_p = sym_par_0.clone();
double [] sym_par_m = sym_par_0.clone();
sym_par_p[sym_par] += 0.5 * delta;
sym_par_m[sym_par] -= 0.5 * delta;
GeometryCorrection.CorrVector corr_p = geometryCorrection.getCorrVector(sym_par_p, par_mask);
GeometryCorrection.CorrVector corr_m = geometryCorrection.getCorrVector(sym_par_m, par_mask);
double [] mv_p = debug_mv_from_sym(
mismatch_list,
geometryCorrection,
corr_p,
debugLevel);
double [] mv_m = debug_mv_from_sym(
mismatch_list,
geometryCorrection,
corr_m,
debugLevel);
for (int i = 0; i < jt_mv[sym_par].length; i++){
jt_mv[sym_par][i] = (mv_p[i]-mv_m[i])/delta;
}
}
return jt_mv;
}
/**
* Debugging jacobian with two coordinate transformations - input and output. Calculating output mv vector
* for all coordinate points for current corr_vector (to use it with delta corr_vecotr)
* @param mismatch_list
* @param geometryCorrection
* @param corr_vector
* @param debugLevel
* @return
*/
double [] debug_mv_from_sym(
// boolean [] par_mask,
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
int debugLevel)
{
double [][] dMismatch_dXY = (new Mismatch()).get_dMismatch_dXY(); // just a static array
double [] mv = new double [2 * NUM_SENSORS * mismatch_list.size()];
for (int indx = 0; indx<mismatch_list.size(); indx++){ // need indx value
Mismatch mm = mismatch_list.get(indx);
double [] pXY = mm.getPXY();
double [][] f = geometryCorrection.getPortsCoordinatesAndDerivatives( // 4x2
corr_vector, // CorrVector corr_vector,
null, // boolean calc_deriv,
pXY[0], // double px,
pXY[1], // double py,
mm.getDisparityMeas()); // getDisparityTask()); // double disparity)
// convert to symmetrical coordianets
// f is [4][2] array of port x,y coordinates - convert them to mv (linear array)
double [] mv_partial = new double [dMismatch_dXY.length];
for (int i = 0; i < mv_partial.length; i++){
for (int nsens = 0; nsens < NUM_SENSORS; nsens++){
for (int dir = 0; dir <2; dir++){
mv_partial[i]+=f[nsens][dir]* dMismatch_dXY[i][2*nsens+dir];
}
}
}
for (int n = 0; n < 2* NUM_SENSORS; n++){
mv[2 * NUM_SENSORS * indx + n] = mv_partial[n];
}
}
return mv;
}
public int dbg_index(double [] pXY, int decimate) public int dbg_index(double [] pXY, int decimate)
{ {
int width = qc.tp.getTilesX()*qc.tp.getTileSize()/decimate; int width = qc.tp.getTilesX()*qc.tp.getTileSize()/decimate;
...@@ -2398,6 +2449,9 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2398,6 +2449,9 @@ B = |+dy0 -dy1 -2*dy3 |
double [][] jta_mv = (new Mismatch()).convertJt_mv (jta); //double [][] jt) double [][] jta_mv = (new Mismatch()).convertJt_mv (jta); //double [][] jt)
Matrix jt = new Matrix(jta_mv); Matrix jt = new Matrix(jta_mv);
double [] y_minus_fx_a = getYminusFx( // mv[0]..mv[7], not the measured data (dx0, dy0, ... dx3, dy3) double [] y_minus_fx_a = getYminusFx( // mv[0]..mv[7], not the measured data (dx0, dy0, ... dx3, dy3)
mismatch_list); // ArrayList<Mismatch> mismatch_list) mismatch_list); // ArrayList<Mismatch> mismatch_list)
...@@ -2427,10 +2481,22 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2427,10 +2481,22 @@ B = |+dy0 -dy1 -2*dy3 |
double [][] dbg_xy = null; // jacobian dmv/dsym double [][] dbg_xy = null; // jacobian dmv/dsym
double [][] dbg_mv = null; // jacobian dmv/dsym double [][] dbg_mv = null; // jacobian dmv/dsym
double [][] dbg_dmv_dsym = null; // jacobian dmv/dsym double [][] dbg_dmv_dsym = null; // jacobian dmv/dsym
double [][] dbg_dmv_dsym_delta = null; // jacobian dmv/dsym
double [][] dbg_dmv_dsym_diff = null; // jacobian dmv/dsym
if (dbg_images) { if (dbg_images) {
double [][] jta_mv_delta = debug_mv_from_sym_jacobian(
1e-9, // 6, // double delta,
par_mask, // boolean [] par_mask,
mismatch_list, // ArrayList<Mismatch> mismatch_list,
geometryCorrection, // GeometryCorrection geometryCorrection,
corr_vector, // GeometryCorrection.CorrVector corr_vector)
debugLevel); // int debugLevel)
dbg_xy = doubleNaN(dbg_titles_xy.length, dbg_length); // jacobian dmv/dsym dbg_xy = doubleNaN(dbg_titles_xy.length, dbg_length); // jacobian dmv/dsym
dbg_mv = doubleNaN(dbg_titles_mv.length, dbg_length); // jacobian dmv/dsym dbg_mv = doubleNaN(dbg_titles_mv.length, dbg_length); // jacobian dmv/dsym
dbg_dmv_dsym = doubleNaN(dbg_titles_mv.length * dbg_titles_sym.length, dbg_length); // jacobian dmv/dsym dbg_dmv_dsym = doubleNaN(dbg_titles_mv.length * dbg_titles_sym.length, dbg_length); // jacobian dmv/dsym
dbg_dmv_dsym_delta = doubleNaN(dbg_titles_mv.length * dbg_titles_sym.length, dbg_length); // jacobian dmv/dsym
dbg_dmv_dsym_diff = doubleNaN(dbg_titles_mv.length * dbg_titles_sym.length, dbg_length); // jacobian dmv/dsym
// dbg_xy = new double [dbg_titles_xy.length] [dbg_length]; // jacobian dmv/dsym // dbg_xy = new double [dbg_titles_xy.length] [dbg_length]; // jacobian dmv/dsym
// dbg_mv = new double [dbg_titles_mv.length] [dbg_length]; // jacobian dmv/dsym // dbg_mv = new double [dbg_titles_mv.length] [dbg_length]; // jacobian dmv/dsym
...@@ -2464,6 +2530,8 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2464,6 +2530,8 @@ B = |+dy0 -dy1 -2*dy3 |
System.out.println("solveCorr(): dbg_dmv_dsym.length="+dbg_dmv_dsym.length+ ", dbg_dmv_dsym[0].length="+dbg_dmv_dsym[0].length); System.out.println("solveCorr(): dbg_dmv_dsym.length="+dbg_dmv_dsym.length+ ", dbg_dmv_dsym[0].length="+dbg_dmv_dsym[0].length);
} }
dbg_dmv_dsym[i * dbg_titles_sym.length + j][dbg_index] = jta_mv [oj][dbg_titles_mv.length * indx + i]; //java.lang.ArrayIndexOutOfBoundsException: 3552 dbg_dmv_dsym[i * dbg_titles_sym.length + j][dbg_index] = jta_mv [oj][dbg_titles_mv.length * indx + i]; //java.lang.ArrayIndexOutOfBoundsException: 3552
dbg_dmv_dsym_delta[i * dbg_titles_sym.length + j][dbg_index] = jta_mv_delta [oj][dbg_titles_mv.length * indx + i];
dbg_dmv_dsym_diff[i * dbg_titles_sym.length + j][dbg_index] = jta_mv_delta [oj][dbg_titles_mv.length * indx + i] - jta_mv [oj][dbg_titles_mv.length * indx + i];
oj++; oj++;
} }
} }
...@@ -2472,11 +2540,15 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2472,11 +2540,15 @@ B = |+dy0 -dy1 -2*dy3 |
dbgImgRemoveEmpty(dbg_xy); dbgImgRemoveEmpty(dbg_xy);
dbgImgRemoveEmpty(dbg_xy); dbgImgRemoveEmpty(dbg_xy);
dbgImgRemoveEmpty(dbg_dmv_dsym); dbgImgRemoveEmpty(dbg_dmv_dsym);
dbgImgRemoveEmpty(dbg_dmv_dsym_delta);
dbgImgRemoveEmpty(dbg_dmv_dsym_diff);
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
sdfa_instance.showArrays(dbg_xy, dbg_owidth, dbg_oheight, true, "dbg_xy", dbg_titles_xy); sdfa_instance.showArrays(dbg_xy, dbg_owidth, dbg_oheight, true, "dbg_xy", dbg_titles_xy);
sdfa_instance.showArrays(dbg_mv, dbg_owidth, dbg_oheight, true, "dbg_mv", dbg_titles_mv); sdfa_instance.showArrays(dbg_mv, dbg_owidth, dbg_oheight, true, "dbg_mv", dbg_titles_mv);
sdfa_instance.showArrays(dbg_dmv_dsym, dbg_owidth, dbg_oheight, true, "dbg_dmv_dsym", dbg_dmv_dsym_titles); sdfa_instance.showArrays(dbg_dmv_dsym, dbg_owidth, dbg_oheight, true, "dbg_dmv_dsym", dbg_dmv_dsym_titles);
sdfa_instance.showArrays(dbg_dmv_dsym_delta, dbg_owidth, dbg_oheight, true, "delta_dmv_dsym",dbg_dmv_dsym_titles);
sdfa_instance.showArrays(dbg_dmv_dsym_diff, dbg_owidth, dbg_oheight, true, "diff_dmv_dsym", dbg_dmv_dsym_titles);
} }
if (debugLevel>-1) { if (debugLevel>-1) {
jtj.print(18, 6); jtj.print(18, 6);
......
...@@ -2140,6 +2140,7 @@ public class EyesisCorrectionParameters { ...@@ -2140,6 +2140,7 @@ public class EyesisCorrectionParameters {
public boolean avg_cluster_disp = false; // Weight-average disparity for the whole cluster public boolean avg_cluster_disp = false; // Weight-average disparity for the whole cluster
public double maxDispTriangle = 0.2; // Maximal relative disparity difference in a triangle face public double maxDispTriangle = 0.2; // Maximal relative disparity difference in a triangle face
public double infinityDistance = 10000; // Distance to generate backdrop (0 - use regular backdrop) public double infinityDistance = 10000; // Distance to generate backdrop (0 - use regular backdrop)
public int min_bgnd_tiles = 10; // Minimal number of background tiles to generate background
public boolean shUseFlaps = true; // Split into shells with flaps public boolean shUseFlaps = true; // Split into shells with flaps
public boolean shAggrFade = true; // Aggressive fade alpha (whole boundary) public boolean shAggrFade = true; // Aggressive fade alpha (whole boundary)
public int shMinArea = 1; // Minimal shell area (not counting flaps public int shMinArea = 1; // Minimal shell area (not counting flaps
...@@ -2758,6 +2759,7 @@ public class EyesisCorrectionParameters { ...@@ -2758,6 +2759,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"avg_cluster_disp", this.avg_cluster_disp+""); properties.setProperty(prefix+"avg_cluster_disp", this.avg_cluster_disp+"");
properties.setProperty(prefix+"maxDispTriangle", this.maxDispTriangle +""); properties.setProperty(prefix+"maxDispTriangle", this.maxDispTriangle +"");
properties.setProperty(prefix+"infinityDistance", this.infinityDistance +""); properties.setProperty(prefix+"infinityDistance", this.infinityDistance +"");
properties.setProperty(prefix+"min_bgnd_tiles", this.min_bgnd_tiles+"");
properties.setProperty(prefix+"shUseFlaps", this.shUseFlaps+""); properties.setProperty(prefix+"shUseFlaps", this.shUseFlaps+"");
properties.setProperty(prefix+"shAggrFade", this.shAggrFade+""); properties.setProperty(prefix+"shAggrFade", this.shAggrFade+"");
properties.setProperty(prefix+"shMinArea", this.shMinArea+""); properties.setProperty(prefix+"shMinArea", this.shMinArea+"");
...@@ -3335,6 +3337,7 @@ public class EyesisCorrectionParameters { ...@@ -3335,6 +3337,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"avg_cluster_disp")!=null) this.avg_cluster_disp=Boolean.parseBoolean(properties.getProperty(prefix+"avg_cluster_disp")); if (properties.getProperty(prefix+"avg_cluster_disp")!=null) this.avg_cluster_disp=Boolean.parseBoolean(properties.getProperty(prefix+"avg_cluster_disp"));
if (properties.getProperty(prefix+"maxDispTriangle")!=null) this.maxDispTriangle=Double.parseDouble(properties.getProperty(prefix+"maxDispTriangle")); if (properties.getProperty(prefix+"maxDispTriangle")!=null) this.maxDispTriangle=Double.parseDouble(properties.getProperty(prefix+"maxDispTriangle"));
if (properties.getProperty(prefix+"infinityDistance")!=null) this.infinityDistance=Double.parseDouble(properties.getProperty(prefix+"infinityDistance")); if (properties.getProperty(prefix+"infinityDistance")!=null) this.infinityDistance=Double.parseDouble(properties.getProperty(prefix+"infinityDistance"));
if (properties.getProperty(prefix+"min_bgnd_tiles")!=null) this.min_bgnd_tiles=Integer.parseInt(properties.getProperty(prefix+"min_bgnd_tiles"));
if (properties.getProperty(prefix+"shUseFlaps")!=null) this.shUseFlaps=Boolean.parseBoolean(properties.getProperty(prefix+"shUseFlaps")); if (properties.getProperty(prefix+"shUseFlaps")!=null) this.shUseFlaps=Boolean.parseBoolean(properties.getProperty(prefix+"shUseFlaps"));
if (properties.getProperty(prefix+"shAggrFade")!=null) this.shAggrFade=Boolean.parseBoolean(properties.getProperty(prefix+"shAggrFade")); if (properties.getProperty(prefix+"shAggrFade")!=null) this.shAggrFade=Boolean.parseBoolean(properties.getProperty(prefix+"shAggrFade"));
if (properties.getProperty(prefix+"shMinArea")!=null) this.shMinArea=Integer.parseInt(properties.getProperty(prefix+"shMinArea")); if (properties.getProperty(prefix+"shMinArea")!=null) this.shMinArea=Integer.parseInt(properties.getProperty(prefix+"shMinArea"));
...@@ -3809,7 +3812,7 @@ public class EyesisCorrectionParameters { ...@@ -3809,7 +3812,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("X 3", this.fine_corr_x_3, 3); gd.addNumericField("X 3", this.fine_corr_x_3, 3);
gd.addNumericField("Y 4", this.fine_corr_y_3, 3); gd.addNumericField("Y 4", this.fine_corr_y_3, 3);
gd.addNumericField("Y 4", this.fcorr_radius, 3); gd.addNumericField("fcorr_radius", this.fcorr_radius, 3);
gd.addNumericField("Do not try to correct outside this fraction of width/hight", this.fcorr_min_strength,3); gd.addNumericField("Do not try to correct outside this fraction of width/hight", this.fcorr_min_strength,3);
gd.addNumericField("Consider only tiles with absolute residual disparity lower than", this.fcorr_disp_diff, 3); gd.addNumericField("Consider only tiles with absolute residual disparity lower than", this.fcorr_disp_diff, 3);
gd.addCheckbox ("Use quadratic polynomial for fine correction (false - only linear)", this.fcorr_quadratic); gd.addCheckbox ("Use quadratic polynomial for fine correction (false - only linear)", this.fcorr_quadratic);
...@@ -3940,6 +3943,7 @@ public class EyesisCorrectionParameters { ...@@ -3940,6 +3943,7 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Weight-average disparity for the whole cluster ", this.avg_cluster_disp); gd.addCheckbox ("Weight-average disparity for the whole cluster ", this.avg_cluster_disp);
gd.addNumericField("Maximal disparity difference in a triangle face to show", this.maxDispTriangle, 6); gd.addNumericField("Maximal disparity difference in a triangle face to show", this.maxDispTriangle, 6);
gd.addNumericField("Distance to generate backdrop (0 - use regular backdrop)", this.infinityDistance, 8); gd.addNumericField("Distance to generate backdrop (0 - use regular backdrop)", this.infinityDistance, 8);
gd.addNumericField(" Minimal number of background tiles to generate background", this.min_bgnd_tiles, 0);
gd.addCheckbox ("Split into shells with flaps", this.shUseFlaps); gd.addCheckbox ("Split into shells with flaps", this.shUseFlaps);
gd.addCheckbox ("Aggressive fade alpha (whole boundary)", this.shAggrFade); gd.addCheckbox ("Aggressive fade alpha (whole boundary)", this.shAggrFade);
...@@ -4549,6 +4553,7 @@ public class EyesisCorrectionParameters { ...@@ -4549,6 +4553,7 @@ public class EyesisCorrectionParameters {
this.avg_cluster_disp= gd.getNextBoolean(); this.avg_cluster_disp= gd.getNextBoolean();
this.maxDispTriangle= gd.getNextNumber(); this.maxDispTriangle= gd.getNextNumber();
this.infinityDistance= gd.getNextNumber(); this.infinityDistance= gd.getNextNumber();
this.min_bgnd_tiles= (int) gd.getNextNumber();
this.shUseFlaps= gd.getNextBoolean(); this.shUseFlaps= gd.getNextBoolean();
this.shAggrFade= gd.getNextBoolean(); this.shAggrFade= gd.getNextBoolean();
this.shMinArea= (int) gd.getNextNumber(); this.shMinArea= (int) gd.getNextNumber();
......
...@@ -501,7 +501,7 @@ private Panel panel1, ...@@ -501,7 +501,7 @@ private Panel panel1,
addButton("CLT process files", panelClt1, color_process); addButton("CLT process files", panelClt1, color_process);
addButton("CLT process sets", panelClt1, color_process); addButton("CLT process sets", panelClt1, color_process);
addButton("CLT process quads", panelClt1, color_process); addButton("CLT process quads", panelClt1, color_process);
// addButton("CLT process corr", panelClt1, color_conf_process); // addButton("CLT 4 images", panelClt1, color_conf_process);
// addButton("CLT disparity scan", panelClt1, color_conf_process); // addButton("CLT disparity scan", panelClt1, color_conf_process);
// addButton("CLT reset fine corr", panelClt1, color_stop); // addButton("CLT reset fine corr", panelClt1, color_stop);
// addButton("CLT show fine corr", panelClt1, color_configure); // addButton("CLT show fine corr", panelClt1, color_configure);
...@@ -528,7 +528,7 @@ private Panel panel1, ...@@ -528,7 +528,7 @@ private Panel panel1,
// addButton("CLT process files", panelClt2, color_process); // addButton("CLT process files", panelClt2, color_process);
// addButton("CLT process sets", panelClt2, color_process); // addButton("CLT process sets", panelClt2, color_process);
// addButton("CLT process quads", panelClt2, color_process); // addButton("CLT process quads", panelClt2, color_process);
addButton("CLT process corr", panelClt2, color_conf_process); addButton("CLT 4 images", panelClt2, color_conf_process);
addButton("CLT disparity scan", panelClt2, color_conf_process); addButton("CLT disparity scan", panelClt2, color_conf_process);
addButton("CLT reset fine corr", panelClt2, color_stop); addButton("CLT reset fine corr", panelClt2, color_stop);
addButton("CLT reset extrinsic corr", panelClt2, color_stop); addButton("CLT reset extrinsic corr", panelClt2, color_stop);
...@@ -4475,7 +4475,7 @@ private Panel panel1, ...@@ -4475,7 +4475,7 @@ private Panel panel1,
return; return;
} else if (label.equals("CLT process corr") || label.equals("CLT apply fine corr") || label.equals("CLT infinity corr")) { } else if (label.equals("CLT 4 images") || label.equals("CLT apply fine corr") || label.equals("CLT infinity corr")) {
boolean apply_corr = label.equals("CLT apply fine corr"); boolean apply_corr = label.equals("CLT apply fine corr");
boolean infinity_corr = label.equals("CLT infinity corr"); boolean infinity_corr = label.equals("CLT infinity corr");
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
......
...@@ -5166,7 +5166,7 @@ public class QuadCLT { ...@@ -5166,7 +5166,7 @@ public class QuadCLT {
// } // }
bgnd_data.texture = imp_bgnd.getTitle()+ (clt_parameters.black_back? ".jpeg" : ".png"); bgnd_data.texture = (imp_bgnd == null)? null: ( imp_bgnd.getTitle()+ (clt_parameters.black_back? ".jpeg" : ".png"));
// create x3d file // create x3d file
X3dOutput x3dOutput = new X3dOutput( X3dOutput x3dOutput = new X3dOutput(
...@@ -5176,10 +5176,11 @@ public class QuadCLT { ...@@ -5176,10 +5176,11 @@ public class QuadCLT {
tp.clt_3d_passes); tp.clt_3d_passes);
x3dOutput.generateBackground(clt_parameters.infinityDistance <= 0.0); // needs just first (background) scan x3dOutput.generateBackground(clt_parameters.infinityDistance <= 0.0); // needs just first (background) scan
/*
String x3d_path= correctionsParameters.selectX3dDirectory( String x3d_path= correctionsParameters.selectX3dDirectory(
true, // smart, true, // smart,
true); //newAllowed, // save true); //newAllowed, // save
*/
// refine first measurement // refine first measurement
int bg_pass = tp.clt_3d_passes.size() - 1; // 0 int bg_pass = tp.clt_3d_passes.size() - 1; // 0
int refine_pass = tp.clt_3d_passes.size(); // 1 int refine_pass = tp.clt_3d_passes.size(); // 1
...@@ -6182,14 +6183,6 @@ public class QuadCLT { ...@@ -6182,14 +6183,6 @@ public class QuadCLT {
tp.clt_3d_passes.add(latest_scan); // put it back tp.clt_3d_passes.add(latest_scan); // put it back
} }
int next_pass = tp.clt_3d_passes.size(); // int next_pass = tp.clt_3d_passes.size(); //
// tp.showScan(
// tp.clt_3d_passes.get(0), // CLTPass3d scan,
// "bg_scan"); //String title)
// tp.showScan(
// tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
// "after_pass2-"+(next_pass-1)); //String title)
// tp.thirdPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
tp.thirdPassSetupSurf( // prepare tile tasks for the second pass based on the previous one(s) // needs last scan tp.thirdPassSetupSurf( // prepare tile tasks for the second pass based on the previous one(s) // needs last scan
clt_parameters, clt_parameters,
clt_parameters.bgnd_range, // double disparity_far, clt_parameters.bgnd_range, // double disparity_far,
...@@ -6233,31 +6226,30 @@ public class QuadCLT { ...@@ -6233,31 +6226,30 @@ public class QuadCLT {
x3dOutput.generateBackground(clt_parameters.infinityDistance <= 0.0); // needs just first (background) scan x3dOutput.generateBackground(clt_parameters.infinityDistance <= 0.0); // needs just first (background) scan
} }
int bgndIndex = 0; // it already exists?
CLTPass3d bgndScan = tp.clt_3d_passes.get(bgndIndex);
// boolean [] bgnd_sel = bgndScan.getSelected().clone();
// int num_bgnd = 0;
// for (int i = 0; i < bgnd_sel.length; i++) if (bgnd_sel[i]) num_bgnd++;
// if (num_bgnd >= clt_parameters.min_bgnd_tiles) { // TODO: same for the backdrop too
if (bgndScan.texture != null) { // TODO: same for the backdrop too
if (clt_parameters.infinityDistance > 0.0){ // generate background as a billboard if (clt_parameters.infinityDistance > 0.0){ // generate background as a billboard
// tp.showScan(
// tp.clt_3d_passes.get(0), // CLTPass3d scan,
// "bg_scan_inf"); //String title)
double infinity_disparity = geometryCorrection.getDisparityFromZ(clt_parameters.infinityDistance); double infinity_disparity = geometryCorrection.getDisparityFromZ(clt_parameters.infinityDistance);
int scanIndex = 0; // it already exists?
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
// grow selection, then grow once more and create border_tiles // grow selection, then grow once more and create border_tiles
// create/rstore, probably not needed // create/rstore, probably not needed
boolean [] bg_sel_backup = scan.getSelected().clone(); boolean [] bg_sel_backup = bgndScan.getSelected().clone();
boolean [] bg_border_backup = (scan.getBorderTiles() == null) ? null: scan.getBorderTiles().clone(); boolean [] bg_border_backup = (bgndScan.getBorderTiles() == null) ? null: bgndScan.getBorderTiles().clone();
boolean [] bg_selected = scan.getSelected(); boolean [] bg_selected = bgndScan.getSelected();
// tp.growTiles( // tp.growTiles(
// 2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more // 2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
// bg_selected, // bg_selected,
// null); // prohibit // null); // prohibit
boolean [] border_tiles = bg_selected.clone(); boolean [] border_tiles = bg_selected.clone();
tp.growTiles( tp.growTiles(
2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more 2, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
bg_selected, bg_selected,
null); // prohibit null); // prohibit
// for (int) // for (int)
for (int i = 0; i < border_tiles.length; i++){ for (int i = 0; i < border_tiles.length; i++){
border_tiles[i] = !border_tiles[i] && bg_selected[i]; border_tiles[i] = !border_tiles[i] && bg_selected[i];
...@@ -6266,19 +6258,19 @@ public class QuadCLT { ...@@ -6266,19 +6258,19 @@ public class QuadCLT {
for (int ty = 0; ty < tilesY; ty++){ for (int ty = 0; ty < tilesY; ty++){
for (int tx = 0; tx < tilesX; tx++){ for (int tx = 0; tx < tilesX; tx++){
if (!bg_selected[tx + tilesX*ty]){ if (!bg_selected[tx + tilesX*ty]){
scan.texture_tiles[ty][tx] = null; bgndScan.texture_tiles[ty][tx] = null;
} }
} }
} }
scan.setBorderTiles(border_tiles); bgndScan.setBorderTiles(border_tiles);
// updates selection from non-null texture tiles // updates selection from non-null texture tiles
String texturePath = getPassImage( // get image from a single pass String texturePath = getPassImage( // get image from a single pass
clt_parameters, clt_parameters,
colorProcParameters, colorProcParameters,
rgbParameters, rgbParameters,
this.image_name+"-img_infinity", // +scanIndex, this.image_name+"-img_infinity", // +scanIndex,
scanIndex, bgndIndex,
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
debugLevel); debugLevel);
...@@ -6288,9 +6280,9 @@ public class QuadCLT { ...@@ -6288,9 +6280,9 @@ public class QuadCLT {
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 ++){
scan_disparity[indx++] = infinity_disparity; scan_disparity[indx++] = infinity_disparity;
} }
// tp.showScan( // tp.showScan(
// scan, // CLTPass3d scan, // scan, // CLTPass3d scan,
// "infinityDistance"); // "infinityDistance");
boolean showTri = false; // ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||((scanIndex - next_pass) == 73); boolean showTri = false; // ((scanIndex < next_pass + 1) && clt_parameters.show_triangles) ||((scanIndex - next_pass) == 73);
try { try {
...@@ -6300,8 +6292,8 @@ public class QuadCLT { ...@@ -6300,8 +6292,8 @@ public class QuadCLT {
texturePath, texturePath,
"INFINITY", // id (scanIndex - next_pass), // id "INFINITY", // id (scanIndex - next_pass), // id
"INFINITY", // class "INFINITY", // class
scan.getTextureBounds(), bgndScan.getTextureBounds(),
scan.selected, bgndScan.selected,
scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM], scan_disparity, // scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM],
clt_parameters.transform_size, clt_parameters.transform_size,
clt_parameters.correct_distortions, // requires backdrop image to be corrected also clt_parameters.correct_distortions, // requires backdrop image to be corrected also
...@@ -6315,10 +6307,10 @@ public class QuadCLT { ...@@ -6315,10 +6307,10 @@ public class QuadCLT {
return false; return false;
} }
// maybe not needed // maybe not needed
scan.setBorderTiles(bg_border_backup); bgndScan.setBorderTiles(bg_border_backup);
scan.setSelected(bg_sel_backup); bgndScan.setSelected(bg_sel_backup);
}
} }
...@@ -6620,6 +6612,7 @@ public class QuadCLT { ...@@ -6620,6 +6612,7 @@ public class QuadCLT {
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "strict_grown",titles); sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "strict_grown",titles);
} }
int num_bgnd = 0;
double [][][][] texture_tiles_bgnd = new double[tilesY][tilesX][][]; double [][][][] texture_tiles_bgnd = new double[tilesY][tilesX][][];
double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size]; double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size];
int alpha_index = 3; int alpha_index = 3;
...@@ -6632,6 +6625,7 @@ public class QuadCLT { ...@@ -6632,6 +6625,7 @@ public class QuadCLT {
bgnd_tiles_grown2[tileY * tilesX + tileX]) { bgnd_tiles_grown2[tileY * tilesX + tileX]) {
if (bgnd_tiles[tileY * tilesX + tileX]) { if (bgnd_tiles[tileY * tilesX + tileX]) {
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX]; texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX];
num_bgnd++;
}else{ }else{
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone(); texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero; texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero;
...@@ -6647,6 +6641,7 @@ public class QuadCLT { ...@@ -6647,6 +6641,7 @@ public class QuadCLT {
bgnd_tiles[tileY * tilesX + tileX]) { bgnd_tiles[tileY * tilesX + tileX]) {
if (bgnd_tiles_grown2[tileY * tilesX + tileX]) { if (bgnd_tiles_grown2[tileY * tilesX + tileX]) {
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX]; texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX];
num_bgnd++;
}else{ }else{
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone(); texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero; texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero;
...@@ -6656,6 +6651,11 @@ public class QuadCLT { ...@@ -6656,6 +6651,11 @@ public class QuadCLT {
} }
} }
if (num_bgnd < clt_parameters.min_bgnd_tiles){
return null; // no background to generate
}
ImageDtt image_dtt = new ImageDtt(); ImageDtt image_dtt = new ImageDtt();
double [][] texture_overlap = image_dtt.combineRGBATiles( double [][] texture_overlap = image_dtt.combineRGBATiles(
texture_tiles_bgnd, // texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null} texture_tiles_bgnd, // texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
......
...@@ -97,7 +97,7 @@ public class X3dOutput { ...@@ -97,7 +97,7 @@ public class X3dOutput {
Element el_Bgnd = x3dDoc.createElement("Background"); Element el_Bgnd = x3dDoc.createElement("Background");
el_Bgnd.setAttribute("class","Background"); el_Bgnd.setAttribute("class","Background");
el_Bgnd.setAttribute("id", "Background"); el_Bgnd.setAttribute("id", "Background");
if (use_backdrop) { if (use_backdrop && (bgnd_pass.texture != null)) {
el_Bgnd.setAttribute("frontUrl", bgnd_pass.texture); el_Bgnd.setAttribute("frontUrl", bgnd_pass.texture);
// temporarily - add same picture to all other sides. Actually - any square will work, make some // temporarily - add same picture to all other sides. Actually - any square will work, make some
// perspective grids/ colors to simplify orientation when looking wrong way // perspective grids/ colors to simplify orientation when looking wrong way
......
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