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 { ...@@ -36,7 +36,9 @@ public class BiQuadParameters {
public double inf_min_strength_rig = 0.25; public double inf_min_strength_rig = 0.25;
public double inf_max_disp_main = 0.15; public double inf_max_disp_main = 0.15;
public double inf_max_disp_aux = 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_main = 0.5; // before refinement
public double first_max_disp_aux = 0.5; public double first_max_disp_aux = 0.5;
...@@ -86,6 +88,10 @@ public class BiQuadParameters { ...@@ -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"); "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", 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"); "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", 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 { ...@@ -143,7 +149,8 @@ public class BiQuadParameters {
this.inf_max_disp_main= gd.getNextNumber(); this.inf_max_disp_main= gd.getNextNumber();
this.inf_max_disp_aux= gd.getNextNumber(); this.inf_max_disp_aux= gd.getNextNumber();
this.inf_max_disp_rig= 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_main= gd.getNextNumber();
this.first_max_disp_aux= gd.getNextNumber(); this.first_max_disp_aux= gd.getNextNumber();
this.first_max_disp_rig= gd.getNextNumber(); this.first_max_disp_rig= gd.getNextNumber();
...@@ -181,6 +188,9 @@ public class BiQuadParameters { ...@@ -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_main", this.inf_max_disp_main+"");
properties.setProperty(prefix+"inf_max_disp_aux", this.inf_max_disp_aux+""); 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_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_main", this.first_max_disp_main+"");
properties.setProperty(prefix+"first_max_disp_aux", this.first_max_disp_aux+""); properties.setProperty(prefix+"first_max_disp_aux", this.first_max_disp_aux+"");
...@@ -219,6 +229,8 @@ public class BiQuadParameters { ...@@ -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_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_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_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_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")); 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 { ...@@ -257,6 +269,8 @@ public class BiQuadParameters {
bqp.inf_max_disp_main = this.inf_max_disp_main; bqp.inf_max_disp_main = this.inf_max_disp_main;
bqp.inf_max_disp_aux = this.inf_max_disp_aux; bqp.inf_max_disp_aux = this.inf_max_disp_aux;
bqp.inf_max_disp_rig = this.inf_max_disp_rig; 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_main= this.first_max_disp_main;
bqp.first_max_disp_aux= this.first_max_disp_aux; bqp.first_max_disp_aux= this.first_max_disp_aux;
...@@ -279,7 +293,6 @@ public class BiQuadParameters { ...@@ -279,7 +293,6 @@ public class BiQuadParameters {
bqp.rig_adjust_distance= this.rig_adjust_distance; bqp.rig_adjust_distance= this.rig_adjust_distance;
bqp.rig_adjust_forward= this.rig_adjust_forward; bqp.rig_adjust_forward= this.rig_adjust_forward;
bqp.rig_correction_scale= this.rig_correction_scale; bqp.rig_correction_scale= this.rig_correction_scale;
return bqp; return bqp;
......
...@@ -1156,7 +1156,7 @@ private Panel panel1, ...@@ -1156,7 +1156,7 @@ private Panel panel1,
String path= loadProperties(null,CORRECTION_PARAMETERS.resultsDirectory,true, PROPERTIES); String path= loadProperties(null,CORRECTION_PARAMETERS.resultsDirectory,true, PROPERTIES);
if (path != null) { if (path != null) {
getAllProperties(PROPERTIES); 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 { } else {
if (DEBUG_LEVEL > -10) System.out.println("Failed to restore configuration parameters"); if (DEBUG_LEVEL > -10) System.out.println("Failed to restore configuration parameters");
} }
...@@ -5982,7 +5982,7 @@ private Panel panel1, ...@@ -5982,7 +5982,7 @@ private Panel panel1,
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); 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 { ...@@ -967,6 +967,7 @@ public class TwoQuadCLT {
disparity_bimap, // double [][] src_bimap, // current state of measurements (or null for new measurement) disparity_bimap, // double [][] src_bimap, // current state of measurements (or null for new measurement)
null, // double [][] prev_bimap, // previous state of measurements or null null, // double [][] prev_bimap, // previous state of measurements or null
2, // int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter 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 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_min_strength, // do not refine weaker tiles
0.0, // double refine_tolerance, // do not refine if absolute disparity below 0.0, // double refine_tolerance, // do not refine if absolute disparity below
...@@ -986,19 +987,20 @@ public class TwoQuadCLT { ...@@ -986,19 +987,20 @@ public class TwoQuadCLT {
// do actual adjustment step, update rig parameters // do actual adjustment step, update rig parameters
quadCLT_aux.geometryCorrection.getRigCorrection( quadCLT_aux.geometryCorrection.getRigCorrection(
clt_parameters.rig.rig_adjust_orientation, // boolean adjust_orientation, clt_parameters.rig.inf_weight , // double infinity_importance, // of all measurements
clt_parameters.rig.rig_adjust_zoom, // boolean adjust_zoom, clt_parameters.rig.rig_adjust_orientation, // boolean adjust_orientation,
clt_parameters.rig.rig_adjust_angle, // boolean adjust_angle, clt_parameters.rig.rig_adjust_zoom, // boolean adjust_zoom,
clt_parameters.rig.rig_adjust_distance, // boolean adjust_distance, clt_parameters.rig.rig_adjust_angle, // boolean adjust_angle,
clt_parameters.rig.rig_adjust_forward, // boolean adjust_forward, // not used clt_parameters.rig.rig_adjust_distance, // boolean adjust_distance,
clt_parameters.rig.rig_correction_scale, // double scale_correction, clt_parameters.rig.rig_adjust_forward, // boolean adjust_forward, // not used
tile_list, // ArrayList<Integer> tile_list, clt_parameters.rig.rig_correction_scale, // double scale_correction,
quadCLT_main, // QuadCLT qc_main, tile_list, // ArrayList<Integer> tile_list,
disparity_bimap[ImageDtt.BI_STR_CROSS_INDEX], // double [] strength, quadCLT_main, // QuadCLT qc_main,
disparity_bimap[ImageDtt.BI_DISP_CROSS_DX_INDEX], // double [] diff_x, // used only with target_disparity == 0 disparity_bimap[ImageDtt.BI_STR_CROSS_INDEX], // double [] strength,
disparity_bimap[ImageDtt.BI_DISP_CROSS_DY_INDEX], // double [] diff_y, disparity_bimap[ImageDtt.BI_DISP_CROSS_DX_INDEX], // double [] diff_x, // used only with target_disparity == 0
disparity_bimap[ImageDtt.BI_TARGET_INDEX], // double [] target_disparity, disparity_bimap[ImageDtt.BI_DISP_CROSS_DY_INDEX], // double [] diff_y,
debugLevel+1); disparity_bimap[ImageDtt.BI_TARGET_INDEX], // double [] target_disparity,
debugLevel+1);
} // end of for (int num_short_cycle = 0; num_short_cycle < clt_parameters.rig.rig_adjust_short_cycles;num_short_cycle++) { } // end of for (int num_short_cycle = 0; num_short_cycle < clt_parameters.rig.rig_adjust_short_cycles;num_short_cycle++) {
...@@ -1066,16 +1068,17 @@ public class TwoQuadCLT { ...@@ -1066,16 +1068,17 @@ public class TwoQuadCLT {
/** /**
* Refine (re-measure with updated expected disparity) tiles. If refine_min_strength and refine_tolerance are both * 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_main main camera QuadCLT instance (should have tp initialized)
* @param quadCLT_aux auxiliary 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 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 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 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 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_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 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_main saturated pixels bitmaps for the main camera
* @param saturation_aux saturated pixels bitmaps for the auxiliary camera * @param saturation_aux saturated pixels bitmaps for the auxiliary camera
...@@ -1324,7 +1327,14 @@ public class TwoQuadCLT { ...@@ -1324,7 +1327,14 @@ public class TwoQuadCLT {
// check if it was measured (skip NAN) // check if it was measured (skip NAN)
if (Double.isNaN(src_bimap[ImageDtt.BI_TARGET_INDEX][nTile])) return false; if (Double.isNaN(src_bimap[ImageDtt.BI_TARGET_INDEX][nTile])) return false;
// check if it is infinity and change is prohibited // 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; double diff_disp, strength, disp_scale, diff_prev;
switch (refine_mode) { switch (refine_mode) {
case 0: case 0:
...@@ -1429,12 +1439,17 @@ public class TwoQuadCLT { ...@@ -1429,12 +1439,17 @@ public class TwoQuadCLT {
if (select_infinity) { if (select_infinity) {
for (int nTile = 0; nTile < numTiles; nTile++) { for (int nTile = 0; nTile < numTiles; nTile++) {
if ( (disparity_bimap[ImageDtt.BI_TARGET_INDEX][nTile] == 0.0 ) && // expected disparity was 0.0 (infinity) 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_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_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_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)&& (disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_main) &&
(Math.abs(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile]) <= clt_parameters.rig.inf_max_disp_rig)) { (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); tilesList.add(nTile);
} }
} }
...@@ -1445,9 +1460,14 @@ public class TwoQuadCLT { ...@@ -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_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_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_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)&& (disparity_bimap[ImageDtt.BI_DISP_FULL_INDEX][nTile] <= clt_parameters.rig.inf_max_disp_main) &&
(Math.abs(disparity_bimap[ImageDtt.BI_DISP_CROSS_INDEX][nTile]) <= clt_parameters.rig.near_max_disp_rig)) { (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); 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