Commit cfbcc5e2 authored by Andrey Filippov's avatar Andrey Filippov

Per-scene reliable_ref filtering to mitigate "folding" using

reliable_scene masks.
parent f7241809
......@@ -1929,6 +1929,8 @@ public class ErsCorrection extends GeometryCorrection {
public static double [][] combineXYZATR(
double [][] reference_xyzatr,
double [][] scene_xyzatr){
if (reference_xyzatr == null) return scene_xyzatr;
if (scene_xyzatr == null) return reference_xyzatr;
return combineXYZATR(
reference_xyzatr[0],
reference_xyzatr[1],
......
......@@ -599,12 +599,13 @@ min_str_neib_fpn 0.35
// Detect initial match
public boolean use_combo_reliable = true; // use combo dsi if available for relaible tiles
public boolean use_combo_reliable = true; // use combo dsi if available for reliable tiles
public boolean ref_need_lma = true; // need LMA output for reliable tiles (no combo available)
public boolean ref_need_lma_combo = true; // need LMA output for reliable tiles (when combo is available)
public double min_ref_str = 0.33; // 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger
public double min_ref_str_lma = 0.8; // 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger
public double min_ref_frac = 0.2; // 0.22; if fraction number of reliable tiles is less than this, use best possible
public boolean save_reliables = true; // save reliable tiles as a multi-slice image
// was overwritten in code to always be true ****
public boolean ref_smooth = true; // false; // smooth reference disparity for initial matching
......@@ -2226,6 +2227,8 @@ min_str_neib_fpn 0.35
"Match only tiles where INTER-INTRA-LMA is stronger than that (and has LMA).");
gd.addNumericField("DSI_MAIN minimal fraction", this.min_ref_frac, 5,7,"",
"If relative number of the reliable tiles is less than this - use this best fraction.");
gd.addCheckbox ("Save reliable tiles as a multi-slice image", this.save_reliables,
"Debug feature - which tiles where used for each scene");
gd.addMessage ("Smooth reference disparity for initial matching");
gd.addCheckbox ("Smooth reference disparity", this.ref_smooth,
......@@ -3865,6 +3868,8 @@ min_str_neib_fpn 0.35
this.min_ref_str = gd.getNextNumber();
this.min_ref_str_lma = gd.getNextNumber();
this.min_ref_frac = gd.getNextNumber();
this.save_reliables = gd.getNextBoolean();
this.ref_smooth = gd.getNextBoolean();
ref_smooth_always = gd.getNextBoolean();
this.ref_sigma = gd.getNextNumber();
......@@ -5065,6 +5070,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"min_ref_str", this.min_ref_str+""); // double
properties.setProperty(prefix+"min_ref_str_lma", this.min_ref_str_lma+""); // double
properties.setProperty(prefix+"min_ref_frac", this.min_ref_frac+""); // double
properties.setProperty(prefix+"save_reliables", this.save_reliables+""); // boolean
properties.setProperty(prefix+"ref_smooth", this.ref_smooth+""); // boolean
properties.setProperty(prefix+"ref_smooth_always", this.ref_smooth_always+""); // boolean
......@@ -6205,6 +6211,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"min_ref_str")!=null) this.min_ref_str=Double.parseDouble(properties.getProperty(prefix+"min_ref_str"));
if (properties.getProperty(prefix+"min_ref_str_lma")!=null) this.min_ref_str_lma=Double.parseDouble(properties.getProperty(prefix+"min_ref_str_lma"));
if (properties.getProperty(prefix+"min_ref_frac")!=null) this.min_ref_frac=Double.parseDouble(properties.getProperty(prefix+"min_ref_frac"));
if (properties.getProperty(prefix+"save_reliables")!=null) this.save_reliables=Boolean.parseBoolean(properties.getProperty(prefix+"save_reliables"));
if (properties.getProperty(prefix+"ref_smooth")!=null) this.ref_smooth=Boolean.parseBoolean(properties.getProperty(prefix+"ref_smooth"));
if (properties.getProperty(prefix+"ref_smooth_always")!=null) this.ref_smooth_always=Boolean.parseBoolean(properties.getProperty(prefix+"ref_smooth_always"));
......@@ -7358,6 +7365,7 @@ min_str_neib_fpn 0.35
imp.min_ref_str = this.min_ref_str;
imp.min_ref_str_lma = this.min_ref_str_lma;
imp.min_ref_frac = this.min_ref_frac;
imp.save_reliables = this.save_reliables;
imp.ref_smooth = this.ref_smooth;
imp.ref_smooth_always = this.ref_smooth_always;
......
......@@ -5806,6 +5806,7 @@ public class OpticalFlow {
boolean lma_use_Z = clt_parameters.imp.lma_use_Z; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables
boolean lma_use_R = clt_parameters.imp.lma_use_R; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables
boolean ers_from_ims = true; // false; // change later
int ers_mode = 0; // keep
// with IMS it is already set during initial orientation. In non-IMS mode
if (!ers_from_ims && (master_CLT.getNumOrient() < 2)) {
......@@ -5849,6 +5850,7 @@ public class OpticalFlow {
boolean lma_use_AT = ( readjust_xy_ims || lpf_xy);
if (clt_parameters.imp.air_mode_en) {
readjust_xy_ims = false;
int min_adjust_atr = 2;
if (master_CLT.getNumOrient() < min_adjust_atr) {
disable_ers = true;
......
......@@ -144,6 +144,8 @@ public class QuadCLTCPU {
public static final String CENTER_FPN_SUFFIX = "-FPN";
public static final String CENTER_ROWCOL_SUFFIX = "-ROWCOL";
// Scale estimated overlap before masking out folded pixels to account for rotations and distortions
public static final double RELIABLE_SCALE = 1.2;
// public GPUTileProcessor.GpuQuad gpuQuad = null;
......@@ -2056,8 +2058,69 @@ public class QuadCLTCPU {
return offs_avg;
}
public double [] estimateCenterShiftXY(
double [][] xyzatr0,
double [][] xyzatr1,
double average_z,
boolean rectilinear
) {
double [][] xyzatr0_a = new double [][] {xyzatr0[0].clone(),xyzatr0[1].clone()}; // debugging
double [][] xyzatr1_a = new double [][] {xyzatr1[0].clone(),xyzatr1[1].clone()};
ErsCorrection ers = getErsCorrection();
double disp_avg = ers.getDisparityFromZ(average_z);
int [] wh = ers.getSensorWH();
double [] xy = {0.5*wh[0], 0.5*wh[1]};
double [] pXpYD = ers.getImageCoordinatesERS(
null, // QuadCLT cameraQuadCLT, // camera station that got image to be to be matched
xy[0], // double px, // pixel coordinate X in the reference view
xy[1], // double py, // pixel coordinate Y in the reference view
disp_avg, // double disparity, // this reference disparity
!rectilinear, // boolean distortedView, // This camera view is distorted (diff.rect), false - rectilinear
xyzatr0_a[0], // double [] reference_xyz, // this view position in world coordinates (typically zero3)
xyzatr0_a[1], // double [] reference_atr, // this view orientation relative to world frame (typically zero3)
!rectilinear, // boolean distortedCamera, // camera view is distorted (false - rectilinear)
xyzatr1_a[0], // double [] camera_xyz, // camera center in world coordinates
xyzatr1_a[1], // double [] camera_atr, // camera orientation relative to world frame
OpticalFlow.LINE_ERR); // double line_err); // threshold error in scan lines (1.0)
if (pXpYD == null) {
return null;
} else {
// return new double [] {pXpYD[0]-xy[0],pXpYD[1]-xy[1]};
return new double [] {xy[0]-pXpYD[0],xy[1]-pXpYD[1]};
}
}
public boolean [] maskByOverlap(
boolean [] reliable_ref_tiles,
double [] offset) {
boolean [] relable_scene_tiles= reliable_ref_tiles.clone();
int tile_size = getTileSize();
int tilesX = getTilesX();
int tilesY = getTilesY();
int width = getWidth();
int height = getHeight();
double s = 0.5*(RELIABLE_SCALE-1); // > 0
int xl = (int) Math.round((offset[0] - s* width)/tile_size);
int xr = (int) Math.round((offset[0] + (s+1)*width)/tile_size);
int yt = (int) Math.round((offset[1] - s* height)/tile_size);
int yb = (int) Math.round((offset[1] + (s+1)*height)/tile_size);
if (yt > 0) {
Arrays.fill(relable_scene_tiles, 0, tilesX * yt, false);
}
if (yb < tilesY) {
Arrays.fill(relable_scene_tiles, tilesX * yb, relable_scene_tiles.length, false);
}
if (xl > 0) {
for (int i = 0; i < tilesY; i++) {
Arrays.fill(relable_scene_tiles, tilesX * i, tilesX * i + xl, false);
}
}
if (xr < tilesX) {
for (int i = 0; i < tilesY; i++) {
Arrays.fill(relable_scene_tiles, tilesX * i + xr, tilesX * (i + 1), false); //java.lang.IllegalArgumentException: fromIndex(9) > toIndex(0)
}
}
return relable_scene_tiles;
}
public double [][] getGround(
CLTParameters clt_parameters,
......@@ -4412,9 +4475,9 @@ public class QuadCLTCPU {
null, // String path, // full name with extension or null to use x3d directory
false, // boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
return;
}
public double [][] readComboDSI (boolean silent) {
double [][] combo_dsi = new double [OpticalFlow.COMBO_DSN_TITLES.length][];
for (int indx: new int[]{INDEX_INTER_LMA, INDEX_INTER}) {
......@@ -4834,7 +4897,28 @@ public class QuadCLTCPU {
return num_slices_read;
}
public void saveReliables(
QuadCLTCPU [] quadCLTs,
boolean [][] reliables,
String suffix) {
String [] titles = new String [quadCLTs.length];
double [][] dreliables = new double[reliables.length][];
for (int nscene = 0; nscene < quadCLTs.length; nscene++) if (quadCLTs[nscene] != null){
titles[nscene] = quadCLTs[nscene].getImageName();
if (reliables[nscene] != null) {
dreliables[nscene] = new double [reliables[nscene].length];
for (int i = 0; i < reliables[nscene].length; i++) {
dreliables[nscene][i] = reliables[nscene][i] ? 1.0 : 0.0;
}
}
}
saveDoubleArrayInModelDirectory(
"-RELIABLE_TILES"+ suffix, // String suffix,
titles, // String [] labels, // or null
dreliables, // double [][] data,
getTilesX(), // int width,
getTilesY()); //int height)
}
public void saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
......
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