Commit fd67c744 authored by Andrey Filippov's avatar Andrey Filippov

updating before branching

parent a817f0c0
......@@ -3335,6 +3335,7 @@ public class GpuQuad{ // quad camera description
public TpTask[] setInterTasks(
final boolean calcPortsCoordinatesAndDerivatives, // GPU can calculate them centreXY
final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls)
final boolean [] selection, // may be null, if not null do not process unselected tiles
final GeometryCorrection geometryCorrection,
final double disparity_corr,
final int margin, // do not use tiles if their centers are closer to the edges
......@@ -3346,6 +3347,7 @@ public class GpuQuad{ // quad camera description
img_width, // final int img_width,
calcPortsCoordinatesAndDerivatives, // final boolean calcPortsCoordinatesAndDerivatives, // GPU can calculate them centreXY
pXpYD, // final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls)
selection, // final boolean [] selection, // may be null, if not null do not process unselected tiles
geometryCorrection, // final GeometryCorrection geometryCorrection,
disparity_corr, // final double disparity_corr,
margin, // final int margin, // do not use tiles if their centers are closer to the edges
......@@ -3358,6 +3360,7 @@ public class GpuQuad{ // quad camera description
final int img_width,
final boolean calcPortsCoordinatesAndDerivatives, // GPU can calculate them centreXY
final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls)
final boolean [] selection, // may be null, if not null do not process unselected tiles
final GeometryCorrection geometryCorrection,
final double disparity_corr,
final int margin, // do not use tiles if their centers are closer to the edges
......@@ -3395,9 +3398,7 @@ public class GpuQuad{ // quad camera description
threads[ithread] = new Thread() {
@Override
public void run() {
// for (int indx = ai.getAndIncrement(); indx < tp_tasks.length; indx = ai.getAndIncrement()) {
// int nTile = tile_indices[indx];
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) if (pXpYD[nTile] != null) {
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) if ((pXpYD[nTile] != null) && ((selection == null) || selection[nTile])) {
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
TpTask tp_task = new TpTask(num_cams, tileX, tileY);
......
......@@ -960,7 +960,6 @@ public class ErsCorrection extends GeometryCorrection {
}
if (xyzw[2] > 0) {
xyzw[2] = xyzw[2];
/// return null; // can not match object behind the camera
}
ErsCorrection ers_camera = this;
if (cameraQuadCLT != null) {
......
......@@ -697,6 +697,7 @@ public class ImageDtt extends ImageDttCPU {
TpTask[] tp_tasks = gpuQuad.setInterTasks(
false, // final boolean calcPortsCoordinatesAndDerivatives, // GPU can calculate them centreXY
pXpYD, // final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls)
null, // final boolean [] selection, // may be null, if not null do not process unselected tiles
geometryCorrection, // final GeometryCorrection geometryCorrection,
disparity_corr, // final double disparity_corr,
margin, // final int margin, // do not use tiles if their centers are closer to the edges
......@@ -2308,6 +2309,7 @@ public class ImageDtt extends ImageDttCPU {
return;
}
final double [][] debug_offsets = new double[getNumSensors()][2];
for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
......@@ -2322,6 +2324,13 @@ public class ImageDtt extends ImageDttCPU {
final int corr_size = transform_size * 2 - 1;
final double [][] debug_lma = imgdtt_params.lmamask_dbg? (new double [6][tilesX*tilesY]):null;
if (debug_lma != null) {
for (int i = 0; i < debug_lma.length; i++) {
Arrays.fill(debug_lma[i], Double.NaN);
}
}
// reducing weight of on-axis correlation values to enhance detection of vertical/horizontal lines
// multiply correlation results inside the horizontal center strip 2*enhortho_width - 1 wide by enhortho_scale
......@@ -2422,7 +2431,7 @@ public class ImageDtt extends ImageDttCPU {
}
if (combine_corrs) {
correlation2d.generateResample( // should be called before
correlation2d.generateResample( // should be called before *** This can be done in CPU, table(s) copied to GPU
mcorr_comb_width, // combined correlation tile width
mcorr_comb_height, // combined correlation tile full height
mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
......@@ -2499,7 +2508,7 @@ public class ImageDtt extends ImageDttCPU {
}
}
// get CM disparity/strength
double [] disp_str = {0.0, 0.0}; // dispaprity = 0 will be initial approximation for LMA if no averaging
double [] disp_str = {0.0, 0.0}; // disparity = 0 will be initial approximation for LMA if no averaging
if (combine_corrs) {
double [] corr_combo_tile = correlation2d.accumulateInit(); // combine all available pairs
double sumw = 0.0;
......@@ -2592,6 +2601,13 @@ public class ImageDtt extends ImageDttCPU {
System.out.println("Will run new LMA for tileX="+tileX+", tileY="+tileY);
}
double [] poly_disp = {Double.NaN, 0.0};
double [] debug_lma_tile = (debug_lma != null) ? (new double [debug_lma.length]):null;
if (debug_lma_tile != null) {
for (int i = 0; i < debug_lma.length; i++) {
debug_lma_tile[i] = debug_lma[i][nTile];
}
}
Corr2dLMA lma2 = correlation2d.corrLMA2Single( // null pointer
imgdtt_params, // ImageDttParameters imgdtt_params,
imgdtt_params.lmas_LY_single, // false, // boolean adjust_ly, // adjust Lazy Eye
......@@ -2605,9 +2621,12 @@ public class ImageDtt extends ImageDttCPU {
disp_str, //corr_stat[0], // double xcenter, // preliminary center x in pixels for largest baseline
poly_disp, // double[] poly_ds, // null or pair of disparity/strength
imgdtt_params.ortho_vasw_pwr, // double vasw_pwr, // value as weight to this power,
-2, //0, // tile_lma_debug_level, // +2, // int debug_level,
debug_lma_tile, // double [] debug_lma_tile,
(debugTile0 ? 1: -2), // int debug_level,
// -2, //0, // tile_lma_debug_level, // +2, // int debug_level,
tileX, // int tileX, // just for debug output
tileY ); // int tileY
tileY );
// int tileY
if (debugTile0) { // should be debugTile
System.out.println("Ran LMA for tileX="+tileX+", tileY="+tileY);
}
......@@ -2659,14 +2678,31 @@ public class ImageDtt extends ImageDttCPU {
}
}
}
}
if (debug_lma_tile != null) {
for (int i = 0; i < debug_lma.length; i++) {
debug_lma[i][nTile] = debug_lma_tile[i];
}
}
}
}
}
};
}
startAndJoin(threads);
if (debug_lma != null) {
(new ShowDoubleFloatArrays()).showArrays(
debug_lma,
tilesX,
tilesY,
true,
"lma_debug",
new String[] {"disp_samples","num_cnvx_samples","num_comb_samples", "num_lmas","num_iters","rms"}
);
}
}
return;
}
......
......@@ -77,7 +77,17 @@ public class ImageDttParameters {
public int dbg_pair_mask = 0x3f; // which pairs to combine
public int corr_strip_hight = 9; // number of rows to calculate
//lmamask_
public boolean lmamask_dbg = false; // show LMA images, exit after single BG
public boolean lmamask_en = false; // Use disparity-based LMA samples filter
public double lmamask_magic = 0.85;
public double lmamask_min_main = 0.4;
public double lmamask_min_neib = 0.10;
public double lmamask_weight_neib = 0.75;
public double lmamask_weight_neib_neib = 0.5;
// Extracting bi-convex (convex in both orthogonal directions) cells and allowing non-convex on the selection border only
public boolean cnvx_en = true; // Use convex-based LMA samples filter
public boolean cnvx_or = false; // If both lmamask_en and cnvx_en are available, use max; if false - multiply masks
public int cnvx_hwnd_size = 4; // half window size (both horizontal and vertical to extract bi-convex cells
public double cnvx_weight = 0.5; // relative weight of non-convex (border) cell
public boolean cnvx_add3x3 = true; // always select 3x3 cells around integer maximum
......@@ -439,7 +449,27 @@ public class ImageDttParameters {
gd.addNumericField("Number of correlation rows to combine (strip height)", this.corr_strip_hight, 0, 3, "",
"Number of rows to combine/interpolate correlation results. Rows are twice denser than pixels correponding to largest baseline disparity");
gd.addMessage("LMA samples filter based on estimated disparity");
gd.addCheckbox ("Debug LMA", this.lmamask_dbg,
"Generate debug images and exit after first clt_process_tl_correlations() while generating background image");
gd.addCheckbox ("Use disparity-based LMA samples filtering", this.lmamask_en,
"Generate weighs by averaging 2D correlation shape and per-pair shifting for estimated from CM disparity");
gd.addNumericField("Divide estimated disparity by magic 0.85", this.lmamask_magic, 6,8,"",
"Increase estimated disparity before averaging correlation shape and per-pair shifting the result");
gd.addNumericField("Minimal relative sample value for unconditional inclusion", this.lmamask_min_main, 6,8,"",
"Relatrive (to maximal) value in averaged correlation to be assigned window vlaue of 1.0 regardless of neighbors");
gd.addNumericField("Minimal relative sample value for neighbor inclusion", this.lmamask_min_neib, 6,8,"",
"Minimal relative sample value for conditional inclusion (if it has unconditional neighbor");
gd.addNumericField("Neighbor weight", this.lmamask_weight_neib, 6,8,"",
"Assign window value for strong enough values of neighbors of unconditionally included");
gd.addNumericField("Neighbor of neighbor weights", this.lmamask_weight_neib_neib, 6,8,"",
"Weight of neighbors of conditionally or anconditionally included poins regardless of their values");
gd.addMessage("LMA samples filter based on convex sample values");
gd.addCheckbox ("Use convex-based LMA samples filtering", this.cnvx_en,
"Select LMA samples based on convex correlation samples");
gd.addCheckbox ("'OR' window functions", this.cnvx_or,
"If both lmamask_en and cnvx_en are available, use max(); if false - multiply masks");
gd.addNumericField("Half window size to extract bi-convex cells", this.cnvx_hwnd_size, 0, 3, "pix",
"Create selection mask for quadratic approximation inside square around initial maximum position, specify distance from the center");
gd.addNumericField("Relative weight of non-convex (border) cell", this.cnvx_weight, 6,8,"",
......@@ -826,7 +856,16 @@ public class ImageDttParameters {
this.dbg_pair_mask= (int) gd.getNextNumber();
this.corr_strip_hight= (int) gd.getNextNumber();
this.lmamask_dbg = gd.getNextBoolean();
this.lmamask_en = gd.getNextBoolean();
this.lmamask_magic = gd.getNextNumber();
this.lmamask_min_main = gd.getNextNumber();
this.lmamask_min_neib = gd.getNextNumber();
this.lmamask_weight_neib = gd.getNextNumber();
this.lmamask_weight_neib_neib = gd.getNextNumber();
this.cnvx_en = gd.getNextBoolean();
this.cnvx_or = gd.getNextBoolean();
this.cnvx_hwnd_size= (int) gd.getNextNumber();
this.cnvx_weight = gd.getNextNumber();
this.cnvx_add3x3 = gd.getNextBoolean();
......@@ -1035,6 +1074,15 @@ public class ImageDttParameters {
properties.setProperty(prefix+"dbg_pair_mask", this.dbg_pair_mask +"");
properties.setProperty(prefix+"corr_strip_hight", this.corr_strip_hight +"");
properties.setProperty(prefix+"lmamask_dbg", this.lmamask_dbg +"");
properties.setProperty(prefix+"lmamask_en", this.lmamask_en +"");
properties.setProperty(prefix+"lmamask_magic", this.lmamask_magic +"");
properties.setProperty(prefix+"lmamask_min_main", this.lmamask_min_main +"");
properties.setProperty(prefix+"lmamask_min_neib", this.lmamask_min_neib +"");
properties.setProperty(prefix+"lmamask_weight_neib", this.lmamask_weight_neib +"");
properties.setProperty(prefix+"lmamask_weight_neib_neib", this.lmamask_weight_neib_neib +"");
properties.setProperty(prefix+"cnvx_en", this.cnvx_en +"");
properties.setProperty(prefix+"cnvx_or", this.cnvx_or +"");
properties.setProperty(prefix+"cnvx_hwnd_size", this.cnvx_hwnd_size +"");
properties.setProperty(prefix+"cnvx_weight", this.cnvx_weight +"");
properties.setProperty(prefix+"cnvx_add3x3", this.cnvx_add3x3 +"");
......@@ -1248,6 +1296,17 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"dbg_pair_mask")!=null) this.dbg_pair_mask=Integer.parseInt(properties.getProperty(prefix+"dbg_pair_mask"));
if (properties.getProperty(prefix+"corr_strip_hight")!=null) this.corr_strip_hight=Integer.parseInt(properties.getProperty(prefix+"corr_strip_hight"));
if (properties.getProperty(prefix+"lmamask_dbg")!=null) this.lmamask_dbg=Boolean.parseBoolean(properties.getProperty(prefix+"lmamask_dbg"));
if (properties.getProperty(prefix+"lmamask_en")!=null) this.lmamask_en=Boolean.parseBoolean(properties.getProperty(prefix+"lmamask_en"));
if (properties.getProperty(prefix+"lmamask_magic")!=null) this.lmamask_magic=Double.parseDouble(properties.getProperty(prefix+"lmamask_magic"));
if (properties.getProperty(prefix+"lmamask_min_main")!=null) this.lmamask_min_main=Double.parseDouble(properties.getProperty(prefix+"lmamask_min_main"));
if (properties.getProperty(prefix+"lmamask_min_neib")!=null) this.lmamask_min_neib=Double.parseDouble(properties.getProperty(prefix+"lmamask_min_neib"));
if (properties.getProperty(prefix+"lmamask_weight_neib")!=null) this.lmamask_weight_neib=Double.parseDouble(properties.getProperty(prefix+"lmamask_weight_neib"));
if (properties.getProperty(prefix+"lmamask_weight_neib_neib")!=null) this.lmamask_weight_neib_neib=Double.parseDouble(properties.getProperty(prefix+"lmamask_weight_neib_neib"));
if (properties.getProperty(prefix+"cnvx_en")!=null) this.cnvx_en=Boolean.parseBoolean(properties.getProperty(prefix+"cnvx_en"));
if (properties.getProperty(prefix+"cnvx_or")!=null) this.cnvx_or=Boolean.parseBoolean(properties.getProperty(prefix+"cnvx_or"));
if (properties.getProperty(prefix+"cnvx_hwnd_size")!=null) this.cnvx_hwnd_size=Integer.parseInt(properties.getProperty(prefix+"cnvx_hwnd_size"));
if (properties.getProperty(prefix+"cnvx_weight")!=null) this.cnvx_weight=Double.parseDouble(properties.getProperty(prefix+"cnvx_weight"));
if (properties.getProperty(prefix+"cnvx_add3x3")!=null) this.cnvx_add3x3=Boolean.parseBoolean(properties.getProperty(prefix+"cnvx_add3x3"));
......@@ -1477,6 +1536,15 @@ public class ImageDttParameters {
idp.dbg_pair_mask= this.dbg_pair_mask;
idp.corr_strip_hight= this.corr_strip_hight;
idp.lmamask_dbg= this.lmamask_dbg;
idp.lmamask_en= this.lmamask_en;
idp.lmamask_magic= this.lmamask_magic;
idp.lmamask_min_main= this.lmamask_min_main;
idp.lmamask_min_neib= this.lmamask_min_neib;
idp.lmamask_weight_neib= this.lmamask_weight_neib;
idp.lmamask_weight_neib_neib= this.lmamask_weight_neib_neib;
idp.cnvx_en= this.cnvx_en;
idp.cnvx_or= this.cnvx_or;
idp.cnvx_hwnd_size= this.cnvx_hwnd_size;
idp.cnvx_weight= this.cnvx_weight;
idp.cnvx_add3x3= this.cnvx_add3x3;
......
......@@ -3892,6 +3892,7 @@ public class QuadCLT extends QuadCLTCPU {
TpTask[] tp_tasks = gpuQuad.setInterTasks(
false, // final boolean calcPortsCoordinatesAndDerivatives, // GPU can calculate them centreXY
pXpYD, // final double [][] pXpYD, // per-tile array of pX,pY,disparity triplets (or nulls)
null, // final boolean [] selection, // may be null, if not null do not process unselected tiles
geometryCorrection, // final GeometryCorrection geometryCorrection,
disparity_corr, // final double disparity_corr,
margin, // final int margin, // do not use tiles if their centers are closer to the edges
......
......@@ -8253,6 +8253,12 @@ public class QuadCLTCPU {
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (clt_parameters.img_dtt.lmamask_dbg) {
System.out.println("Remove me - QCC8257");
return false;
}
tp.clt_3d_passes.add(bgnd_data);
// if (show_init_refine)
// if ((debugLevel > -2) && clt_parameters.show_first_bg) {
......@@ -12026,7 +12032,8 @@ public class QuadCLTCPU {
d = ImageDtt.setPairMask(d,0xf);
d = ImageDtt.setForcedDisparity(d,true);
int [][] tile_op = tp.setSameTileOp(clt_parameters, d, debugLevel);
double [][] disparity_array = tp.setSameDisparity(0.0); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity
double disparity0 = 0.0;
double [][] disparity_array = tp.setSameDisparity(disparity0); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity
scan.disparity = disparity_array;
scan.tile_op = tile_op;
CLTPass3d scan_rslt = CLTMeas( // perform single pass according to prepared tiles operations and disparity // USED in lwir
......@@ -12976,6 +12983,7 @@ public class QuadCLTCPU {
// When clt_mismatch is non-zero, no far objects extraction will be attempted
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
// REMOVE 'true'
clt_parameters.correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
// define combining of all 2D correlation pairs for CM (LMA does not use them)
clt_parameters.img_dtt.mcorr_comb_width, //final int mcorr_comb_width, // combined correlation tile width (set <=0 to skip combined correlations)
......@@ -12986,7 +12994,7 @@ public class QuadCLTCPU {
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
threadsMax, // final int threadsMax, // maximal number of threads to launch
debugLevel + 2+0); // -1 ); // final int globalDebugLevel)
debugLevel + 2+1); // -1 ); // final int globalDebugLevel)
} else {
image_dtt.clt_process_tl_correlations( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
......
......@@ -11766,6 +11766,11 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevelInner);
if (clt_parameters.img_dtt.lmamask_dbg) {
System.out.println("Remove me - TQC11770");
return;
}
if (quadCLT_main.correctionsParameters.clt_batch_dsi_aux_full) {
if (updateStatus) IJ.showStatus("Expanding DSI for the aux camera image set "+quadCLT_main.image_name+" (for DSI export)");
quadCLT_aux.expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
......
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