Commit 7d8c844a authored by Andrey Filippov's avatar Andrey Filippov

working on ranging

parent 6e5b9835
......@@ -530,7 +530,9 @@ public class CuasRanging {
tilesX,
tilesY,
true,
center_CLT.getImageName()+"accumulated_disparity_map-"+nrefine,
center_CLT.getImageName()+"-accumulated_disparity_map_R"+clt_parameters.imp.cuas_rng_radius+"-F"+
(cuasMotion.getFrameCenter(nseq))+":"+nrefine+"-M"+clt_parameters.imp.cuas_mcorr_sel+
"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
ImageDtt.getDisparityTitles(center_CLT.getNumSensors(),center_CLT.isMonochrome()) // ImageDtt.DISPARITY_TITLES
);
}
......@@ -592,6 +594,8 @@ public class CuasRanging {
final double gpu_sigma_corr = clt_parameters.getGpuCorrSigma(center_CLT.isMonochrome());
final double gpu_sigma_rb_corr = center_CLT.isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(center_CLT.isMonochrome());
final int frame_center = cuasMotion.getFrameCenter(nseq);
final int half_accum_range = cuasMotion.getSeqLength()/2;
......@@ -623,6 +627,18 @@ public class CuasRanging {
final int tilesY = center_CLT.getTilesY();
final int sensor_mask = -1; // all sensors
final int num_sens = center_CLT.getNumSensors();
ImageDttParameters imgdtt_params = null;
try {
imgdtt_params = clt_parameters.img_dtt.clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgdtt_params.updateFromCuas(clt_parameters.imp, num_sens);
boolean show_um = false; // true;
if (show_um) {
String [] titles_sensors = new String[img_um_seq[0].length];
......@@ -644,7 +660,7 @@ public class CuasRanging {
}
final int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,num_sens);
final int mcorr_sel = ImageDttParameters.corrSelEncode(imgdtt_params,num_sens);
ErsCorrection ers_reference = center_CLT.getErsCorrection();
int num_used_sens = 0;
for (int i = 0; i < num_sens; i++) if (((sensor_mask >> i) & 1) != 0) num_used_sens++;
......@@ -663,14 +679,6 @@ public class CuasRanging {
(new float [tilesX * tilesY][][]) : null;
final boolean use_rms = true; // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023) (from OF11168: boolean use_rms = true; )
final boolean no_map = false;
ImageDttParameters imgdtt_params = null;
try {
imgdtt_params = clt_parameters.img_dtt.clone();
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgdtt_params.updateFromCuas(clt_parameters.imp, num_sens);
ImageDtt image_dtt = new ImageDtt(
center_CLT.getNumSensors(),
......@@ -786,7 +794,7 @@ public class CuasRanging {
}
float [][][][] fcorr_td = new float[tilesY][tilesX][][];
image_dtt.quadCorrTD(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
imgdtt_params, // clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
tp_tasks[0], // *** will be updated inside from GPU-calculated geometry
fcorr_td, // fcorrs_td[nscene], // [tilesY][tilesX][pair][4*64] transform domain representation of 6 corr pairs
clt_parameters.gpu_sigma_r, // 0.9, 1.1
......@@ -882,10 +890,10 @@ public class CuasRanging {
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
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)
clt_parameters.img_dtt.mcorr_comb_height,//final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset,//final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp, //final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
imgdtt_params.mcorr_comb_width, //final int mcorr_comb_width, // combined correlation tile width (set <=0 to skip combined correlations)
imgdtt_params.mcorr_comb_height,//final int mcorr_comb_height, // combined correlation tile full height
imgdtt_params.mcorr_comb_offset,//final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
imgdtt_params.mcorr_comb_disp, //final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.clt_window, // final int window_type, // GPU: will not be used
clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY,
......@@ -923,7 +931,8 @@ public class CuasRanging {
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
center_CLT.getImageName()+"-CORR-ACCUM_R"+clt_parameters.imp.cuas_rng_radius+"-F"+frame_center+":"+nrefine+"-M"+mcorr_sel,
center_CLT.getImageName()+"-CORR-ACCUM_R"+clt_parameters.imp.cuas_rng_radius+
"-F"+frame_center+":"+nrefine+"-M"+mcorr_sel+"-"+clt_parameters.imp.cuas_mcorr_sel_lma,
titles); // image_dtt.getCorrelation2d().getCorrTitles()); //CORR_TITLES);
}
}
......@@ -1059,6 +1068,7 @@ public class CuasRanging {
ImageDtt.startAndJoin(threads);
return sensors_xy;
}
public static double [][] copyMaskedTargets ( // [sensor][pixel]
final double radius,
final double radius_blur,
......
......@@ -75,7 +75,7 @@ public class Correlation2d {
// 1: 2 sensors - horizontal diameter, sensors 4,12
// 2: 4 sensors - original quad selection, sensors 2,6,10,14
// 3: 8 sensors - 0,2,4,6,8,10,12,14
/*
public static int corrSelEncode(
boolean sel_all,
boolean sel_dia,
......@@ -92,6 +92,7 @@ public class Correlation2d {
(sel_vert ? (1 << CORR_SEL_BIT_VERT): 0) |
((limit_sensors & ((1 << CORR_SEL_BITS_LIMIT) - 1)) << CORR_SEL_BIT_LIMIT);
}
*/
public static boolean isCorrAll (int sel) { return ((sel >> CORR_SEL_BIT_ALL) & 1) != 0;}
public static boolean isCorrDia (int sel) { return ((sel >> CORR_SEL_BIT_DIA) & 1) != 0;}
public static boolean isCorrSq (int sel) { return ((sel >> CORR_SEL_BIT_SQ) & 1) != 0;}
......@@ -99,9 +100,9 @@ public class Correlation2d {
public static boolean isCorrHor (int sel) { return ((sel >> CORR_SEL_BIT_HOR) & 1) != 0;}
public static boolean isCorrVert(int sel) { return ((sel >> CORR_SEL_BIT_VERT) & 1) != 0;}
public static int getSensorsLimit(int sel){ return ((sel >> CORR_SEL_BIT_LIMIT) & ((1 << CORR_SEL_BITS_LIMIT) - 1));}
/*
public static int corrSelEncode(ImageDttParameters img_dtt, int num_sensors) {
return corrSelEncode(
return ImageDttParameters.corrSelEncode(
img_dtt.getMcorrAll (num_sensors), // boolean sel_all,
img_dtt.getMcorrDia (num_sensors), // boolean sel_dia,
img_dtt.getMcorrSq (num_sensors), // boolean sel_sq,
......@@ -110,18 +111,7 @@ public class Correlation2d {
img_dtt.getMcorrVert (num_sensors), // boolean sel_vert);
img_dtt.mcorr_limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
}
public static int corrSelEncodeAll(int limit_sensors) { // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
return corrSelEncode(
true, // boolean sel_all,
false, // boolean sel_dia,
false, // boolean sel_sq,
false, // boolean sel_neib,
false, // boolean sel_hor,
false, // boolean sel_vert);
limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
}
*/
// configuration for 8-lens and 4-lens cameras. 8-lens has baseline = 1 for 1..4 and 1/2 for 4..7
/*0 1
......
......@@ -460,7 +460,7 @@ public class ImageDtt extends ImageDttCPU {
// does it need correlations?
if (fneed_corr) {
int mcorr_sel = Correlation2d.corrSelEncode(imgdtt_params,numSensors);
int mcorr_sel = ImageDttParameters.corrSelEncode(imgdtt_params,numSensors);
int [] i_mcorr_sel = Correlation2d.intCorrPairs(
mcorr_sel,
numSensors,
......@@ -3051,6 +3051,9 @@ public class ImageDtt extends ImageDttCPU {
final boolean debug_stuck = false; // true;
final double disparity_scale = 1.0/Math.sqrt(2); // combo pixels -> disparity pixels
final boolean diameters_combo = (imgdtt_params.mcorr_dual_fract > 0.0); // add diameters-only combo after all-combo
final int mcorr_sel_lma = imgdtt_params.mcorr_sel_lma; // was equivalent to 1 - all before 09/2025
final boolean [] selected_lma = Correlation2d.boolCorrPairs(mcorr_sel_lma, correlation2d.getNumSensors());
if (this.gpuQuad == null) {
System.out.println("clt_aberrations_quad_corr_GPU(): this.gpuQuad is null, bailing out");
return;
......@@ -3486,7 +3489,8 @@ public class ImageDtt extends ImageDttCPU {
disp_dist,
rXY, // double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
// all that are not null in corr_tiles
correlation2d.selectAll(), // longToArray(imgdtt_params.dbg_pair_mask), // int pair_mask, // which pairs to process
// correlation2d.selectAll(), // longToArray(imgdtt_params.dbg_pair_mask), // int pair_mask, // which pairs to process
selected_lma, // boolean [] pair_mask, // which pairs to process
maxes, //double[][] disp_str_dual, // -preliminary center x in pixels for largest baseline
null, // debug_lma_tile, // double [] debug_lma_tile,
(debugTile0 ? 1: -2), // int debug_level,
......
......@@ -37,6 +37,10 @@ public class ImageDttParameters {
public static final int CORR_SEL_BIT_LIMIT = 8;
public static final int CORR_SEL_BITS_LIMIT = 3;
// Debug feature to limit selections to:
// 1: 2 sensors - horizontal diameter, sensors 4,12
// 2: 4 sensors - original quad selection, sensors 2,6,10,14
// 3: 8 sensors - 0,2,4,6,8,10,12,14
......@@ -411,7 +415,11 @@ public class ImageDttParameters {
public int corrSelEncode(ImageDttParameters img_dtt, int num_sensors) {
public static int corrSelEncode(ImageDttParameters img_dtt, int num_sensors) {
return img_dtt.corrSelEncode(num_sensors);
}
public int corrSelEncode(int num_sensors) {
return corrSelEncode(
getMcorrAll (num_sensors), // boolean sel_all,
getMcorrDia (num_sensors), // boolean sel_dia,
......@@ -419,9 +427,11 @@ public class ImageDttParameters {
getMcorrNeib (num_sensors), // boolean sel_neib,
getMcorrHor (num_sensors), // boolean sel_hor,
getMcorrVert (num_sensors), // boolean sel_vert);
mcorr_limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
mcorr_limit_sensors); // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
}
public static int corrSelEncodeAll(int limit_sensors) { // 0 - no limit, 1 - (4,12) 2 - (2, 6, 10, 14), 3 - (0,2,4,6,8,10,12,14)
return corrSelEncode(
true, // boolean sel_all,
......
......@@ -5328,7 +5328,7 @@ public class Interscene {
if (use3D) { //(scene_disparity_strength != null)
final boolean [] valid_tiles = new boolean[tilesX * tilesY]; // or use null?
float [][][][] fcorr_td = new float[tilesY][tilesX][][];
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, scene.getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, scene.getNumSensors());
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(scene.getNumSensors(), scene.isMonochrome()).length][];
TpTask[] tp_tasks_disp = GpuQuad.setInterTasks( // just to calculate valid_tiles
scene.getNumSensors(),
......
......@@ -888,7 +888,7 @@ public class MultisceneLY {
}
final TpTask[][] tp_tasks_scenes = new TpTask[num_scenes][];
image_dtt.getCorrelation2d(); // initiate image_dtt.correlation2d, needed if disparity_map != null
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, last_scene.getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, last_scene.getNumSensors());
for (int nscene = 0; nscene < num_scenes; nscene++) {
QuadCLT scene = scenes[nscene];
......
......@@ -9688,7 +9688,7 @@ public class OpticalFlow {
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
disparity_map = correlateInterscene(
clt_parameters, // final CLTParameters clt_parameters,
......@@ -10357,7 +10357,7 @@ public class OpticalFlow {
}
}
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,num_sensors);
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt,num_sensors);
double [][] disparity_map =
correlateInterscene( // should skip scenes w/o orientation 06/29/2022
clt_parameters, // final CLTParameters clt_parameters,
......@@ -11274,7 +11274,7 @@ public class OpticalFlow {
}
}
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,num_sensors);
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt,num_sensors);
boolean show_dbg_img = true;
/*if (need_fix_sky) {
......@@ -12306,7 +12306,7 @@ public class OpticalFlow {
}
if (save_accum) {
int mcorr_sel = Correlation2d.corrSelEncodeAll(0); // all sensors
int mcorr_sel = ImageDttParameters.corrSelEncodeAll(0); // all sensors
float [][][] facc_2d_img = new float [1][][];
// FIXME?: should work with non-matched
boolean no_map = true;
......@@ -12849,7 +12849,7 @@ public class OpticalFlow {
}
}
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
// FIXME: null, // final boolean [] selection, // may be null, if not null do not process unselected tiles
double [][] disparity_map =
correlateInterscene(
......@@ -13971,7 +13971,7 @@ public class OpticalFlow {
/// final ErsCorrection ers_reference = ref_scene.getErsCorrection();
final int tilesX = ref_scene.getTileProcessor().getTilesX();
final int tilesY = ref_scene.getTileProcessor().getTilesY();
int mcorr_sel = Correlation2d.corrSelEncodeAll(0); // all sensors
int mcorr_sel = ImageDttParameters.corrSelEncodeAll(0); // all sensors
final float [][][] fclt_corr = new float [tilesX * tilesY][][];
ImageDtt image_dtt;
......
......@@ -3713,7 +3713,7 @@ public class QuadCLT extends QuadCLTCPU {
true,
"fclt"); // , dbg_titles);
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
if (test_execCorr2D) {
int [] i_mcorr_sel = Correlation2d.intCorrPairs(
......@@ -4350,7 +4350,7 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.gpu_corr_rad); // int corr_rad);
// calculate correlations, keep TD
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,quadCLT_main.getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt,quadCLT_main.getNumSensors());
int [] i_mcorr_sel = Correlation2d.intCorrPairs(
mcorr_sel,
quadCLT_main.getNumSensors(),
......
......@@ -10543,7 +10543,7 @@ public class QuadCLTCPU {
}
//getNumSensors()
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
// if (debugLevel > 1000) texture_tiles = null; // FIXME: until texture generation for multi-cam is fixed
double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
......@@ -17444,7 +17444,7 @@ public class QuadCLTCPU {
}
}
double [][][] fine_corr = (clt_parameters.fcorr_ignore? null: this.fine_corr);
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
if (clust_radius > 0) {
if (use_tilted) { // always
image_dtt.clt_aberrations_quad_corr_tilted(
......@@ -17711,7 +17711,7 @@ public class QuadCLTCPU {
}
}
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
int mcorr_sel = ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
......@@ -17861,7 +17861,7 @@ public class QuadCLTCPU {
}
final double disparity_corr = (z_correction == 0) ? clt_parameters.imp.disparity_corr : geometryCorrection.getDisparityFromZ(1.0/z_correction);
int mcorr_sel = save_corr ? Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors()) : 0;
int mcorr_sel = save_corr ? ImageDttParameters.corrSelEncode(clt_parameters.img_dtt, getNumSensors()) : 0;
TpTask[] tp_tasks = GpuQuad.setTasks( // null on geometryCorrection
num_sensors, // final int num_cams,
disparity_array, // final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
......
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