Commit 70ccd5f4 authored by Andrey Filippov's avatar Andrey Filippov

Tested inter-camera (double quad) bundle adjustment

parent 84e61b79
......@@ -36,7 +36,9 @@ public class BiQuadParameters {
public double inf_min_strength_rig = 0.25;
public double inf_max_disp_main = 0.15;
public double inf_max_disp_aux = 0.15;
public double inf_max_disp_rig = 0.5; // maybe even higher (2.0) to lock to initially high mismatch
public double inf_max_disp_rig = 0.2; // maybe even higher (2.0) to lock to initially high mismatch
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
public double first_max_disp_main = 0.5; // before refinement
public double first_max_disp_aux = 0.5;
......@@ -86,6 +88,10 @@ 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("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,"",
"Set importance of infinity matching among all measurements");
gd.addNumericField("Maximal absolute value of main camera disparity difference near objects, before refinement", this.first_max_disp_main, 3,6,"pix",
......@@ -143,7 +149,8 @@ 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_neg_tolerance= gd.getNextNumber();
this.inf_weight= gd.getNextNumber();
this.first_max_disp_main= gd.getNextNumber();
this.first_max_disp_aux= gd.getNextNumber();
this.first_max_disp_rig= gd.getNextNumber();
......@@ -181,6 +188,9 @@ 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_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+"");
......@@ -219,6 +229,8 @@ 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_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"));
if (properties.getProperty(prefix+"first_max_disp_main")!=null) this.first_max_disp_main=Double.parseDouble(properties.getProperty(prefix+"first_max_disp_main"));
if (properties.getProperty(prefix+"first_max_disp_aux")!=null) this.first_max_disp_aux=Double.parseDouble(properties.getProperty(prefix+"first_max_disp_aux"));
......@@ -257,6 +269,8 @@ 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_neg_tolerance = this.inf_neg_tolerance;
bqp.inf_weight = this.inf_weight;
bqp.first_max_disp_main= this.first_max_disp_main;
bqp.first_max_disp_aux= this.first_max_disp_aux;
......@@ -279,7 +293,6 @@ public class BiQuadParameters {
bqp.rig_adjust_distance= this.rig_adjust_distance;
bqp.rig_adjust_forward= this.rig_adjust_forward;
bqp.rig_correction_scale= this.rig_correction_scale;
return bqp;
......
......@@ -1156,7 +1156,7 @@ private Panel panel1,
String path= loadProperties(null,CORRECTION_PARAMETERS.resultsDirectory,true, PROPERTIES);
if (path != null) {
getAllProperties(PROPERTIES);
if (DEBUG_LEVEL > -1) System.out.println("Configuration parameters are restored from "+path);
if (DEBUG_LEVEL > -3) System.out.println("Configuration parameters are restored from "+path);
} else {
if (DEBUG_LEVEL > -10) System.out.println("Failed to restore configuration parameters");
}
......@@ -5982,7 +5982,7 @@ private Panel panel1,
// TODO Auto-generated catch block
e.printStackTrace();
}
if (DEBUG_LEVEL>0) System.out.println("Configuration parameters are saved to "+path);
if (DEBUG_LEVEL> -3) System.out.println("Configuration parameters are saved to "+path);
}
......
This diff is collapsed.
......@@ -967,6 +967,7 @@ public class TwoQuadCLT {
disparity_bimap, // double [][] src_bimap, // current state of measurements (or null for new measurement)
null, // double [][] prev_bimap, // previous state of measurements or null
2, // int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter
// will still re-measure infinity if refine_min_strength == 0.0
true, // boolean keep_inf, // keep expected disparity 0.0 if it was so
0.0, // double refine_min_strength, // do not refine weaker tiles
0.0, // double refine_tolerance, // do not refine if absolute disparity below
......@@ -986,6 +987,7 @@ public class TwoQuadCLT {
// 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.rig_adjust_orientation, // boolean adjust_orientation,
clt_parameters.rig.rig_adjust_zoom, // boolean adjust_zoom,
clt_parameters.rig.rig_adjust_angle, // boolean adjust_angle,
......@@ -1066,16 +1068,17 @@ public class TwoQuadCLT {
/**
* Refine (re-measure with updated expected disparity) tiles. If refine_min_strength and refine_tolerance are both
* set to 0.0, all (or listed) tiles will be re-measured, use camera extrinsics are changed
* set to 0.0, all (or listed) tiles will be re-measured, use camera after extrinsics are changed
* With refine_min_strength == 0, will re-measure infinity (have keep_inf == true)
* @param quadCLT_main main camera QuadCLT instance (should have tp initialized)
* @param quadCLT_aux auxiliary camera QuadCLT instance (should have tp initialized)
* @param double_stacks image data from both cameras converted to double and conditioned
* @param src_bimap results of the older measurements (now includes expected disparity)
* @param prev_bimap results of the even older measurements to interpolate if there was an overshoot
* @param refine_mode reference camera data: 0 - main camera, 1 - aux camera, 2 - cross-camera
* @param keep_inf do not refine expected disparity for infinity
* @param keep_inf do not refine expected disparity for infinity, unless refine_min_strength == 0
* @param refine_min_strength do not refine weaker tiles
* @param refine_tolerance do not refine if residial disparity (after FD pre-shift by expected disparity) less than this
* @param refine_tolerance do not refine if residual disparity (after FD pre-shift by expected disparity) less than this
* @param tile_list list of selected tiles or null. If null - try to refine all tiles, otherwise - only listed tiles
* @param saturation_main saturated pixels bitmaps for the main camera
* @param saturation_aux saturated pixels bitmaps for the auxiliary camera
......@@ -1324,7 +1327,14 @@ public class TwoQuadCLT {
// check if it was measured (skip NAN)
if (Double.isNaN(src_bimap[ImageDtt.BI_TARGET_INDEX][nTile])) return false;
// check if it is infinity and change is prohibited
if (keep_inf && (src_bimap[ImageDtt.BI_TARGET_INDEX][nTile] == 0.0)) return false;
if (keep_inf && (src_bimap[ImageDtt.BI_TARGET_INDEX][nTile] == 0.0)) {
if ((refine_min_strength == 0.0) || (refine_tolerance == 0.0)) {
tile_op[tileY][tileX] = tile_op_all;
disparity_array[tileY][tileX] = 0.0;
return true;
}
return false;
}
double diff_disp, strength, disp_scale, diff_prev;
switch (refine_mode) {
case 0:
......@@ -1429,12 +1439,17 @@ public class TwoQuadCLT {
if (select_infinity) {
for (int nTile = 0; nTile < numTiles; nTile++) {
if ( (disparity_bimap[ImageDtt.BI_TARGET_INDEX][nTile] == 0.0 ) && // expected disparity was 0.0 (infinity)
(disparity_bimap[ImageDtt.BI_STR_FULL_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_main)&&
(disparity_bimap[ImageDtt.BI_ASTR_FULL_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_aux)&&
(disparity_bimap[ImageDtt.BI_STR_CROSS_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_rig)&&
(Math.abs(disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile]) <= clt_parameters.rig.inf_max_disp_main)&&
(Math.abs(disparity_bimap[ImageDtt.BI_ADISP_FULL_INDEX][nTile]) <= clt_parameters.rig.inf_max_disp_aux)&&
(Math.abs(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile]) <= clt_parameters.rig.inf_max_disp_rig)) {
(disparity_bimap[ImageDtt.BI_STR_FULL_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_main) &&
(disparity_bimap[ImageDtt.BI_ASTR_FULL_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_aux) &&
(disparity_bimap[ImageDtt.BI_STR_CROSS_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_rig) &&
(disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_main) &&
(disparity_bimap[ImageDtt.BI_ADISP_FULL_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_aux) &&
(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_rig) &&
(disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile] >= -clt_parameters.rig.inf_max_disp_main) &&
(disparity_bimap[ImageDtt.BI_ADISP_FULL_INDEX][nTile] >= -clt_parameters.rig.inf_max_disp_aux) &&
(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile] >= -clt_parameters.rig.inf_max_disp_rig * clt_parameters.rig.inf_neg_tolerance)) {
tilesList.add(nTile);
}
}
......@@ -1445,9 +1460,14 @@ public class TwoQuadCLT {
(disparity_bimap[ImageDtt.BI_STR_FULL_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_main)&&
(disparity_bimap[ImageDtt.BI_ASTR_FULL_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_aux)&&
(disparity_bimap[ImageDtt.BI_STR_CROSS_INDEX][nTile] >= clt_parameters.rig.inf_min_strength_rig)&&
(Math.abs(disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile]) <= clt_parameters.rig.near_max_disp_main)&&
(Math.abs(disparity_bimap[ImageDtt.BI_ADISP_FULL_INDEX][nTile]) <= clt_parameters.rig.near_max_disp_aux)&&
(Math.abs(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile]) <= clt_parameters.rig.near_max_disp_rig)) {
(disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_main) &&
(disparity_bimap[ImageDtt.BI_ADISP_FULL_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_aux) &&
(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_rig) &&
(disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile] >= -clt_parameters.rig.inf_max_disp_main) &&
(disparity_bimap[ImageDtt.BI_ADISP_FULL_INDEX][nTile] >= -clt_parameters.rig.inf_max_disp_aux) &&
(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile] >= -clt_parameters.rig.inf_max_disp_rig * clt_parameters.rig.inf_neg_tolerance)) {
tilesList.add(nTile);
}
}
......
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