Commit 436cf9c1 authored by Andrey Filippov's avatar Andrey Filippov

testing/debugging multicam correlations

parent 2a0e3035
......@@ -162,6 +162,8 @@ public class Correlation2d {
private static int SUB_SAMPLE = 16; // subsample source pixel in each direction when generating
public static int THREADS_MAX = 100;
// All used pairs (but the diameters) are clockwise (end is clockwise of start)
// Orientation calculations are valid for clockwise only
private void setupPairs() {
int indx = 0;
for (int i = 1; i <= numSensors/2; i++) { // CW length
......@@ -223,9 +225,10 @@ public class Correlation2d {
public boolean [] selectParallel(boolean [] cur_sel, int start, int end) {
boolean [] sel = (cur_sel == null) ? (new boolean[pair_length.length]) : cur_sel;
int n1 = (2 * start + end) % (2 * numSensors);
for (int j = 0; j < pair_start_end.length; j++ ) {
int l = (end + numSensors - start) % numSensors; // CCW pairfs will have l > numSensors/2
int n1 = (2 * start + l ) % (2 * numSensors);
for (int j = 0; j < pair_start_end.length; j++ ) { // lengths are always positive
int n2 = (2 * pair_start_end[j][0] + pair_length[j]) % (2 * numSensors);
if ((n2 - n1) % numSensors == 0) { // only parallel or anti-parallel
sel[j] = true;
......@@ -449,7 +452,8 @@ public class Correlation2d {
cwrot += Math.PI;
}
double pl = 2 * Math.sin(Math.PI* pair_length[num_pair] / numSensors); // length for R=1
double scale = pl/Math.sqrt(2.0)* mcorr_comb_disp; // Math.sqrt(2.0) - relative to side of a square - may be change later?
// double scale = pl/Math.sqrt(2.0)* mcorr_comb_disp; // Math.sqrt(2.0) - relative to side of a square - may be change later?
double scale = pl/2.0* mcorr_comb_disp; // Math.sqrt(2.0) - relative to diameter
Matrix toPair = new Matrix(new double[][] {
{scale * Math.cos(cwrot), -scale*Math.sin(cwrot)},
{scale * Math.sin(cwrot), scale*Math.cos(cwrot)}});
......@@ -558,7 +562,8 @@ public class Correlation2d {
}
double pl = 2 * Math.sin(Math.PI* pair_length[num_pair] / numSensors); // length for R=1
// scale - to get pair (source) radius from combo (destination) radius
double scale = pl/Math.sqrt(2.0)* mcorr_comb_disp; // Math.sqrt(2.0) - relative to side of a square - may be change later?
// double scale = pl/Math.sqrt(2.0)* mcorr_comb_disp; // Math.sqrt(2.0) - relative to side of a square - may be change later?
double scale = pl/2.0* mcorr_comb_disp; // Math.sqrt(2.0) - relative to diameter
Matrix toPair = new Matrix(new double[][] {
{scale * Math.cos(cwrot), -scale*Math.sin(cwrot)},
{scale * Math.sin(cwrot), scale*Math.cos(cwrot)}});
......@@ -2088,7 +2093,7 @@ public class Correlation2d {
* Negative values are ignored!
* Both x and y half-windows can be variable length (to reduce calculations with 0.0 elements), normalized
* so sums of zero element and twice all others are 1.0
* Window in Y direction corresponds to correlation stripe rows, corresponding to sqrt(2)/2 sensor pixels
* Window in Y direction corresponds to correlation strip rows, corresponding to sqrt(2)/2 sensor pixels
* for the largest baseline pairs,
* Window in X direction has the same sqrt(2)/2 step, but it is half of the horizontal steps of the correlation
* results strip
......
......@@ -2424,7 +2424,7 @@ public class ImageDttCPU {
final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
// final double [][][][] clt_corr_combo_in, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [type][tilesY][tilesX] should be set by caller
// types: 0 - selected correlation (product+offset), 1 - sum
......@@ -2493,10 +2493,13 @@ public class ImageDttCPU {
if (correlation2d != null){
// Initialize correlation pairs selection to be used by all threads
boolean [] corr_calculate = null;
if (imgdtt_params.getMcorrAll(numSensors)) corr_calculate = correlation2d.selectAll();
if (imgdtt_params.getMcorrDia(numSensors)) corr_calculate = correlation2d.selectDiameters(corr_calculate);
if (imgdtt_params.getMcorrSq (numSensors)) corr_calculate = correlation2d.selectSquares (corr_calculate);
if (imgdtt_params.getMcorrNeib(numSensors)) corr_calculate = correlation2d.selectNeibs (corr_calculate);
if (imgdtt_params.getMcorrAll (numSensors)) corr_calculate = correlation2d.selectAll();
if (imgdtt_params.getMcorrDia (numSensors)) corr_calculate = correlation2d.selectDiameters (corr_calculate);
if (imgdtt_params.getMcorrSq (numSensors)) corr_calculate = correlation2d.selectSquares (corr_calculate);
if (imgdtt_params.getMcorrNeib(numSensors)) corr_calculate = correlation2d.selectNeibs (corr_calculate);
if (imgdtt_params.getMcorrHor (numSensors)) corr_calculate = correlation2d.selectHorizontal (corr_calculate);
if (imgdtt_params.getMcorrVert(numSensors)) corr_calculate = correlation2d.selectVertical (corr_calculate);
correlation2d.setCorrPairs(corr_calculate); // will limit correlation pairs calculation
correlation2d.generateResample( // should be called before
mcorr_comb_width, // combined correlation tile width
......@@ -2539,6 +2542,13 @@ public class ImageDttCPU {
clt_combo_out[i] = new double[tilesY][tilesX][];
}
}
if (clt_combo_dbg != null) {
boolean [] calc_corr_pairs = correlation2d.getCorrPairs();
for (int i = 0; i < calc_corr_pairs.length; i++) if (calc_corr_pairs[i]){
clt_combo_dbg[i] = new double[tilesY][tilesX][];
}
}
}
final boolean [][] combo_sels = pcombo_sels;
final boolean debug_distort= globalDebugLevel > 0; ///false; // true;
......@@ -3110,6 +3120,17 @@ public class ImageDttCPU {
clt_combo_out[num_comb][tileY][tileX] = corr_combo[num_comb];
}
}
if (clt_combo_dbg != null) { // debug feature, will re-calculate scaled/rotated pairs
for (int num_pair = 0; num_pair < corr_tiles.length; num_pair++) if (corr_tiles[num_pair] != null){
clt_combo_dbg[num_pair][tileY][tileX] = correlation2d.accumulateInit();
correlation2d.accummulatePair(
clt_combo_dbg[num_pair][tileY][tileX], // double [] accum_tile,
corr_tiles[num_pair], // double [] corr_tile,
num_pair, // int num_pair,
1.0); // double weight)
}
}
// calculate CM maximums for all mixed channels
// First get integer correlation center, relative to the center
......
......@@ -4650,6 +4650,7 @@ public class QuadCLTCPU {
// double [][][][][] clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
double [][][][] clt_corr_out = null; // will be used instead of clt_corr_partial
double [][][][] clt_combo_out = null; // will be used instead of clt_corr_combo
double [][][][] clt_combo_dbg = null; // generate partial rotated/scaled pairs
double [][][][] texture_tiles = null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualization mode full 16 or overlapped
double [][] disparity_map = null;
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
......@@ -4669,14 +4670,9 @@ public class QuadCLTCPU {
int num_combo = correlation2d.getComboTitles().length;
clt_corr_out = new double [num_pairs][][][];
clt_combo_out = new double [num_combo][][][];
/*
clt_corr_partial = new double [tilesY][tilesX][][][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
clt_corr_partial[i][j] = null;
}
if (clt_parameters.img_dtt.mcorr_comb_dbg) {
clt_combo_dbg = new double [num_pairs][][][];
}
*/
} // clt_parameters.corr_mismatch = false
disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
}
......@@ -4725,6 +4721,7 @@ public class QuadCLTCPU {
// correlation results
clt_corr_out, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
clt_combo_out, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
clt_combo_dbg, // final double [][][][] clt_combo_dbg, // generate sparse partial rotated/scaled pairs
disparity_map, // [2][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
imp_quad[0].getWidth(), // final int width,
......@@ -4778,6 +4775,8 @@ public class QuadCLTCPU {
+" clt_data[0]["+first_color+"].length="+clt_data[0][first_color].length+" clt_data[0]["+first_color+"][0].length="+
clt_data[0][first_color][0].length);
}
//clt_corr_out = null;
//clt_combo_out = null;
// visualize texture tiles as RGBA slices
double [][] texture_nonoverlap = null;
double [][] texture_overlap = null;
......@@ -5065,6 +5064,27 @@ public class QuadCLTCPU {
}
}
if (!batch_mode && !infinity_corr && (clt_combo_dbg != null)){
if (debugLevel > -2){ // -1
String [] titles = image_dtt.correlation2d.getCorrTitles();
double [][] corr_rslt = ImageDtt.corr_partial_dbg(
clt_combo_dbg, // final double [][][][] corr_data,
clt_parameters.img_dtt.mcorr_comb_width, // final int corr_width,
clt_parameters.img_dtt.mcorr_comb_height, // final int corr_height
threadsMax,
debugLevel);
// titles.length = 15, corr_rslt_partial.length=16!
System.out.println("corr_rslt.length = "+corr_rslt.length+", titles.length = "+titles.length);
sdfa_instance.showArrays( // out of boundary 15
corr_rslt,
tilesX * (clt_parameters.img_dtt.mcorr_comb_width + 1),
tilesY * (clt_parameters.img_dtt.mcorr_comb_height + 1),
true,
image_name+sAux()+"-COMBO-DBG-D"+clt_parameters.disparity,
titles);
}
}
double [][][] iclt_data = new double [clt_data.length][][];
if (!infinity_corr && (clt_parameters.gen_chn_img || clt_parameters.gen_4_img || clt_parameters.gen_chn_stacks)) {
......
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