Commit 2f7a08d9 authored by Andrey Filippov's avatar Andrey Filippov

intermediate, working, debugging interscene matching

parent ba860911
...@@ -2412,10 +2412,12 @@ public class Correlation2d { ...@@ -2412,10 +2412,12 @@ public class Correlation2d {
} }
public static double [] getMaxXYCm( public static double [] getMaxXYCm(
double [] data, double [] data, // will be modified if fpn_mask != null;
int data_width, // = 2 * transform_size - 1; int data_width, // = 2 * transform_size - 1;
double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad) double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
int refine, // re-center window around new maximum. 0 -no refines (single-pass) int refine, // re-center window around new maximum. 0 -no refines (single-pass)
boolean [] fpn_mask,
boolean ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
boolean debug) boolean debug)
{ {
int data_height = data.length/data_width; int data_height = data.length/data_width;
...@@ -2428,8 +2430,29 @@ public class Correlation2d { ...@@ -2428,8 +2430,29 @@ public class Correlation2d {
} }
} }
double mx = data[imax]; double mx = data[imax];
x0 = imax % data_width; int ix0 = imax % data_width;
y0 = imax / data_width; int iy0 = imax / data_width;
x0 = ix0;
y0 = iy0;
// if (fpn_mask != null
if (fpn_mask != null) {
for (int i = 0; i < fpn_mask.length; i++) if (fpn_mask[i]) {
int iy = i / data_width;
int ix = i - iy * data_width;
if (ignore_border) {
if(((ix - ix0) <= 1) && ((ix - ix0) >= -1) && ((iy - iy0) <= 1) && ((iy - iy0) >= -1)) {
return null; // new double[3];
}
}
int ix1 = 2 * ix0 - ix;
if ((ix1 >= 0) && (ix1 < data_width)) {
int iy1 = 2 * iy0 - iy;
if ((iy1 >= 0) && (iy1 < data_height)) {
data[iy1 * data_width + ix1] = 0.0; // zero out symmetrical to fpn mask around integer maximum
}
}
}
}
//calculate as "center of mass" //calculate as "center of mass"
if (radius == 0) { if (radius == 0) {
double s0 = 0, sx=0,sy = 0; double s0 = 0, sx=0,sy = 0;
...@@ -2442,6 +2465,9 @@ public class Correlation2d { ...@@ -2442,6 +2465,9 @@ public class Correlation2d {
s0 += d; s0 += d;
sx += d * x; sx += d * x;
sy += d * y; sy += d * y;
} else if (Double.isNaN(d)) {
System.out.println("NaN in getMaxXYCm()");
return null;
} }
} }
} }
......
...@@ -2461,6 +2461,9 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2461,6 +2461,9 @@ public class ImageDtt extends ImageDttCPU {
// to be converted to float (may be null) // to be converted to float (may be null)
final double [][][] dcorr_tiles, // [tile][pair absolute, sparse][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate final double [][][] dcorr_tiles, // [tile][pair absolute, sparse][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
final double [][] pXpYD, // pXpYD for the reference scene final double [][] pXpYD, // pXpYD for the reference scene
final double [][] fpn_offsets, // null, or per-tile X,Y offset to be blanked
final double fpn_radius, // radius to be blanked around FPN offset center
final boolean fpn_ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
final double[][][] motion_vectors, // [tilesY*tilesX][][] -> [][num_sel_sensors+1 or 2][3] final double[][][] motion_vectors, // [tilesY*tilesX][][] -> [][num_sel_sensors+1 or 2][3]
final boolean run_poly, // polynomial max, if false - centroid final boolean run_poly, // polynomial max, if false - centroid
final boolean use_partial, // find motion vectors for individual pairs, false - for sum only final boolean use_partial, // find motion vectors for individual pairs, false - for sum only
...@@ -2469,8 +2472,10 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2469,8 +2472,10 @@ public class ImageDtt extends ImageDttCPU {
final double td_weight, // mix correlations accumulated in TD with final double td_weight, // mix correlations accumulated in TD with
final double pd_weight, // correlations (post) accumulated in PD final double pd_weight, // correlations (post) accumulated in PD
final boolean td_nopd_only, // only use TD accumulated data if no safe PD is available for the tile. final boolean td_nopd_only, // only use TD accumulated data if no safe PD is available for the tile.
final double min_str, // = 0.25; final double min_str_nofpn, // = 0.25;
final double min_str_sum, // = 0.8; // 5; final double min_str_sum_nofpn,// = 0.8; // 5;
final double min_str_fpn, // = 0.25;
final double min_str_sum_fpn, // = 0.8; // 5;
final int min_neibs, // 2; // minimal number of strong neighbors (> min_str) final int min_neibs, // 2; // minimal number of strong neighbors (> min_str)
final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8) final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8)
final double half_disparity, // 5.0; // Reduce weight twice for this disparity final double half_disparity, // 5.0; // Reduce weight twice for this disparity
...@@ -2573,13 +2578,11 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2573,13 +2578,11 @@ public class ImageDtt extends ImageDttCPU {
final Thread[] threads = newThreadArray(threadsMax); final Thread[] threads = newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override @Override
public void run() { public void run() {
int tileY,tileX,nTile; // , chn; int tileY,tileX,nTile; // , chn;
// for (int iTile = ai.getAndIncrement(); iTile < tp_tasks.length; iTile = ai.getAndIncrement()) {
for (int iCorrTile = ai.getAndIncrement(); iCorrTile < num_tiles; iCorrTile = ai.getAndIncrement()) { for (int iCorrTile = ai.getAndIncrement(); iCorrTile < num_tiles; iCorrTile = ai.getAndIncrement()) {
nTile = (corr_indices[iCorrTile* used_sensors_list.length] >> GPUTileProcessor.CORR_NTILE_SHIFT); nTile = (corr_indices[iCorrTile* used_sensors_list.length] >> GPUTileProcessor.CORR_NTILE_SHIFT);
tileY = nTile / tilesX; tileY = nTile / tilesX;
...@@ -2588,6 +2591,29 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2588,6 +2591,29 @@ public class ImageDtt extends ImageDttCPU {
if (debugTile0) { if (debugTile0) {
System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY+", nTile="+nTile+", nTile="+nTile); System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY+", nTile="+nTile+", nTile="+nTile);
} }
// zero FPN right in the fcorr2D so it will go to both processing and display
boolean [] fpn_mask = null;
double min_str = min_str_nofpn; // higher threshold when FPN is possible
double min_str_sum = min_str_sum_nofpn; // higher threshold when FPN is possible
if ((fpn_offsets != null) && (fpn_offsets[nTile] != null)) {
double fpn_x = transform_size - 1 - fpn_offsets[nTile][0]; // 0 -> 7.0
double fpn_y = transform_size - 1 - fpn_offsets[nTile][1]; // 0 -> 7.0
int min_x = (int) Math.max(Math.round(fpn_x - fpn_radius),0);
int max_x = (int) Math.min(Math.round(fpn_x + fpn_radius), corr_size-1);
int min_y = (int) Math.max(Math.round(fpn_y - fpn_radius),0);
int max_y = (int) Math.min(Math.round(fpn_y + fpn_radius), corr_size-1);
int fcorr2D_indx = (iCorrTile + 1)* used_sensors_list.length -1; // last in each group - sum in TD
fpn_mask = new boolean[fcorr2D[fcorr2D_indx].length];
for (int iy = min_y; iy <= max_y; iy++) {
for (int ix = min_x; ix <= max_x; ix++) {
int indx = iy * corr_size + ix;
fcorr2D[fcorr2D_indx][indx] = 0;
fpn_mask[indx] = true;
}
}
min_str = min_str_fpn;
min_str_sum = min_str_sum_fpn;
}
double [][] corrs = new double [corrs_len + extra_len][]; double [][] corrs = new double [corrs_len + extra_len][];
// copy correlation tiles from the GPU's floating point arrays // copy correlation tiles from the GPU's floating point arrays
double scale = 1.0/getNumSensors(); double scale = 1.0/getNumSensors();
...@@ -2617,7 +2643,7 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2617,7 +2643,7 @@ public class ImageDtt extends ImageDttCPU {
} }
} }
if (dcorr_tiles != null) { if (dcorr_tiles != null) { // This will be visualized
int index_es = getNumSensors() + extra_len; int index_es = getNumSensors() + extra_len;
dcorr_tiles[iCorrTile] = new double[getNumSensors()+1 + extra_len][]; dcorr_tiles[iCorrTile] = new double[getNumSensors()+1 + extra_len][];
if (extra_sum) { if (extra_sum) {
...@@ -2651,6 +2677,8 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2651,6 +2677,8 @@ public class ImageDtt extends ImageDttCPU {
corr_size, // int data_width, // = 2 * transform_size - 1; corr_size, // int data_width, // = 2 * transform_size - 1;
centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad) centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass) n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass)
null, // boolean [] fpn_mask,
false, // boolean ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
false); // boolean debug) false); // boolean debug)
if (motion_vectors[nTile][nsens] != null) { if (motion_vectors[nTile][nsens] != null) {
if (motion_vectors[nTile][nsens][2] < min_vstr) { if (motion_vectors[nTile][nsens][2] < min_vstr) {
...@@ -2668,6 +2696,8 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2668,6 +2696,8 @@ public class ImageDtt extends ImageDttCPU {
corr_size, // int data_width, // = 2 * transform_size - 1; corr_size, // int data_width, // = 2 * transform_size - 1;
centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad) centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass) n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass)
null, // boolean [] fpn_mask,
false, // boolean ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
false); // boolean debug) false); // boolean debug)
if (mv_pd != null) { if (mv_pd != null) {
if (mv_pd[2] < min_str) { if (mv_pd[2] < min_str) {
...@@ -2683,6 +2713,8 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2683,6 +2713,8 @@ public class ImageDtt extends ImageDttCPU {
corr_size, // int data_width, // = 2 * transform_size - 1; corr_size, // int data_width, // = 2 * transform_size - 1;
centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad) centroid_radius, // double radius, // 0 - all same weight, > 0 cosine(PI/2*sqrt(dx^2+dy^2)/rad)
n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass) n_recenter, // int refine, // re-center window around new maximum. 0 -no refines (single-pass)
fpn_mask, // boolean [] fpn_mask,
false, // boolean ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
false); // boolean debug) false); // boolean debug)
if (mv_td != null) { if (mv_td != null) {
if (mv_td[2] < min_str_sum) { if (mv_td[2] < min_str_sum) {
...@@ -2735,6 +2767,9 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2735,6 +2767,9 @@ public class ImageDtt extends ImageDttCPU {
double l2; double l2;
TileNeibs tn = new TileNeibs(tilesX,tilesY); TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
// if (nTile==162) {
// System.out.println("nTile="+nTile);
// }
if ((mv[nTile] != null) && (pXpYD[nTile] != null)) { if ((mv[nTile] != null) && (pXpYD[nTile] != null)) {
int num_neibs=0; int num_neibs=0;
double sx=0.0, sy=0.0; double sx=0.0, sy=0.0;
...@@ -2785,9 +2820,12 @@ public class ImageDtt extends ImageDttCPU { ...@@ -2785,9 +2820,12 @@ public class ImageDtt extends ImageDttCPU {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
@Override @Override
public void run() { public void run() {
double l2; // double l2;
TileNeibs tn = new TileNeibs(tilesX,tilesY); // TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) { for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
// if (nTile==162) {
// System.out.println("nTile="+nTile);
// }
if ((mv[nTile] != null) && (pXpYD[nTile] != null)) { if ((mv[nTile] != null) && (pXpYD[nTile] != null)) {
if (mv[nTile][2] <= 0) { if (mv[nTile][2] <= 0) {
mv[nTile] = null; mv[nTile] = null;
......
...@@ -175,14 +175,19 @@ public class IntersceneMatchParameters { ...@@ -175,14 +175,19 @@ public class IntersceneMatchParameters {
public double centroid_radius = 4.0; // public double centroid_radius = 4.0; //
public int n_recenter = 2; // when cosine window, re-center window this many times public int n_recenter = 2; // when cosine window, re-center window this many times
// filtering motion vectors // filtering motion vectors
public double min_ref_str = 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger
// TD accumulation of the inter-scene correlations demonstrated artifacts (horizontally offset by 8 pixels // TD accumulation of the inter-scene correlations demonstrated artifacts (horizontally offset by 8 pixels
// false maximum that is sharper than the real one. Still not understood - maybe float precision related. // false maximum that is sharper than the real one. Still not understood - maybe float precision related.
public double td_weight = 0.5; // mix correlations accumulated in TD with public double td_weight = 0.5; // mix correlations accumulated in TD with
public double pd_weight = 0.5; // correlations (post) accumulated in PD public double pd_weight = 0.5; // correlations (post) accumulated in PD
public boolean td_nopd_only = true; // only use TD accumulated data if no safe PD is available for the tile. public boolean td_nopd_only = false; // true; // only use TD accumulated data if no safe PD is available for the tile.
public double min_str_fpn = 0.2; // 0.25; // minimal correlation strength for all but TD-accumulated layer
public double min_str_sum_fpn = 0.5; // 0.8; // minimal correlation strength for TD-accumulated layer
public double min_str = 0.18; // tiles w/o FPN: minimal correlation strength for all but TD-accumulated layer
public double min_str_sum = 0.33; // tiles w/o FPN: minimal correlation strength for TD-accumulated layer
public double min_str = 0.2; // 0.25; // minimal correlation strength for all but TD-accumulated layer
public double min_str_sum = 0.7; // 0.8; // minimal correlation strength for TD-accumulated layer
public int min_neibs = 2; // minimal number of strong neighbors (> min_str) public int min_neibs = 2; // minimal number of strong neighbors (> min_str)
public double weight_zero_neibs = 0.2; // Reduce weight for no-neib (1.0 for all 8) public double weight_zero_neibs = 0.2; // Reduce weight for no-neib (1.0 for all 8)
public double half_disparity = 5.0; // Reduce weight twice for this disparity public double half_disparity = 5.0; // Reduce weight twice for this disparity
...@@ -191,15 +196,24 @@ public class IntersceneMatchParameters { ...@@ -191,15 +196,24 @@ public class IntersceneMatchParameters {
// Detect initial match // Detect initial match
public int pix_step = 4; // Azimuth/tilt search step in pixels public int pix_step = 4; // Azimuth/tilt search step in pixels
public int search_rad = 10; // Search radius in steps public int search_rad = 10; // Search radius in steps
public double maybe_sum = 8.0; // minimal sum of strengths (will search for the best) public double maybe_sum = 1.0; // minimal sum of strengths (will search for the best)
public double shure_sum = 30.0; // definitely good sum of strengths (no farther search) public double sure_sum = 50.0; // definitely good sum of strengths (no more search) too high, will be FOM-defined
public double maybe_avg = 0.005; // maybe average strength public double maybe_avg = 0.01; // maybe average strength
public double shure_avg = 0.015; // sure average strength public double sure_avg = 0.15; // 0.015; // sure average strength disabling (was 0.03)
public double max_search_rms = 1.5; // good - 0.34, so-so - 0.999
public double maybe_fom = 1.0; // good - 38, second good - 4.5
public double sure_fom = 12.0; // good - 38, second good - 4.5
// Reference scene disparity // Reference scene disparity
public boolean use_combo_dsi = true; // use interscene DSI if available (instead of the single-scene) public boolean use_combo_dsi = true; // use interscene DSI if available (instead of the single-scene)
public boolean use_lma_dsi = true; // only use reference DSI tiles that have LMA (strong) disparity public boolean use_lma_dsi = true; // only use reference DSI tiles that have LMA (strong) disparity
// Remove correlation caused by FPN
public boolean fpn_remove = true; // only use reference DSI tiles that have LMA (strong) disparity
public double fpn_max_offset = 8.0; // pix - ignore larger FPN offsets
public double fpn_radius = 0.75; // pix - zero around center
public boolean fpn_ignore_border = false; // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
// Remove moving objects (goal is not to detect slightest movement, but to improve pose matching // Remove moving objects (goal is not to detect slightest movement, but to improve pose matching
public boolean mov_en = true; // enable detection/removal of the moving objects during pose matching public boolean mov_en = true; // enable detection/removal of the moving objects during pose matching
...@@ -240,15 +254,21 @@ public class IntersceneMatchParameters { ...@@ -240,15 +254,21 @@ public class IntersceneMatchParameters {
public int test_ers1 = -1; // try adjusting a pair of scenes with ERS. Other scene index public int test_ers1 = -1; // try adjusting a pair of scenes with ERS. Other scene index
public boolean renderRef() {return (debug_level>1) && render_ref;} public boolean renderRef() {return renderRef (debug_level);}
public boolean renderScene() {return (debug_level>1) && render_scene;} public boolean renderScene() {return renderScene (debug_level);}
public boolean show2dCorrelations() {return (debug_level>1) && show_2d_correlations;} public boolean show2dCorrelations() {return show2dCorrelations (debug_level);}
public boolean showMotionVectors() {return (debug_level>1) && show_motion_vectors;} public boolean showMotionVectors() {return showMotionVectors (debug_level);}
public boolean showCorrMotion() {return (debug_level>0) && show_motion_vectors;} public boolean showCorrMotion() {return showCorrMotion (debug_level);}
public boolean showMovementDetection(){return showMovementDetection (debug_level);}
public boolean showMovementDetection(){return (debug_level>0) && mov_show;} public int movDebugLevel() {return movDebugLevel (debug_level);}
public int movDebugLevel() {return (debug_level > -1) ? mov_debug_level : 0;}
public boolean renderRef(int dlev) {return (dlev>1) && render_ref;}
public boolean renderScene(int dlev) {return (dlev>1) && render_scene;}
public boolean show2dCorrelations(int dlev) {return (dlev>1) && show_2d_correlations;}
public boolean showMotionVectors(int dlev) {return (dlev>1) && show_motion_vectors;}
public boolean showCorrMotion(int dlev) {return (dlev>0) && show_motion_vectors;}
public boolean showMovementDetection(int dlev){return (dlev>0) && mov_show;}
public int movDebugLevel(int dlev) {return (dlev > -1) ? mov_debug_level : 0;}
public IntersceneMatchParameters() { public IntersceneMatchParameters() {
...@@ -570,6 +590,11 @@ public class IntersceneMatchParameters { ...@@ -570,6 +590,11 @@ public class IntersceneMatchParameters {
gd.addNumericField("Refine centroids", this.n_recenter, 0,5,"", gd.addNumericField("Refine centroids", this.n_recenter, 0,5,"",
"Repeat centroids after moving the window center to the new centroid location this many times (0 - calculate once)"); "Repeat centroids after moving the window center to the new centroid location this many times (0 - calculate once)");
gd.addMessage ("Filter tiles to use for scene poses");
gd.addNumericField("DSI_MAIN minimal strength", this.min_ref_str, 5,7,"",
"Match only tiles where DSI_MAIN is stronger than that (and has LMA).");
gd.addMessage ("Mixing TD and PD accumulation of 2d correlations"); gd.addMessage ("Mixing TD and PD accumulation of 2d correlations");
gd.addNumericField("TD-accumulated weight", this.td_weight, 5,7,"", gd.addNumericField("TD-accumulated weight", this.td_weight, 5,7,"",
"Mix argmax from TD-accumulated correlation."); "Mix argmax from TD-accumulated correlation.");
...@@ -581,8 +606,13 @@ public class IntersceneMatchParameters { ...@@ -581,8 +606,13 @@ public class IntersceneMatchParameters {
gd.addMessage ("Filtering motion vectors"); gd.addMessage ("Filtering motion vectors");
gd.addNumericField("Minimal correlation strength (non-sum)", this.min_str, 5,7,"", gd.addNumericField("Minimal correlation strength (non-sum)", this.min_str, 5,7,"",
"Minimal correlation strength for individual correlation and for pixel-domain averaged one. Weeker tiles results are removed."); "Minimal correlation strength for individual correlation and for pixel-domain averaged one. Weeker tiles results are removed.");
gd.addNumericField("Minimal correlation strength (sum only)",this.min_str_sum, 5,7,"", gd.addNumericField("Minimal correlation strength (non-sum) w/FPN", this.min_str_fpn, 5,7,"",
"Similar to above, but for small offsets where FPN correlation may be present");
gd.addNumericField("Minimal correlation strength (sum only)", this.min_str_sum, 5,7,"",
"Minimal correlation strength for transform-domain averaging. Weeker tiles results are removed."); "Minimal correlation strength for transform-domain averaging. Weeker tiles results are removed.");
gd.addNumericField("Minimal correlation strength (sum only) w/FPN",this.min_str_sum_fpn, 5,7,"",
"Similar to above, but for small offsets where FPN correlation may be present");
gd.addNumericField("Minimal number of neighbors (of 8)", this.min_neibs, 0,3,"", gd.addNumericField("Minimal number of neighbors (of 8)", this.min_neibs, 0,3,"",
"Remove motion vectors with less than this number of defined (passing min_str) neighbors."); "Remove motion vectors with less than this number of defined (passing min_str) neighbors.");
gd.addNumericField("No-neighbors weight (<1.0)", this.weight_zero_neibs, 5,7,"", gd.addNumericField("No-neighbors weight (<1.0)", this.weight_zero_neibs, 5,7,"",
...@@ -599,12 +629,20 @@ public class IntersceneMatchParameters { ...@@ -599,12 +629,20 @@ public class IntersceneMatchParameters {
"Maximal search radius in steps"); "Maximal search radius in steps");
gd.addNumericField("\"Maybe\" sum of strengths", this.maybe_sum, 5,7,"", gd.addNumericField("\"Maybe\" sum of strengths", this.maybe_sum, 5,7,"",
"Minimal acceptable sum of defined tiles strengths (will look for the best among matching)"); "Minimal acceptable sum of defined tiles strengths (will look for the best among matching)");
gd.addNumericField("\"Sure\" sum of strengths", this.shure_sum, 5,7,"", gd.addNumericField("\"Sure\" sum of strengths", this.sure_sum, 5,7,"",
"Definitely sufficient sum of defined tiles strengths (will non continue looking for better)."); "Definitely sufficient sum of defined tiles strengths (will not continue looking for better).");
gd.addNumericField("\"Maybe\" average of strengths", this.maybe_avg, 5,7,"", gd.addNumericField("\"Maybe\" average of strengths", this.maybe_avg, 5,7,"",
"Minimal acceptable average of defined tiles strengths (will look for the best among matching)"); "Minimal acceptable average of defined tiles strengths (will look for the best among matching)");
gd.addNumericField("\"Sure\" average of strengths", this.shure_avg, 5,7,"", gd.addNumericField("\"Sure\" average of strengths", this.sure_avg, 5,7,"",
"Definitely sufficient average of defined tiles strengths (will non continue looking for better)."); "Definitely sufficient average of defined tiles strengths (will not continue looking for better).");
gd.addNumericField("Maximal offset standard deviation", this.max_search_rms, 5,7,"pix",
"Standard deviation for X,Y offsets.");
gd.addNumericField("\"Maybe\" FOM", this.maybe_fom, 5,7,"",
"Minimal acceptable Figure of Merit (semi-total strength divided by standard deviation of offsets), will look for the best among matching.");
gd.addNumericField("\"Sure\" FOM", this.sure_fom, 5,7,"",
"Definitely sufficient FOM (semi-total strength divided by standard deviation of offsets), will non continue looking for better.");
gd.addMessage ("Reference scene disparity"); gd.addMessage ("Reference scene disparity");
gd.addCheckbox ("Use combo DSI (if available)", this.use_combo_dsi, gd.addCheckbox ("Use combo DSI (if available)", this.use_combo_dsi,
...@@ -612,6 +650,16 @@ public class IntersceneMatchParameters { ...@@ -612,6 +650,16 @@ public class IntersceneMatchParameters {
gd.addCheckbox ("LMA tiles only", this.use_lma_dsi, gd.addCheckbox ("LMA tiles only", this.use_lma_dsi,
"Use only strong correlation tiles (with LMA available) for interscene correlation (pose matching)"); "Use only strong correlation tiles (with LMA available) for interscene correlation (pose matching)");
gd.addMessage ("Supress FPN in interscene correlations");
gd.addCheckbox ("Enable FPN suppression", this.fpn_remove,
"Zero-out integrated inter-scene correlation around zero-shift offset");
gd.addNumericField("Maximal FPN offset to consider", this.fpn_max_offset, 6,7,"pix",
"Maximal offset from the zero shift to consider (normally just 8 pix)");
gd.addNumericField("FPN suppression radius", this.fpn_radius, 6,7,"pix",
"Blank correlation pixels closer than this distance from the FPN offset");
gd.addCheckbox ("Ignore maximums \"touching\" FPN", this.fpn_ignore_border,
"Discard TD integrated tiles where local maximum is a neighbor (including diagonal) to blanked FPN correlation pixels");
gd.addMessage ("Detect and remove moving objects from pose matching"); gd.addMessage ("Detect and remove moving objects from pose matching");
gd.addCheckbox ("Enable movement detection/elimination", this.mov_en, gd.addCheckbox ("Enable movement detection/elimination", this.mov_en,
"Detect and mask areas with detected movement to improve pose matching"); "Detect and mask areas with detected movement to improve pose matching");
...@@ -879,12 +927,17 @@ public class IntersceneMatchParameters { ...@@ -879,12 +927,17 @@ public class IntersceneMatchParameters {
this.centroid_radius = gd.getNextNumber(); this.centroid_radius = gd.getNextNumber();
this.n_recenter = (int) gd.getNextNumber(); this.n_recenter = (int) gd.getNextNumber();
this.min_ref_str = gd.getNextNumber();
this.td_weight = gd.getNextNumber(); this.td_weight = gd.getNextNumber();
this.pd_weight = gd.getNextNumber(); this.pd_weight = gd.getNextNumber();
this.td_nopd_only = gd.getNextBoolean(); this.td_nopd_only = gd.getNextBoolean();
this.min_str = gd.getNextNumber(); this.min_str = gd.getNextNumber();
this.min_str_fpn = gd.getNextNumber();
this.min_str_sum = gd.getNextNumber(); this.min_str_sum = gd.getNextNumber();
this.min_str_sum_fpn = gd.getNextNumber();
this.min_neibs = (int) gd.getNextNumber(); this.min_neibs = (int) gd.getNextNumber();
this.weight_zero_neibs = gd.getNextNumber(); this.weight_zero_neibs = gd.getNextNumber();
this.half_disparity = gd.getNextNumber(); this.half_disparity = gd.getNextNumber();
...@@ -892,13 +945,22 @@ public class IntersceneMatchParameters { ...@@ -892,13 +945,22 @@ public class IntersceneMatchParameters {
this.pix_step = (int) gd.getNextNumber(); this.pix_step = (int) gd.getNextNumber();
this.search_rad = (int) gd.getNextNumber(); this.search_rad = (int) gd.getNextNumber();
this.maybe_sum = gd.getNextNumber(); this.maybe_sum = gd.getNextNumber();
this.shure_sum = gd.getNextNumber(); this.sure_sum = gd.getNextNumber();
this.maybe_avg = gd.getNextNumber(); this.maybe_avg = gd.getNextNumber();
this.shure_avg = gd.getNextNumber(); this.sure_avg = gd.getNextNumber();
this.max_search_rms = gd.getNextNumber();
this.maybe_fom = gd.getNextNumber();
this.sure_fom = gd.getNextNumber();
this.use_combo_dsi = gd.getNextBoolean(); this.use_combo_dsi = gd.getNextBoolean();
this.use_lma_dsi = gd.getNextBoolean(); this.use_lma_dsi = gd.getNextBoolean();
this.fpn_remove = gd.getNextBoolean();
this.fpn_max_offset = gd.getNextNumber();
this.fpn_radius = gd.getNextNumber();
this.fpn_ignore_border = gd.getNextBoolean();
this.mov_en = gd.getNextBoolean(); this.mov_en = gd.getNextBoolean();
this.mov_sigma = gd.getNextNumber(); this.mov_sigma = gd.getNextNumber();
this.mov_max_std = gd.getNextNumber(); this.mov_max_std = gd.getNextNumber();
...@@ -1075,12 +1137,17 @@ public class IntersceneMatchParameters { ...@@ -1075,12 +1137,17 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"centroid_radius", this.centroid_radius+""); // double properties.setProperty(prefix+"centroid_radius", this.centroid_radius+""); // double
properties.setProperty(prefix+"n_recenter", this.n_recenter+""); // int properties.setProperty(prefix+"n_recenter", this.n_recenter+""); // int
properties.setProperty(prefix+"min_ref_str", this.min_ref_str+""); // double
properties.setProperty(prefix+"td_weight", this.td_weight+""); // double properties.setProperty(prefix+"td_weight", this.td_weight+""); // double
properties.setProperty(prefix+"pd_weight", this.pd_weight+""); // double properties.setProperty(prefix+"pd_weight", this.pd_weight+""); // double
properties.setProperty(prefix+"td_nopd_only", this.td_nopd_only+""); // boolean properties.setProperty(prefix+"td_nopd_only", this.td_nopd_only+""); // boolean
properties.setProperty(prefix+"min_str", this.min_str+""); // double properties.setProperty(prefix+"min_str", this.min_str+""); // double
properties.setProperty(prefix+"min_str_fpn", this.min_str_fpn+""); // double
properties.setProperty(prefix+"min_str_sum", this.min_str_sum+""); // double properties.setProperty(prefix+"min_str_sum", this.min_str_sum+""); // double
properties.setProperty(prefix+"min_str_sum_fpn", this.min_str_sum_fpn+""); // double
properties.setProperty(prefix+"min_neibs", this.min_neibs+""); // int properties.setProperty(prefix+"min_neibs", this.min_neibs+""); // int
properties.setProperty(prefix+"weight_zero_neibs", this.weight_zero_neibs+""); // double properties.setProperty(prefix+"weight_zero_neibs", this.weight_zero_neibs+""); // double
properties.setProperty(prefix+"half_disparity", this.half_disparity+""); // double properties.setProperty(prefix+"half_disparity", this.half_disparity+""); // double
...@@ -1088,11 +1155,22 @@ public class IntersceneMatchParameters { ...@@ -1088,11 +1155,22 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"pix_step", this.pix_step+""); // int properties.setProperty(prefix+"pix_step", this.pix_step+""); // int
properties.setProperty(prefix+"search_rad", this.search_rad+""); // int properties.setProperty(prefix+"search_rad", this.search_rad+""); // int
properties.setProperty(prefix+"maybe_sum", this.maybe_sum+""); // double properties.setProperty(prefix+"maybe_sum", this.maybe_sum+""); // double
properties.setProperty(prefix+"shure_sum", this.shure_sum+""); // double properties.setProperty(prefix+"sure_sum", this.sure_sum+""); // double
properties.setProperty(prefix+"maybe_avg", this.maybe_avg+""); // double properties.setProperty(prefix+"maybe_avg", this.maybe_avg+""); // double
properties.setProperty(prefix+"shure_avg", this.shure_avg+""); // double properties.setProperty(prefix+"sure_avg", this.sure_avg+""); // double
properties.setProperty(prefix+"max_search_rms", this.max_search_rms+""); // double
properties.setProperty(prefix+"maybe_fom", this.maybe_fom+""); // double
properties.setProperty(prefix+"sure_fom", this.sure_fom+""); // double
properties.setProperty(prefix+"use_combo_dsi", this.use_combo_dsi+""); // boolean properties.setProperty(prefix+"use_combo_dsi", this.use_combo_dsi+""); // boolean
properties.setProperty(prefix+"use_lma_dsi", this.use_lma_dsi+""); // boolean properties.setProperty(prefix+"use_lma_dsi", this.use_lma_dsi+""); // boolean
properties.setProperty(prefix+"fpn_remove", this.fpn_remove+""); // boolean
properties.setProperty(prefix+"fpn_max_offset", this.fpn_max_offset+""); // double
properties.setProperty(prefix+"fpn_radius", this.fpn_radius+""); // double
properties.setProperty(prefix+"fpn_ignore_border", this.fpn_ignore_border+""); // boolean
properties.setProperty(prefix+"mov_en", this.mov_en+""); // boolean properties.setProperty(prefix+"mov_en", this.mov_en+""); // boolean
properties.setProperty(prefix+"mov_sigma", this.mov_sigma+""); // double properties.setProperty(prefix+"mov_sigma", this.mov_sigma+""); // double
properties.setProperty(prefix+"mov_max_std", this.mov_max_std+""); // double properties.setProperty(prefix+"mov_max_std", this.mov_max_std+""); // double
...@@ -1295,12 +1373,17 @@ public class IntersceneMatchParameters { ...@@ -1295,12 +1373,17 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"centroid_radius")!=null) this.centroid_radius=Double.parseDouble(properties.getProperty(prefix+"centroid_radius")); if (properties.getProperty(prefix+"centroid_radius")!=null) this.centroid_radius=Double.parseDouble(properties.getProperty(prefix+"centroid_radius"));
if (properties.getProperty(prefix+"n_recenter")!=null) this.n_recenter=Integer.parseInt(properties.getProperty(prefix+"n_recenter")); if (properties.getProperty(prefix+"n_recenter")!=null) this.n_recenter=Integer.parseInt(properties.getProperty(prefix+"n_recenter"));
if (properties.getProperty(prefix+"min_ref_str")!=null) this.min_ref_str=Double.parseDouble(properties.getProperty(prefix+"min_ref_str"));
if (properties.getProperty(prefix+"td_weight")!=null) this.td_weight=Double.parseDouble(properties.getProperty(prefix+"td_weight")); if (properties.getProperty(prefix+"td_weight")!=null) this.td_weight=Double.parseDouble(properties.getProperty(prefix+"td_weight"));
if (properties.getProperty(prefix+"pd_weight")!=null) this.pd_weight=Double.parseDouble(properties.getProperty(prefix+"pd_weight")); if (properties.getProperty(prefix+"pd_weight")!=null) this.pd_weight=Double.parseDouble(properties.getProperty(prefix+"pd_weight"));
if (properties.getProperty(prefix+"td_nopd_only")!=null) this.td_nopd_only=Boolean.parseBoolean(properties.getProperty(prefix+"td_nopd_only")); if (properties.getProperty(prefix+"td_nopd_only")!=null) this.td_nopd_only=Boolean.parseBoolean(properties.getProperty(prefix+"td_nopd_only"));
if (properties.getProperty(prefix+"min_str")!=null) this.min_str=Double.parseDouble(properties.getProperty(prefix+"min_str")); if (properties.getProperty(prefix+"min_str")!=null) this.min_str=Double.parseDouble(properties.getProperty(prefix+"min_str"));
if (properties.getProperty(prefix+"min_str_fpn")!=null) this.min_str_fpn=Double.parseDouble(properties.getProperty(prefix+"min_str_fpn"));
if (properties.getProperty(prefix+"min_str_sum")!=null) this.min_str_sum=Double.parseDouble(properties.getProperty(prefix+"min_str_sum")); if (properties.getProperty(prefix+"min_str_sum")!=null) this.min_str_sum=Double.parseDouble(properties.getProperty(prefix+"min_str_sum"));
if (properties.getProperty(prefix+"min_str_sum_fpn")!=null) this.min_str_sum_fpn=Double.parseDouble(properties.getProperty(prefix+"min_str_sum_fpn"));
if (properties.getProperty(prefix+"min_neibs")!=null) this.min_neibs=Integer.parseInt(properties.getProperty(prefix+"min_neibs")); if (properties.getProperty(prefix+"min_neibs")!=null) this.min_neibs=Integer.parseInt(properties.getProperty(prefix+"min_neibs"));
if (properties.getProperty(prefix+"weight_zero_neibs")!=null) this.weight_zero_neibs=Double.parseDouble(properties.getProperty(prefix+"weight_zero_neibs")); if (properties.getProperty(prefix+"weight_zero_neibs")!=null) this.weight_zero_neibs=Double.parseDouble(properties.getProperty(prefix+"weight_zero_neibs"));
if (properties.getProperty(prefix+"half_disparity")!=null) this.half_disparity=Double.parseDouble(properties.getProperty(prefix+"half_disparity")); if (properties.getProperty(prefix+"half_disparity")!=null) this.half_disparity=Double.parseDouble(properties.getProperty(prefix+"half_disparity"));
...@@ -1308,12 +1391,24 @@ public class IntersceneMatchParameters { ...@@ -1308,12 +1391,24 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"pix_step")!=null) this.pix_step=Integer.parseInt(properties.getProperty(prefix+"pix_step")); if (properties.getProperty(prefix+"pix_step")!=null) this.pix_step=Integer.parseInt(properties.getProperty(prefix+"pix_step"));
if (properties.getProperty(prefix+"search_rad")!=null) this.search_rad=Integer.parseInt(properties.getProperty(prefix+"search_rad")); if (properties.getProperty(prefix+"search_rad")!=null) this.search_rad=Integer.parseInt(properties.getProperty(prefix+"search_rad"));
if (properties.getProperty(prefix+"maybe_sum")!=null) this.maybe_sum=Double.parseDouble(properties.getProperty(prefix+"maybe_sum")); if (properties.getProperty(prefix+"maybe_sum")!=null) this.maybe_sum=Double.parseDouble(properties.getProperty(prefix+"maybe_sum"));
if (properties.getProperty(prefix+"shure_sum")!=null) this.shure_sum=Double.parseDouble(properties.getProperty(prefix+"shure_sum")); if (properties.getProperty(prefix+"sure_sum")!=null) this.sure_sum=Double.parseDouble(properties.getProperty(prefix+"sure_sum"));
if (properties.getProperty(prefix+"maybe_avg")!=null) this.maybe_avg=Double.parseDouble(properties.getProperty(prefix+"maybe_avg")); if (properties.getProperty(prefix+"maybe_avg")!=null) this.maybe_avg=Double.parseDouble(properties.getProperty(prefix+"maybe_avg"));
if (properties.getProperty(prefix+"shure_avg")!=null) this.shure_avg=Double.parseDouble(properties.getProperty(prefix+"shure_avg")); if (properties.getProperty(prefix+"sure_avg")!=null) this.sure_avg=Double.parseDouble(properties.getProperty(prefix+"sure_avg"));
if (properties.getProperty(prefix+"max_search_rms")!=null) this.max_search_rms=Double.parseDouble(properties.getProperty(prefix+"max_search_rms"));
if (properties.getProperty(prefix+"maybe_fom")!=null) this.maybe_fom=Double.parseDouble(properties.getProperty(prefix+"maybe_fom"));
if (properties.getProperty(prefix+"sure_fom")!=null) this.sure_fom=Double.parseDouble(properties.getProperty(prefix+"sure_fom"));
if (properties.getProperty(prefix+"use_combo_dsi")!=null) this.use_combo_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"use_combo_dsi")); if (properties.getProperty(prefix+"use_combo_dsi")!=null) this.use_combo_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"use_combo_dsi"));
if (properties.getProperty(prefix+"use_lma_dsi")!=null) this.use_lma_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"use_lma_dsi")); if (properties.getProperty(prefix+"use_lma_dsi")!=null) this.use_lma_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"use_lma_dsi"));
if (properties.getProperty(prefix+"fpn_remove")!=null) this.fpn_remove=Boolean.parseBoolean(properties.getProperty(prefix+"fpn_remove"));
if (properties.getProperty(prefix+"fpn_max_offset")!=null) this.fpn_max_offset=Double.parseDouble(properties.getProperty(prefix+"fpn_max_offset"));
if (properties.getProperty(prefix+"fpn_radius")!=null) this.fpn_radius=Double.parseDouble(properties.getProperty(prefix+"fpn_radius"));
if (properties.getProperty(prefix+"fpn_ignore_border")!=null) this.fpn_ignore_border=Boolean.parseBoolean(properties.getProperty(prefix+"fpn_ignore_border"));
if (properties.getProperty(prefix+"mov_en")!=null) this.mov_en=Boolean.parseBoolean(properties.getProperty(prefix+"mov_en")); if (properties.getProperty(prefix+"mov_en")!=null) this.mov_en=Boolean.parseBoolean(properties.getProperty(prefix+"mov_en"));
if (properties.getProperty(prefix+"mov_sigma")!=null) this.mov_sigma=Double.parseDouble(properties.getProperty(prefix+"mov_sigma")); if (properties.getProperty(prefix+"mov_sigma")!=null) this.mov_sigma=Double.parseDouble(properties.getProperty(prefix+"mov_sigma"));
if (properties.getProperty(prefix+"mov_max_std")!=null) this.mov_max_std=Double.parseDouble(properties.getProperty(prefix+"mov_max_std")); if (properties.getProperty(prefix+"mov_max_std")!=null) this.mov_max_std=Double.parseDouble(properties.getProperty(prefix+"mov_max_std"));
...@@ -1474,12 +1569,16 @@ public class IntersceneMatchParameters { ...@@ -1474,12 +1569,16 @@ public class IntersceneMatchParameters {
imp.centroid_radius = this.centroid_radius; imp.centroid_radius = this.centroid_radius;
imp.n_recenter = this.n_recenter; imp.n_recenter = this.n_recenter;
imp.min_ref_str = this.min_ref_str;
imp.td_weight = this.td_weight; imp.td_weight = this.td_weight;
imp.pd_weight = this.pd_weight; imp.pd_weight = this.pd_weight;
imp.td_nopd_only = this.td_nopd_only; imp.td_nopd_only = this.td_nopd_only;
imp.min_str = this.min_str; imp.min_str = this.min_str;
imp.min_str_fpn = this.min_str_fpn;
imp.min_str_sum = this.min_str_sum; imp.min_str_sum = this.min_str_sum;
imp.min_str_sum_fpn = this.min_str_sum_fpn;
imp.min_neibs = this.min_neibs; imp.min_neibs = this.min_neibs;
imp.weight_zero_neibs = this.weight_zero_neibs; imp.weight_zero_neibs = this.weight_zero_neibs;
imp.half_disparity = this.half_disparity; imp.half_disparity = this.half_disparity;
...@@ -1487,12 +1586,22 @@ public class IntersceneMatchParameters { ...@@ -1487,12 +1586,22 @@ public class IntersceneMatchParameters {
imp.pix_step = this.pix_step; imp.pix_step = this.pix_step;
imp.search_rad = this.search_rad; imp.search_rad = this.search_rad;
imp.maybe_sum = this.maybe_sum; imp.maybe_sum = this.maybe_sum;
imp.shure_sum = this.shure_sum; imp.sure_sum = this.sure_sum;
imp.maybe_avg = this.maybe_avg; imp.maybe_avg = this.maybe_avg;
imp.shure_avg = this.shure_avg; imp.sure_avg = this.sure_avg;
imp.max_search_rms = this.max_search_rms;
imp.maybe_fom = this.maybe_fom;
imp.sure_fom = this.sure_fom;
imp.use_combo_dsi = this.use_combo_dsi; imp.use_combo_dsi = this.use_combo_dsi;
imp.use_lma_dsi = this.use_lma_dsi; imp.use_lma_dsi = this.use_lma_dsi;
imp.fpn_remove = this.fpn_remove;
imp.fpn_max_offset = this.fpn_max_offset;
imp.fpn_radius = this.fpn_radius;
imp.fpn_ignore_border = this.fpn_ignore_border;
imp.mov_en = this.mov_en; imp.mov_en = this.mov_en;
imp.mov_sigma = this.mov_sigma; imp.mov_sigma = this.mov_sigma;
imp.mov_max_std = this.mov_max_std; imp.mov_max_std = this.mov_max_std;
......
...@@ -3769,6 +3769,7 @@ public class OpticalFlow { ...@@ -3769,6 +3769,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
null, // double [] ref_disparity, // null or alternative reference disparity null, // double [] ref_disparity, // null or alternative reference disparity
null, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scene_QuadClt, // QuadCLT scene_QuadCLT, scene_QuadClt, // QuadCLT scene_QuadCLT,
scenes_xyzatr[i][0], // xyz scenes_xyzatr[i][0], // xyz
scenes_xyzatr[i][1], // atr scenes_xyzatr[i][1], // atr
...@@ -4131,6 +4132,9 @@ public class OpticalFlow { ...@@ -4131,6 +4132,9 @@ public class OpticalFlow {
test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0); test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0);
final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel; // copied from TQ final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel; // copied from TQ
double min_ref_str = clt_parameters.imp.min_ref_str;
if (reuse_video) { // disable all other options if (reuse_video) { // disable all other options
generate_mapped = false; generate_mapped = false;
export_images = false; export_images = false;
...@@ -4308,6 +4312,14 @@ public class OpticalFlow { ...@@ -4308,6 +4312,14 @@ public class OpticalFlow {
debugLevel-2); debugLevel-2);
} // split cycles to remove output clutter } // split cycles to remove output clutter
int debug_scene = -15; int debug_scene = -15;
boolean [] reliable_ref = null;
if (min_ref_str > 0.0) {
reliable_ref = quadCLTs[ref_index].getReliableTiles( // will be null if does not exist.
min_ref_str, // double min_strength,
true); // boolean needs_lma);
}
for (int scene_index = ref_index - 1; scene_index >= earliest_scene ; scene_index--) { for (int scene_index = ref_index - 1; scene_index >= earliest_scene ; scene_index--) {
if (scene_index == debug_scene) { if (scene_index == debug_scene) {
System.out.println("scene_index = "+scene_index); System.out.println("scene_index = "+scene_index);
...@@ -4320,9 +4332,19 @@ public class OpticalFlow { ...@@ -4320,9 +4332,19 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quadCLTs[ref_index], // QuadCLT reference_QuadClt, quadCLTs[ref_index], // QuadCLT reference_QuadClt,
scene_QuadClt, // QuadCLT scene_QuadClt, scene_QuadClt, // QuadCLT scene_QuadClt,
reliable_ref, // ********* boolean [] reliable_ref,
debugLevel); debugLevel);
if (use_atr == null) { if (use_atr == null) {
earliest_scene = scene_index + 1; earliest_scene = scene_index + 1;
if (debugLevel > -3) {
System.out.println("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + scene_QuadClt.getImageName()+
" spiralSearchATR() FAILED. Setting earliest_scene to "+earliest_scene);
}
// set this and all previous to null
for (; scene_index >= 0 ; scene_index--) {
ers_reference.addScene(quadCLTs[scene_index].getImageName(), null);
}
break; // failed with even first before reference break; // failed with even first before reference
} }
scenes_xyzatr[scene_index] = new double [][] {new double[3], use_atr}; scenes_xyzatr[scene_index] = new double [][] {new double[3], use_atr};
...@@ -4339,6 +4361,7 @@ public class OpticalFlow { ...@@ -4339,6 +4361,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quadCLTs[ref_index], // QuadCLT reference_QuadCLT, quadCLTs[ref_index], // QuadCLT reference_QuadCLT,
null, // double [] ref_disparity, // null or alternative reference disparity null, // double [] ref_disparity, // null or alternative reference disparity
reliable_ref, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scene_QuadClt, // QuadCLT scene_QuadCLT, scene_QuadClt, // QuadCLT scene_QuadCLT,
scenes_xyzatr[scene_index][0], // xyz scenes_xyzatr[scene_index][0], // xyz
scenes_xyzatr[scene_index][1], // atr scenes_xyzatr[scene_index][1], // atr
...@@ -4450,8 +4473,15 @@ public class OpticalFlow { ...@@ -4450,8 +4473,15 @@ public class OpticalFlow {
} }
} }
*/ */
boolean [] reliable_ref = null;
if (min_ref_str > 0.0) {
reliable_ref = quadCLTs[ref_index].getReliableTiles( // will be null if does not exist.
min_ref_str, // double min_strength,
true); // boolean needs_lma);
}
earliest_scene=reAdjustPairsLMAInterscene( // after combo dsi is available and preliminary poses are known earliest_scene=reAdjustPairsLMAInterscene( // after combo dsi is available and preliminary poses are known
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
reliable_ref, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
debugLevel) ; // int debugLevel) debugLevel) ; // int debugLevel)
// should update earliest_scene // should update earliest_scene
...@@ -5442,6 +5472,7 @@ public class OpticalFlow { ...@@ -5442,6 +5472,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quadCLTs[other_ref[1]], // QuadCLT reference_QuadCLT, quadCLTs[other_ref[1]], // QuadCLT reference_QuadCLT,
null, // double [] ref_disparity, // null or alternative reference disparity null, // double [] ref_disparity, // null or alternative reference disparity
null, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
quadCLTs[other_ref[0]], // QuadCLT scene_QuadCLT, quadCLTs[other_ref[0]], // QuadCLT scene_QuadCLT,
scene_xyz_pre, // xyz scene_xyz_pre, // xyz
scene_atr_pre, // atr scene_atr_pre, // atr
...@@ -5450,7 +5481,7 @@ public class OpticalFlow { ...@@ -5450,7 +5481,7 @@ public class OpticalFlow {
lma_rms, // double [] rms, // null or double [2] lma_rms, // double [] rms, // null or double [2]
clt_parameters.imp.max_rms, // double max_rms, clt_parameters.imp.max_rms, // double max_rms,
clt_parameters.imp.debug_level); // 1); // -1); // int debug_level); clt_parameters.imp.debug_level); // 1); // -1); // int debug_level);
System.out.println("lma_rms={"+lma_rms[0]+","+lma_rms[1]+"}"); // System.out.println("lma_rms={"+lma_rms[0]+","+lma_rms[1]+"}");
ImageStack stack_adjusted_color = null; ImageStack stack_adjusted_color = null;
ImageStack stack_adjusted_mono = null; ImageStack stack_adjusted_mono = null;
...@@ -5754,6 +5785,7 @@ public class OpticalFlow { ...@@ -5754,6 +5785,7 @@ public class OpticalFlow {
CLTParameters clt_parameters, CLTParameters clt_parameters,
QuadCLT reference_QuadClt, QuadCLT reference_QuadClt,
QuadCLT scene_QuadClt, QuadCLT scene_QuadClt,
boolean [] reliable_ref,
int debugLevel int debugLevel
) { ) {
int [][] offset_start_corner = {{-1,-1},{1,-1},{1,1},{-1,1}}; //{x,y} int [][] offset_start_corner = {{-1,-1},{1,-1},{1,1},{-1,1}}; //{x,y}
...@@ -5764,14 +5796,21 @@ public class OpticalFlow { ...@@ -5764,14 +5796,21 @@ public class OpticalFlow {
int pix_step = clt_parameters.imp.pix_step; // 4; int pix_step = clt_parameters.imp.pix_step; // 4;
int search_rad = clt_parameters.imp.search_rad; // 10; int search_rad = clt_parameters.imp.search_rad; // 10;
double maybe_sum = clt_parameters.imp.maybe_sum; // 8.0; double maybe_sum = clt_parameters.imp.maybe_sum; // 8.0;
double shure_sum = clt_parameters.imp.shure_sum; // 30.0; double sure_sum = clt_parameters.imp.sure_sum; // 30.0;
double maybe_avg = clt_parameters.imp.maybe_avg; // 0.005; double maybe_avg = clt_parameters.imp.maybe_avg; // 0.005;
double shure_avg = clt_parameters.imp.shure_avg; // 0.015; double sure_avg = clt_parameters.imp.sure_avg; // 0.015;
double max_search_rms = clt_parameters.imp.max_search_rms; // 1.2; // good - 0.34, so-so - 0.999
double maybe_fom = clt_parameters.imp.maybe_fom; // 3.0; // good - 30, second good - 5
double sure_fom = clt_parameters.imp.sure_fom; // 10.0; // good - 30, second good - 10
double [][] pose = new double [2][3]; double [][] pose = new double [2][3];
double angle_per_step = reference_QuadClt.getGeometryCorrection().getCorrVector().getTiltAzPerPixel() * pix_step; double angle_per_step = reference_QuadClt.getGeometryCorrection().getCorrVector().getTiltAzPerPixel() * pix_step;
double [][] atrs = new double [(2*search_rad+1)*(2*search_rad+1)][]; double [][] atrs = new double [(2*search_rad+1)*(2*search_rad+1)][];
double [] confidences_sum = new double [atrs.length]; double [] confidences_sum = new double [atrs.length];
double [] confidences_avg = new double [atrs.length]; double [] confidences_avg = new double [atrs.length];
double [] confidences_fom = new double [atrs.length];
int min_defined = 75;
int rad = 0, dir=0, n=0; int rad = 0, dir=0, n=0;
int ntry = 0; int ntry = 0;
int num_good=0; int num_good=0;
...@@ -5787,7 +5826,7 @@ public class OpticalFlow { ...@@ -5787,7 +5826,7 @@ public class OpticalFlow {
pose[1][0]+ix * angle_per_step, pose[1][0]+ix * angle_per_step,
pose[1][1]+iy * angle_per_step, pose[1][1]+iy * angle_per_step,
pose[1][2]}; pose[1][2]};
if (debugLevel > -2) { if (debugLevel > -1) {
System.out.println("buildSeries(): trying adjustPairsLMA() with initial offset azimuth: "+ System.out.println("buildSeries(): trying adjustPairsLMA() with initial offset azimuth: "+
atr[0]+", tilt ="+atr[1]); atr[0]+", tilt ="+atr[1]);
} }
...@@ -5798,27 +5837,54 @@ public class OpticalFlow { ...@@ -5798,27 +5837,54 @@ public class OpticalFlow {
scene_QuadClt, // QuadCLT scene_QuadCLT, scene_QuadClt, // QuadCLT scene_QuadCLT,
pose[0], // camera_xyz0, // xyz pose[0], // camera_xyz0, // xyz
atr, // camera_atr0, // pose[1], // atr atr, // camera_atr0, // pose[1], // atr
null, // final boolean [] selection, // may be null, if not null do not process unselected tiles reliable_ref, // null, // final boolean [] selection, // may be null, if not null do not process unselected tiles
margin, // final int margin, margin, // final int margin,
sensor_mask_inter, // final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all. sensor_mask_inter, // final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs) facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
null, // final float [][][] dbg_corr_fpn,
false, // boolean near_important, // do not reduce weight of the near tiles
true, // boolean all_fpn, // do not lower thresholds for non-fpn (used during search)
clt_parameters.imp.debug_level, // int imp_debug_level,
clt_parameters.imp.debug_level); // 1); // -1); // int debug_level); clt_parameters.imp.debug_level); // 1); // -1); // int debug_level);
int num_defined = 0; int num_defined = 0;
double sum_strength = 0.0; double sum_strength = 0.0;
// calculate average vector and standard deviation for its components
double swx=0.0,swy = 0.0, swx2 = 0.0, swy2 = 0.0, sw2=0.0 ;
for (int i = 0; i < coord_motion[1].length; i++) if (coord_motion[1][i] != null){ for (int i = 0; i < coord_motion[1].length; i++) if (coord_motion[1][i] != null){
swx += coord_motion[1][i][2] * coord_motion[1][i][0];
swx2 += coord_motion[1][i][2] * coord_motion[1][i][0] * coord_motion[1][i][0];
swy += coord_motion[1][i][2] * coord_motion[1][i][1];
swy2 += coord_motion[1][i][2] * coord_motion[1][i][1] * coord_motion[1][i][1];
sum_strength += coord_motion[1][i][2]; sum_strength += coord_motion[1][i][2];
sw2+=coord_motion[1][i][2]*coord_motion[1][i][2];
num_defined++; num_defined++;
} }
double avg_strength = (num_defined > 0)?(sum_strength/num_defined) : 0; double vx_avg = swx/sum_strength;
double vy_avg = swy/sum_strength;
double l2x = swx2/sum_strength - vx_avg * vx_avg;
double l2y = swy2/sum_strength - vy_avg * vy_avg;
double rms_x = Math.sqrt(l2x);
double rms_y= Math.sqrt(l2y);
double rms = Math.sqrt(l2x+l2y);
double fom = sum_strength/rms/Math.sqrt(0.01 * num_defined); // reduce influence of number defined
double avg_strength = (num_defined > 0)?(sum_strength/num_defined) : 00;
atrs[ntry] = atr; atrs[ntry] = atr;
confidences_sum[ntry] = sum_strength; confidences_sum[ntry] = sum_strength;
confidences_avg[ntry] = avg_strength; confidences_avg[ntry] = avg_strength;
confidences_fom[ntry] = fom;
boolean good = (num_defined > min_defined) && (rms < max_search_rms) && (fom > maybe_fom) && (sum_strength > maybe_sum) && (avg_strength > maybe_avg);
if (debugLevel > -2) { if (debugLevel > -2) {
System.out.println ("ntry = "+ntry+", num_defined = "+num_defined+ System.out.println ((good?"* ":" ")+"ntry = "+ntry+", num_defined = "+num_defined+" ("+min_defined+")"+
", sum_strength = "+sum_strength+", avg_strength = "+avg_strength); ", FOM="+fom+
} ", vx_avg = "+vx_avg+", vy_avg="+vy_avg+
if ((sum_strength > maybe_sum) || (avg_strength > maybe_avg)) { ", sum_strength = "+sum_strength+", rms="+rms+
if ((sum_strength > shure_sum) || (avg_strength > shure_avg)) { ", str2="+Math.sqrt(sw2)+ ", str2_avg="+Math.sqrt(sw2/num_defined)+
", avg_strength = "+avg_strength+
", rms_x="+rms_x+", rms_y="+rms_y);
}
if (good) {
if ((fom > sure_fom) || (sum_strength > sure_sum) || (avg_strength > sure_avg)) {
use_atr = atr; use_atr = atr;
break try_around; break try_around;
} }
...@@ -5836,7 +5902,8 @@ public class OpticalFlow { ...@@ -5836,7 +5902,8 @@ public class OpticalFlow {
if (use_atr == null) { if (use_atr == null) {
int best_ntry = 0; int best_ntry = 0;
for (int i = 1; i < atrs.length; i++) { for (int i = 1; i < atrs.length; i++) {
if (confidences_sum[i] > confidences_sum[best_ntry]) { // if (confidences_sum[i] > confidences_sum[best_ntry]) {
if (confidences_fom[i] > confidences_fom[best_ntry]) {
best_ntry = i; best_ntry = i;
} }
} }
...@@ -6029,6 +6096,7 @@ public class OpticalFlow { ...@@ -6029,6 +6096,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
null, // double [] ref_disparity, // null or alternative reference disparity null, // double [] ref_disparity, // null or alternative reference disparity
null, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scene_QuadClt, // QuadCLT scene_QuadCLT, scene_QuadClt, // QuadCLT scene_QuadCLT,
combo_XYZATR[0], // xyz combo_XYZATR[0], // xyz
combo_XYZATR[1], // atr combo_XYZATR[1], // atr
...@@ -6136,6 +6204,7 @@ public class OpticalFlow { ...@@ -6136,6 +6204,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
null, // double [] ref_disparity, // null or alternative reference disparity null, // double [] ref_disparity, // null or alternative reference disparity
null, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scene_QuadClt, // QuadCLT scene_QuadCLT, scene_QuadClt, // QuadCLT scene_QuadCLT,
combo_XYZATR[0], // xyz combo_XYZATR[0], // xyz
combo_XYZATR[1], // atr combo_XYZATR[1], // atr
...@@ -6275,6 +6344,7 @@ public class OpticalFlow { ...@@ -6275,6 +6344,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
null, // double [] ref_disparity, // null or alternative reference disparity null, // double [] ref_disparity, // null or alternative reference disparity
null, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scenes[i], // QuadCLT scene_QuadCLT, scenes[i], // QuadCLT scene_QuadCLT,
scene_xyz, // combo_XYZATR[0], // xyz scene_xyz, // combo_XYZATR[0], // xyz
scene_atr, // combo_XYZATR[1], // atr scene_atr, // combo_XYZATR[1], // atr
...@@ -9812,11 +9882,6 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -9812,11 +9882,6 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
final double disparity_corr = 0.00; // (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = 0.00; // (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
TpTask[] tp_tasks_ref = null; TpTask[] tp_tasks_ref = null;
for (int nscene = 0; nscene < scenes.length; nscene++) { for (int nscene = 0; nscene < scenes.length; nscene++) {
if (nscene == indx_ref) {
System.out.println("Correlating reference scene, nrefine = "+nrefine);
} else {
System.out.println("Correlating scene "+nrefine+":"+nscene);
}
String ts = scenes[nscene].getImageName(); String ts = scenes[nscene].getImageName();
double [][] scene_pXpYD; double [][] scene_pXpYD;
if (nscene == indx_ref) { if (nscene == indx_ref) {
...@@ -9873,6 +9938,13 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -9873,6 +9938,13 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
scene_pXpYD = scene_pXpYD_prefilter; scene_pXpYD = scene_pXpYD_prefilter;
} }
} }
if (debug_level > -1) {
if (nscene == indx_ref) {
System.out.println("Correlating reference scene, nrefine = "+nrefine);
} else {
System.out.println("Correlating scene "+nrefine+":"+nscene);
}
}
scenes[nscene].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) scenes[nscene].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU)
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(scenes[nscene].isMonochrome()); final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(scenes[nscene].isMonochrome());
final double gpu_sigma_rb_corr = scenes[nscene].isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr; final double gpu_sigma_rb_corr = scenes[nscene].isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
...@@ -11638,6 +11710,139 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11638,6 +11710,139 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
watr_delta[2] = -watr_delta[2]; /// TESTING! watr_delta[2] = -watr_delta[2]; /// TESTING!
return new double [][] {wxyz_delta, watr_delta}; return new double [][] {wxyz_delta, watr_delta};
} }
float [][] getInterCorrOffsetsDebug(
final TpTask[] tp_tasks_ref,
final TpTask[] tp_tasks,
final int tilesX,
final int tilesY
){
final int tiles = tilesX * tilesY;
final float [][] offsets = new float [2*numSens+2][tiles];
final int [] num_inp = new int[tiles];
for (int i = 0; i < offsets.length; i++) {
Arrays.fill(offsets[i], Float.NaN);
}
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile <tp_tasks.length; nTile = ai.getAndIncrement()) {
TpTask task = tp_tasks[nTile];
int tile = task.ty * tilesX + task.tx;
num_inp[tile] = 1;
for (int i = 0; i < numSens; i++) {
offsets[2*i+2][tile] = task.xy[i][0];
offsets[2*i+3][tile] = task.xy[i][1];
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile <tp_tasks_ref.length; nTile = ai.getAndIncrement()) {
TpTask task = tp_tasks_ref[nTile];
int tile = task.ty * tilesX + task.tx;
if (num_inp[tile] == 1) {
num_inp[tile] = 2;
float sx=0,sy=0;
for (int i = 0; i < numSens; i++) {
offsets[2*i+2][tile] -= task.xy[i][0];
offsets[2*i+3][tile] -= task.xy[i][1];
sx += offsets[2*i+2][tile];
sy += offsets[2*i+3][tile];
}
offsets[0][tile] = sx/numSens;
offsets[1][tile] = sy/numSens;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return offsets;
}
/**
* Get average X,Y offsets between inter-scene correlated tiles
* to eliminate correlation between FPN of the same sensor.
* @param max_offset maximal X, Y offset to keep (normally tile size == 8)
* @param tp_tasks_ref reference tiasks (should be updated from GPU to have
* actual X,Y for each sensor
* @param tp_tasks scene correlated to the reference, should also have
* per-sensor coordinates
* @param tilesX number of tile columns
* @param tilesY number of tile rows.
* @return array of X, Y pairs ([tilesX*tilesY][2]), each may be null if
* not defined or out of tile. Returns null if no tiles contain a valid offset
*/
double [][] getInterCorrOffsets(
final double max_offset,
final TpTask[] tp_tasks_ref,
final TpTask[] tp_tasks,
final int tilesX,
final int tilesY
){
final int tiles = tilesX * tilesY;
final double [][] offset_pairs = new double [2*numSens][tiles];
final int [] num_inp = new int[tiles];
for (int i = 0; i < offset_pairs.length; i++) {
Arrays.fill(offset_pairs[i], Float.NaN);
}
double [][] offsets = new double[tiles][];
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile <tp_tasks.length; nTile = ai.getAndIncrement()) {
TpTask task = tp_tasks[nTile];
int tile = task.ty * tilesX + task.tx;
num_inp[tile] = 1;
for (int i = 0; i < numSens; i++) {
offset_pairs[2*i+0][tile] = task.xy[i][0];
offset_pairs[2*i+1][tile] = task.xy[i][1];
}
}
}
};
}
ImageDtt.startAndJoin(threads);
final AtomicInteger anum_pairs = new AtomicInteger(0);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile <tp_tasks_ref.length; nTile = ai.getAndIncrement()) {
TpTask task = tp_tasks_ref[nTile];
int tile = task.ty * tilesX + task.tx;
if (num_inp[tile] == 1) {
num_inp[tile] = 2;
double sx=0,sy=0;
for (int i = 0; i < numSens; i++) {
sx += offset_pairs[2*i+0][tile] - task.xy[i][0];
sy += offset_pairs[2*i+1][tile] - task.xy[i][1];
}
sx /= numSens;
sy /= numSens;
if ((Math.abs(sx) <= max_offset) && (Math.abs(sy) <= max_offset )) {
offsets[tile] = new double[] {sx,sy};
anum_pairs.getAndIncrement();
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
if (anum_pairs.get() > 0) {
return offsets;
}
return null;
}
public double [][][] interCorrPair( // return [tilesX*telesY]{ref_pXpYD, dXdYS} public double [][][] interCorrPair( // return [tilesX*telesY]{ref_pXpYD, dXdYS}
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -11650,23 +11855,32 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11650,23 +11855,32 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
final int margin, final int margin,
final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all. final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs) final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
final float [][] dbg_corr_fpn,
boolean near_important, // do not reduce weight of the near tiles
boolean all_fpn, // do not lower thresholds for non-fpn (used during search)
int imp_debug_level, // MANUALLY change to 2 for debug!
int debug_level) int debug_level)
{ {
TileProcessor tp = ref_scene.getTileProcessor(); TileProcessor tp = ref_scene.getTileProcessor();
// Temporary reusing same ref scene ****** // Temporary reusing same ref scene ******
boolean scene_is_ref_test = clt_parameters.imp.scene_is_ref_test; // false; // true; boolean scene_is_ref_test = clt_parameters.imp.scene_is_ref_test; // false; // true;
boolean show_2d_correlations = clt_parameters.imp.show2dCorrelations(); // true; boolean show_2d_correlations = clt_parameters.imp.show2dCorrelations(imp_debug_level); // true;
boolean show_motion_vectors = clt_parameters.imp.showMotionVectors(); // true; boolean show_motion_vectors = clt_parameters.imp.showMotionVectors(imp_debug_level); // true;
boolean show_render_ref = clt_parameters.imp.renderRef(); // false; //true; boolean show_render_ref = clt_parameters.imp.renderRef(imp_debug_level); // false; //true;
boolean show_render_scene = clt_parameters.imp.renderScene(); // false; // true; boolean show_render_scene = clt_parameters.imp.renderScene(imp_debug_level); // false; // true;
boolean toRGB = clt_parameters.imp.toRGB ; // true; boolean toRGB = clt_parameters.imp.toRGB ; // true;
boolean show_coord_motion = clt_parameters.imp.showCorrMotion(); // mae its own boolean show_coord_motion = clt_parameters.imp.showCorrMotion(imp_debug_level); // mae its own
int erase_clt = (toRGB? clt_parameters.imp.show_color_nan : clt_parameters.imp.show_mono_nan) ? 1:0; int erase_clt = (toRGB? clt_parameters.imp.show_color_nan : clt_parameters.imp.show_mono_nan) ? 1:0;
boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi; boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi;
boolean mov_en = clt_parameters.imp.mov_en; // true; // enable detection/removal of the moving objects during pose matching boolean mov_en = clt_parameters.imp.mov_en; // true; // enable detection/removal of the moving objects during pose matching
boolean mov_debug_images = clt_parameters.imp.showMovementDetection(); boolean mov_debug_images = clt_parameters.imp.showMovementDetection(imp_debug_level);
int mov_debug_level = clt_parameters.imp.movDebugLevel() ; int mov_debug_level = clt_parameters.imp.movDebugLevel(imp_debug_level);
boolean fpn_remove = clt_parameters.imp.fpn_remove;
double fpn_max_offset = clt_parameters.imp.fpn_max_offset;
double fpn_radius = clt_parameters.imp.fpn_radius;
boolean fpn_ignore_border = clt_parameters.imp.fpn_ignore_border; // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
if (scene_is_ref_test) { if (scene_is_ref_test) {
scene_xyz = ZERO3.clone(); scene_xyz = ZERO3.clone();
scene_atr = ZERO3.clone(); scene_atr = ZERO3.clone();
...@@ -11675,6 +11889,14 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11675,6 +11889,14 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
} }
int tilesX = tp.getTilesX(); int tilesX = tp.getTilesX();
int tilesY = tp.getTilesY(); int tilesY = tp.getTilesY();
/*
if (dbg_corr_fpn != null) { // 2*16 or 2*17 (average, individual)
for (int i = 0; i < dbg_corr_fpn.length; i++) {
dbg_corr_fpn[i] = new float [tilesY * tilesX];
Arrays.fill(dbg_corr_fpn[i], Float.NaN);
}
}
*/
double [][][] coord_motion = null; // new double [2][tilesX*tilesY][]; double [][][] coord_motion = null; // new double [2][tilesX*tilesY][];
final double [][][] motion_vectors = show_motion_vectors?new double [tilesY *tilesX][][]:null; final double [][][] motion_vectors = show_motion_vectors?new double [tilesY *tilesX][][]:null;
final float [][][] fclt_corr = ((accum_2d_corr != null) || show_2d_correlations) ? final float [][][] fclt_corr = ((accum_2d_corr != null) || show_2d_correlations) ?
...@@ -11696,7 +11918,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11696,7 +11918,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
if (ref_scene.getGPU() != null) { if (ref_scene.getGPU() != null) {
ref_scene.getGPU().setGpu_debug_level(debug_level - 4); // monitor GPU ops >=-1 ref_scene.getGPU().setGpu_debug_level(debug_level - 4); // monitor GPU ops >=-1
} }
final double disparity_corr = 0.00; // (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = 0.0; // (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
//ref_disparity //ref_disparity
if (ref_disparity == null) { if (ref_disparity == null) {
ref_disparity = ref_scene.getDLS()[use_lma_dsi?1:0]; ref_disparity = ref_scene.getDLS()[use_lma_dsi?1:0];
...@@ -11745,7 +11967,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11745,7 +11967,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
if (ref_scene.hasGPU()) { // direct convert to reference_clt if (ref_scene.hasGPU()) { // direct convert to reference_clt
float [][][][] fcorr_td = null; // no accumulation, use data in GPU float [][][][] fcorr_td = null; // no accumulation, use data in GPU
ref_scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry ref_scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
image_dtt.setReferenceTD( image_dtt.setReferenceTD( // tp_tasks_ref will be updated
erase_clt, erase_clt,
null, // final int [] wh, // null (use sensor dimensions) or pair {width, height} in pixels null, // final int [] wh, // null (use sensor dimensions) or pair {width, height} in pixels
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
...@@ -11802,9 +12024,33 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11802,9 +12024,33 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
imp_render_scene.show(); imp_render_scene.show();
} }
if (dbg_corr_fpn != null) { // 2*16 or 2*17 (average, individual)
float [][] foffsets = getInterCorrOffsetsDebug(
tp_tasks_ref, // final TpTask[] tp_tasks_ref,
tp_tasks, // final TpTask[] tp_tasks,
tilesX, // final int tilesX,
tilesY); // final int tilesY
for (int i = 0; (i < dbg_corr_fpn.length) && (i < foffsets.length); i++) {
dbg_corr_fpn[i] = foffsets[i];
}
}
double [][] fpn_offsets = null;
if (fpn_remove) {
fpn_offsets = getInterCorrOffsets(
fpn_max_offset, // final double max_offset,
tp_tasks_ref, // final TpTask[] tp_tasks_ref,
tp_tasks, // final TpTask[] tp_tasks,
tilesX, // final int tilesX,
tilesY); // final int tilesY);
}
double half_disparity = near_important ? 0.0 : clt_parameters.imp.half_disparity;
double [][][] dcorr_tiles = (fclt_corr != null)? (new double [tp_tasks.length][][]):null; double [][][] dcorr_tiles = (fclt_corr != null)? (new double [tp_tasks.length][][]):null;
// will use num_acc with variable number of accumulations (e.g. clusters) // will use num_acc with variable number of accumulations (e.g. clusters)
//all_fpn
double min_str = all_fpn ? clt_parameters.imp.min_str_fpn : clt_parameters.imp.min_str;
double min_str_sum = all_fpn ? clt_parameters.imp.min_str_sum_fpn : clt_parameters.imp.min_str_sum;
coord_motion = image_dtt.clt_process_tl_interscene( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td coord_motion = image_dtt.clt_process_tl_interscene( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
fcorr_td, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs fcorr_td, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs
...@@ -11818,6 +12064,9 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11818,6 +12064,9 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
// to be converted to float (may be null) // to be converted to float (may be null)
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair_abs, sparse][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair_abs, sparse][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
ref_pXpYD, // final double [][] pXpYD, // pXpYD for the reference scene ref_pXpYD, // final double [][] pXpYD, // pXpYD for the reference scene
fpn_offsets, // final double [][] fpn_offsets, // null, or per-tile X,Y offset to be blanked
fpn_radius, // final double fpn_radius, // radius to be blanked around FPN offset center
fpn_ignore_border, // final boolean fpn_ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
motion_vectors, // final double [][][] motion_vectors, // [tilesY*tilesX][][] -> [][][num_sel_sensors+1][2] motion_vectors, // final double [][][] motion_vectors, // [tilesY*tilesX][][] -> [][][num_sel_sensors+1][2]
clt_parameters.imp.run_poly, // final boolean run_poly, // polynomial max, if false - centroid clt_parameters.imp.run_poly, // final boolean run_poly, // polynomial max, if false - centroid
clt_parameters.imp.use_partial, // final boolean use_partial, // find motion vectors for individual pairs, false - for sum only clt_parameters.imp.use_partial, // final boolean use_partial, // find motion vectors for individual pairs, false - for sum only
...@@ -11826,11 +12075,13 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11826,11 +12075,13 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
clt_parameters.imp.td_weight, // final double td_weight, // mix correlations accumulated in TD with clt_parameters.imp.td_weight, // final double td_weight, // mix correlations accumulated in TD with
clt_parameters.imp.pd_weight, // final double pd_weight, // correlations (post) accumulated in PD clt_parameters.imp.pd_weight, // final double pd_weight, // correlations (post) accumulated in PD
clt_parameters.imp.td_nopd_only, // final boolean td_nopd_only, // only use TD accumulated data if no safe PD is available for the tile. clt_parameters.imp.td_nopd_only, // final boolean td_nopd_only, // only use TD accumulated data if no safe PD is available for the tile.
clt_parameters.imp.min_str, // final double min_str, // = 0.25; min_str, // final double min_str_nofpn, // = 0.25;
clt_parameters.imp.min_str_sum, // final double min_str_sum, // = 0.8; // 5; min_str_sum, // final double min_str_sum_nofpn, // = 0.8; // 5;
clt_parameters.imp.min_str_fpn, // final double min_str, // = 0.25;
clt_parameters.imp.min_str_sum_fpn,// final double min_str_sum, // = 0.8; // 5;
clt_parameters.imp.min_neibs, // final int min_neibs, // 2; // minimal number of strong neighbors (> min_str) clt_parameters.imp.min_neibs, // final int min_neibs, // 2; // minimal number of strong neighbors (> min_str)
clt_parameters.imp.weight_zero_neibs, // final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8) clt_parameters.imp.weight_zero_neibs, // final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8)
clt_parameters.imp.half_disparity, // final double half_disparity, // 5.0; // Reduce weight twice for this disparity half_disparity, // final double half_disparity, // 5.0; // Reduce weight twice for this disparity
clt_parameters.imp.half_avg_diff, // final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice clt_parameters.imp.half_avg_diff, // final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice
clt_parameters.tileX, // final int debug_tileX, clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY, clt_parameters.tileY, // final int debug_tileY,
...@@ -11941,7 +12192,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11941,7 +12192,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
} }
if (show_coord_motion) { if (show_coord_motion) {
//coord_motion //coord_motion
String [] mvTitles = {"dx", "dy", "conf", "pX", "pY","Disp"}; // ,"blurX","blurY", "blur"}; String [] mvTitles = {"dx", "dy", "conf", "pX", "pY","Disp","defined"}; // ,"blurX","blurY", "blur"};
double [][] dbg_img = new double [mvTitles.length][tilesX*tilesY]; double [][] dbg_img = new double [mvTitles.length][tilesX*tilesY];
for (int l = 0; l < dbg_img.length; l++) { for (int l = 0; l < dbg_img.length; l++) {
Arrays.fill(dbg_img[l], Double.NaN); Arrays.fill(dbg_img[l], Double.NaN);
...@@ -11957,6 +12208,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -11957,6 +12208,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
dbg_img[0+i][nTile] = coord_motion[1][nTile][i]; dbg_img[0+i][nTile] = coord_motion[1][nTile][i];
} }
} }
dbg_img[6][nTile] = ((coord_motion[0][nTile] != null)?1:0)+((coord_motion[0][nTile] != null)?2:0);
} }
(new ShowDoubleFloatArrays()).showArrays( // out of boundary 15 (new ShowDoubleFloatArrays()).showArrays( // out of boundary 15
dbg_img, dbg_img,
...@@ -12439,6 +12691,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12439,6 +12691,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
public int reAdjustPairsLMAInterscene( // after combo dgi is available and preliminary poses are known public int reAdjustPairsLMAInterscene( // after combo dgi is available and preliminary poses are known
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean [] reliable_ref, // null or bitmask of reliable reference tiles
QuadCLT [] quadCLTs, QuadCLT [] quadCLTs,
int debugLevel) int debugLevel)
{ {
...@@ -12484,7 +12737,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12484,7 +12737,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
// should have at least next or previous non-null // should have at least next or previous non-null
double maximal_series_rms = 0.00; double maximal_series_rms = 0.00;
for (int nscene = ref_index; nscene > earliest_scene; nscene--) { for (int nscene = ref_index; nscene >= earliest_scene; nscene--) {
if ((quadCLTs[nscene] == null) || if ((quadCLTs[nscene] == null) ||
((nscene != ref_index) && ((nscene != ref_index) &&
((ers_reference.getSceneXYZ(quadCLTs[nscene].getImageName())== null) || ((ers_reference.getSceneXYZ(quadCLTs[nscene].getImageName())== null) ||
...@@ -12545,6 +12798,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12545,6 +12798,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quadCLTs[ref_index], // QuadCLT reference_QuadCLT, quadCLTs[ref_index], // QuadCLT reference_QuadCLT,
interscene_ref_disparity, // double [] ref_disparity, // null or alternative reference disparity interscene_ref_disparity, // double [] ref_disparity, // null or alternative reference disparity
reliable_ref, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
quadCLTs[nscene], // QuadCLT scene_QuadCLT, quadCLTs[nscene], // QuadCLT scene_QuadCLT,
scene_xyz_pre, // xyz scene_xyz_pre, // xyz
scene_atr_pre, // atr scene_atr_pre, // atr
...@@ -12568,7 +12822,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12568,7 +12822,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
break; break;
} }
System.out.println("lma_rms={"+lma_rms[0]+","+lma_rms[1]+"}"); // System.out.println("lma_rms={"+lma_rms[0]+","+lma_rms[1]+"}");
ers_reference.addScene(ts, ers_reference.addScene(ts,
scenes_xyzatr[nscene][0], scenes_xyzatr[nscene][0],
scenes_xyzatr[nscene][1], scenes_xyzatr[nscene][1],
...@@ -12601,6 +12855,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12601,6 +12855,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
CLTParameters clt_parameters, CLTParameters clt_parameters,
QuadCLT reference_QuadClt, QuadCLT reference_QuadClt,
double [] ref_disparity, // null or alternative reference disparity double [] ref_disparity, // null or alternative reference disparity
boolean [] reliable_ref, // null or bitmask of reliable reference tiles
QuadCLT scene_QuadClt, QuadCLT scene_QuadClt,
double [] camera_xyz, double [] camera_xyz,
double [] camera_atr, double [] camera_atr,
...@@ -12621,9 +12876,12 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12621,9 +12876,12 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
double[] camera_xyz0 = camera_xyz.clone(); double[] camera_xyz0 = camera_xyz.clone();
double[] camera_atr0 = camera_atr.clone(); double[] camera_atr0 = camera_atr.clone();
double [][][] coord_motion = null; double [][][] coord_motion = null;
int nlma = 0; boolean show_corr_fpn = debug_level > -1; // -3; *********** Change to debug FPN correleation ***
int nlma = 00;
for (; nlma < clt_parameters.imp.max_cycles; nlma ++) { for (; nlma < clt_parameters.imp.max_cycles; nlma ++) {
//remove outliers (small moving objects) with histogram
boolean near_important = nlma > 0;
coord_motion = interCorrPair( // new double [tilesY][tilesX][][]; coord_motion = interCorrPair( // new double [tilesY][tilesX][][];
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
...@@ -12631,10 +12889,14 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12631,10 +12889,14 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
scene_QuadClt, // QuadCLT scene_QuadCLT, scene_QuadClt, // QuadCLT scene_QuadCLT,
camera_xyz0, // xyz camera_xyz0, // xyz
camera_atr0, // pose[1], // atr camera_atr0, // pose[1], // atr
null, // final boolean [] selection, // may be null, if not null do not process unselected tiles reliable_ref, // ****null, // final boolean [] selection, // may be null, if not null do not process unselected tiles
margin, // final int margin, margin, // final int margin,
sensor_mask_inter, // final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all. sensor_mask_inter, // final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs) facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
null, // final float [][] dbg_corr_fpn,
near_important, // boolean near_important, // do not reduce weight of the near tiles
false, // boolean all_fpn, // do not lower thresholds for non-fpn (used during search)
clt_parameters.imp.debug_level, // int imp_debug_level,
debug_level); // 1); // -1); // int debug_level); debug_level); // 1); // -1); // int debug_level);
if (coord_motion == null) { if (coord_motion == null) {
System.out.println("adjustPairsLMAInterscene() returned null"); System.out.println("adjustPairsLMAInterscene() returned null");
...@@ -12674,6 +12936,83 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad ...@@ -12674,6 +12936,83 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
break; break;
} }
} }
if (show_corr_fpn) { // repeat after last adjustment to get images
String [] fpn_dbg_titles = new String[2 + scene_QuadClt.getNumSensors() * 2];
fpn_dbg_titles[00] = "X_avg";
fpn_dbg_titles[1] = "X_avg";
for (int i = 0; i < scene_QuadClt.getNumSensors(); i++) {
fpn_dbg_titles[2 + 2*i] = "X-"+i;
fpn_dbg_titles[3 + 2*i] = "Y-"+i;
}
float [][] dbg_corr_fpn = new float [fpn_dbg_titles.length][];
coord_motion = interCorrPair( // new double [tilesY][tilesX][][];
clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT,
ref_disparity, // double [] ref_disparity, // null or alternative reference disparity
scene_QuadClt, // QuadCLT scene_QuadCLT,
camera_xyz0, // xyz
camera_atr0, // pose[1], // atr
null, // reliable_ref, // final boolean [] selection, // may be null, if not null do not process unselected tiles
margin, // final int margin,
sensor_mask_inter, // final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
dbg_corr_fpn, // final float [][] dbg_corr_fpn,
true, // boolean near_important, // do not reduce weight of the near tiles
false, // boolean all_fpn, // do not lower thresholds for non-fpn (used during search)
2, // int imp_debug_level,
debug_level); // 1); // -1); // int debug_level);
TileProcessor tp = reference_QuadClt.getTileProcessor();
int tilesX = tp.getTilesX();
int tilesY = tp.getTilesY();
(new ShowDoubleFloatArrays()).showArrays(
dbg_corr_fpn,
tilesX,
tilesY,
true,
scene_QuadClt.getImageName()+"-"+reference_QuadClt.getImageName()+"-CORR-FPN",
fpn_dbg_titles);
}
if (show_corr_fpn) { // repeat after last adjustment to get images
String [] fpn_dbg_titles = new String[2 + scene_QuadClt.getNumSensors() * 2];
fpn_dbg_titles[00] = "X_avg";
fpn_dbg_titles[1] = "X_avg";
for (int i = 0; i < scene_QuadClt.getNumSensors(); i++) {
fpn_dbg_titles[2 + 2*i] = "X-"+i;
fpn_dbg_titles[3 + 2*i] = "Y-"+i;
}
float [][] dbg_corr_fpn = new float [fpn_dbg_titles.length][];
coord_motion = interCorrPair( // new double [tilesY][tilesX][][];
clt_parameters, // CLTParameters clt_parameters,
reference_QuadClt, // QuadCLT reference_QuadCLT,
ref_disparity, // double [] ref_disparity, // null or alternative reference disparity
scene_QuadClt, // QuadCLT scene_QuadCLT,
camera_xyz0, // xyz
camera_atr0, // pose[1], // atr
reliable_ref, // final boolean [] selection, // may be null, if not null do not process unselected tiles
margin, // final int margin,
sensor_mask_inter, // final int sensor_mask_inter, // The bitmask - which sensors to correlate, -1 - all.
facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
dbg_corr_fpn, // final float [][] dbg_corr_fpn,
true, // boolean near_important, // do not reduce weight of the near tiles
false, // boolean all_fpn, // do not lower thresholds for non-fpn (used during search)
2, // int imp_debug_level,
debug_level); // 1); // -1); // int debug_level);
TileProcessor tp = reference_QuadClt.getTileProcessor();
int tilesX = tp.getTilesX();
int tilesY = tp.getTilesY();
(new ShowDoubleFloatArrays()).showArrays(
dbg_corr_fpn,
tilesX,
tilesY,
true,
scene_QuadClt.getImageName()+"-"+reference_QuadClt.getImageName()+"-CORR-FPN",
fpn_dbg_titles);
}
if (clt_parameters.imp.debug_level > -2) { if (clt_parameters.imp.debug_level > -2) {
String [] lines1 = intersceneLma.printOldNew((clt_parameters.imp.debug_level > -1)); // false); // boolean allvectors) String [] lines1 = intersceneLma.printOldNew((clt_parameters.imp.debug_level > -1)); // false); // boolean allvectors)
System.out.println("Adjusted interscene, iteration="+nlma+ System.out.println("Adjusted interscene, iteration="+nlma+
......
...@@ -457,6 +457,36 @@ public class QuadCLTCPU { ...@@ -457,6 +457,36 @@ public class QuadCLTCPU {
silent); silent);
} }
public boolean [] getReliableTiles(
double min_strength,
boolean needs_lma) {
double [][] main_dsi = readDsiMain();
if (main_dsi == null) {
return null;
}
double [] disparity_lma = main_dsi[isAux()?TwoQuadCLT.DSI_DISPARITY_AUX_LMA:TwoQuadCLT.DSI_DISPARITY_MAIN_LMA];
double [] strength = main_dsi[isAux()?TwoQuadCLT.DSI_STRENGTH_AUX:TwoQuadCLT.DSI_STRENGTH_MAIN];
if ((strength == null) || (needs_lma && (disparity_lma == null) )) {
return null;
}
boolean [] reliable = new boolean [strength.length];
for (int i = 0; i < reliable.length; i++) {
reliable[i] = (strength[i] >= min_strength) && (!needs_lma || !Double.isNaN(disparity_lma[i]));
}
return reliable;
}
public double [][] readDsiMain(){
double [][] main_dsi = new double [TwoQuadCLT.DSI_SLICES.length][];
int slices = restoreDSI(
DSI_SUFFIXES[INDEX_DSI_MAIN], // String suffix, // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
main_dsi,
true); // boolean silent)
if (slices < 3) {
return null;
}
return main_dsi;
}
public int restoreDSI( public int restoreDSI(
String suffix, // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX) String suffix, // "-DSI_COMBO", "-DSI_MAIN" (DSI_COMBO_SUFFIX, DSI_MAIN_SUFFIX)
double [][] dsi, double [][] dsi,
......
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