Commit f204d4a8 authored by Andrey Filippov's avatar Andrey Filippov

Improved rig infinity calibration, minor bug fixes

parent a7a1e850
......@@ -38,6 +38,9 @@ public class BiQuadParameters {
public double inf_max_disp_main = 0.15;
public double inf_max_disp_aux = 0.15;
public double inf_max_disp_rig = 0.2; // maybe even higher (2.0) to lock to initially high mismatch
public double inf_weight_disp = 0.3; // all dx < this value have scaled higher weight
public double inf_weight_disp_pow = 1.0; // raise disparity difference to this power for weight
public double inf_neg_tolerance = 2.5; // increase negative disparity for infinity tolerance
public double inf_weight = 0.7; // weight of infinity measurements of all measurements
......@@ -272,6 +275,11 @@ public class BiQuadParameters {
"Do not use tile for infinity adjustment if absolute value of the main camera disparity is too high");
gd.addNumericField("Maximal absolute value of inter-camera disparity to use for infinity rig adjustment", this.inf_max_disp_rig, 3,6,"pix",
"Do not use tile for infinity adjustment if absolute value of the inter-camera disparity is too high");
gd.addNumericField("Infinity disparity offset to increase weight of far pixels", this.inf_weight_disp, 3,6,"pix",
"Increase weights of farther pixels by multiplying strength by (this offset - dx). 0.0 disables this feature");
gd.addNumericField("Weight power for disparity difference", this.inf_weight_disp_pow, 3,6,"",
"Raise (offset - dx) to this power. <=0.0 disables this feature");
gd.addNumericField("Loosen negative disparity tolerance for infinity", this.inf_neg_tolerance, 3,6,"",
"Allow farther negative than positive disparity tiles for infinity (only for main/rig pair)");
gd.addNumericField("Weight of infinity measurements in all measurements", this.inf_weight, 3,6,"",
......@@ -650,6 +658,9 @@ public class BiQuadParameters {
this.inf_max_disp_main= gd.getNextNumber();
this.inf_max_disp_aux= gd.getNextNumber();
this.inf_max_disp_rig= gd.getNextNumber();
this.inf_weight_disp= gd.getNextNumber();
this.inf_weight_disp_pow= gd.getNextNumber();
this.inf_neg_tolerance= gd.getNextNumber();
this.inf_weight= gd.getNextNumber();
this.first_max_disp_main= gd.getNextNumber();
......@@ -843,10 +854,12 @@ public class BiQuadParameters {
properties.setProperty(prefix+"inf_max_disp_main", this.inf_max_disp_main+"");
properties.setProperty(prefix+"inf_max_disp_aux", this.inf_max_disp_aux+"");
properties.setProperty(prefix+"inf_max_disp_rig", this.inf_max_disp_rig+"");
properties.setProperty(prefix+"inf_weight_disp", this.inf_weight_disp+"");
properties.setProperty(prefix+"inf_weight_disp_pow", this.inf_weight_disp_pow+"");
properties.setProperty(prefix+"inf_neg_tolerance", this.inf_neg_tolerance+"");
properties.setProperty(prefix+"inf_weight", this.inf_weight+"");
properties.setProperty(prefix+"first_max_disp_main", this.first_max_disp_main+"");
properties.setProperty(prefix+"first_max_disp_aux", this.first_max_disp_aux+"");
properties.setProperty(prefix+"first_max_disp_rig", this.first_max_disp_rig+"");
......@@ -1038,6 +1051,9 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"inf_max_disp_main")!=null) this.inf_max_disp_main=Double.parseDouble(properties.getProperty(prefix+"inf_max_disp_main"));
if (properties.getProperty(prefix+"inf_max_disp_aux")!=null) this.inf_max_disp_aux=Double.parseDouble(properties.getProperty(prefix+"inf_max_disp_aux"));
if (properties.getProperty(prefix+"inf_max_disp_rig")!=null) this.inf_max_disp_rig=Double.parseDouble(properties.getProperty(prefix+"inf_max_disp_rig"));
if (properties.getProperty(prefix+"inf_weight_disp")!=null) this.inf_weight_disp=Double.parseDouble(properties.getProperty(prefix+"inf_weight_disp"));
if (properties.getProperty(prefix+"inf_weight_disp_pow")!=null) this.inf_weight_disp_pow=Double.parseDouble(properties.getProperty(prefix+"inf_weight_disp_pow"));
if (properties.getProperty(prefix+"inf_neg_tolerance")!=null) this.inf_neg_tolerance=Double.parseDouble(properties.getProperty(prefix+"inf_neg_tolerance"));
if (properties.getProperty(prefix+"inf_weight")!=null) this.inf_weight=Double.parseDouble(properties.getProperty(prefix+"inf_weight"));
......@@ -1233,6 +1249,9 @@ public class BiQuadParameters {
bqp.inf_max_disp_main = this.inf_max_disp_main;
bqp.inf_max_disp_aux = this.inf_max_disp_aux;
bqp.inf_max_disp_rig = this.inf_max_disp_rig;
bqp.inf_weight_disp = this.inf_weight_disp;
bqp.inf_weight_disp_pow = this.inf_weight_disp_pow;
bqp.inf_neg_tolerance = this.inf_neg_tolerance;
bqp.inf_weight = this.inf_weight;
......
......@@ -5034,6 +5034,8 @@ private Panel panel1,
// TODO Auto-generated catch block
e.printStackTrace();
} //final int debugLevel);
QUAD_CLT.tp.clt_3d_passes = null; // resetCLTPasses(); // so running "Ground truth" after would be OK
QUAD_CLT_AUX.tp.clt_3d_passes = null; //.resetCLTPasses();
if (configPath!=null) {
saveTimestampedProperties( // save config again
......
......@@ -156,6 +156,8 @@ public class GeometryCorrection {
public double [] getRigCorrection(
double infinity_importance, // of all measurements
double dx_max, // = 0.3;
double dx_pow, // = 1.0;
boolean adjust_orientation,
boolean adjust_zoom,
boolean adjust_angle,
......@@ -172,6 +174,8 @@ public class GeometryCorrection {
if (rigOffset == null) return null;
return rigOffset.getRigCorrection(
infinity_importance, // of all measurements
dx_max, // double dx_max, // = 0.3;
dx_pow, // double dx_pow, // = 1.0;
adjust_orientation, // boolean adjust_orientation,
adjust_zoom, // boolean adjust_zoom,
adjust_angle, // boolean adjust_angle,
......@@ -371,6 +375,8 @@ public class GeometryCorrection {
}
public double setupYW(
double infinity_importance, // of all measurements
double dx_max, // = 0.3;
double dx_pow, // = 1.0;
ArrayList<Integer> tile_list,
QuadCLT qc,
double [] strength,
......@@ -387,25 +393,36 @@ public class GeometryCorrection {
double sum2_inf = 0.0,sum2_near = 0.0;
int tilesX = qc.tp.getTilesX();
double tileSize = qc.tp.getTileSize();
// double dx_max = 0.2;
// double dx_pow = 1.0;
for (int i = 0; i < tile_list.size(); i++) {
int nTile = tile_list.get(i);
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
double w = strength[nTile];
double inf_w_corr = 1.0;
if ((dx_max > 0) && (dx_pow > 0)){
inf_w_corr = (dx_max - diff_x[nTile])/dx_max;
if (inf_w_corr < 0.0) inf_w_corr = 0.0; // favor negative (more infinity)
if (dx_pow != 1.0) {
inf_w_corr = Math.pow(inf_w_corr,dx_pow);
}
}
if (target_disparity[nTile] == 0.0) { // only for infinity tiles
w *= inf_w_corr;
y_vector[2*i + 0] = diff_x[nTile];
w_vector[2*i + 0] = strength[nTile];
w_vector[2*i + 0] = w;
y_vector[2*i + 1] = diff_y[nTile];
w_vector[2*i + 1] = strength[nTile];
sumw_inf += 2*strength[nTile];
sum2_inf += strength[nTile]*(diff_x[nTile]*diff_x[nTile]+diff_y[nTile]*diff_y[nTile]);
w_vector[2*i + 1] = w;
sumw_inf += 2*w;
sum2_inf += w*(diff_x[nTile]*diff_x[nTile]+diff_y[nTile]*diff_y[nTile]);
is_inf[i] = true;
} else {
y_vector[2*i + 1] = diff_y[nTile];
w_vector[2*i + 1] = strength[nTile];
sumw_near += strength[nTile];
sum2_near += strength[nTile]*diff_y[nTile]*diff_y[nTile];
w_vector[2*i + 1] = w;
sumw_near += w;
sum2_near += w*diff_y[nTile]*diff_y[nTile];
}
xy_vector[2*i + 0] = (tileX + 0.5) * tileSize;
xy_vector[2*i + 1] = (tileY + 0.5) * tileSize;
......@@ -556,6 +573,8 @@ public class GeometryCorrection {
public double [] getRigCorrection(
double infinity_importance, // of all measurements
double dx_max, // = 0.3;
double dx_pow, // = 1.0;
boolean adjust_orientation,
boolean adjust_zoom,
boolean adjust_angle,
......@@ -578,6 +597,8 @@ public class GeometryCorrection {
double rms = setupYW(
infinity_importance, // of all measurements
dx_max, // double dx_max, // = 0.3;
dx_pow, // double dx_pow, // = 1.0;
tile_list,
qc_main,
strength,
......
......@@ -1191,7 +1191,9 @@ if (debugLevel > -100) return true; // temporarily !
// do actual adjustment step, update rig parameters
quadCLT_aux.geometryCorrection.getRigCorrection(
clt_parameters.rig.inf_weight , // double infinity_importance, // of all measurements
clt_parameters.rig.inf_weight , // double infinity_importance, // of all measurements
clt_parameters.rig.inf_weight_disp, // double dx_max, // = 0.3;
clt_parameters.rig.inf_weight_disp_pow, // double dx_pow, // = 1.0;
clt_parameters.rig.rig_adjust_orientation, // boolean adjust_orientation,
clt_parameters.rig.rig_adjust_zoom, // boolean adjust_zoom,
clt_parameters.rig.rig_adjust_angle, // boolean adjust_angle,
......
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