Commit 23dab5f8 authored by Andrey Filippov's avatar Andrey Filippov

Updated multi-scene Lazy Eye adjustment

parent 70892387
......@@ -271,6 +271,11 @@ public class BiQuadParameters {
public double fsplit_adiff = 0.02; //4;// minimal tile (combo) absolute disparity difference from neighbors
public double fsplit_rdiff = 0.02; // 1; // minimal tile (combo) relative disparity difference from neighbors
public double fsplit_kfg_min = 0.05; // *** minimal fraction of kfg and (1.0-kfg)
// split filtering
public double fsplit_min_ratio = 0.8; // minimal ratio of the weakest to strongest of fg and bg strengths
public double fsplit_min_diff = 0.08; // minimal FG to BG disparity difference
public double fsplit_rms_gain = 1.1; // minimal LMA RMS improvement of splitting to FG and BG
public boolean fsplit_dbg = false;
public boolean mll_generate_scene_outlines = false; // Uses 2 GB - change format, add dimensions (separate color for ref)
......@@ -743,6 +748,14 @@ public class BiQuadParameters {
"Maximal relative (to average) disparity difference from average of neighbors for FG/BG split.");
gd.addNumericField("Minimal kFG fraction", this.fsplit_kfg_min, 3,6,"",
"Minimal fraction of kfg and (1.0-kfg).");
gd.addNumericField("Minimal weakest to strongest FG, BG ratio", this.fsplit_min_ratio, 3,6,"",
"Minimal ratio of the weakest to strongest of fg and bg strengths.");
gd.addNumericField("Minimal FG to BG difference", this.fsplit_min_diff, 3,6,"pix",
"Minimal FG to BG disparity difference.");
gd.addNumericField("Minimal LMA RMS improvement of splitting", this.fsplit_rms_gain, 3,6,"",
"Minimal LMA RMS improvement of splitting to FG and BG.");
gd.addCheckbox ("Debug far FG/BG split ", this.fsplit_dbg,
"Generate and save scene outlines for scene series (need to change format, it is 2GB with uncompressed Tiff)");
......@@ -1063,9 +1076,12 @@ public class BiQuadParameters {
this.fsplit_adiff = gd.getNextNumber();
this.fsplit_rdiff = gd.getNextNumber();
this.fsplit_kfg_min = gd.getNextNumber();
this.fsplit_min_ratio = gd.getNextNumber();
this.fsplit_min_diff = gd.getNextNumber();
this.fsplit_rms_gain = gd.getNextNumber();
this.fsplit_dbg = gd.getNextBoolean();
this.mll_generate_scene_outlines= gd.getNextBoolean();
this.mll_generate_scene_outlines= gd.getNextBoolean();
this.mll_add_combo= gd.getNextBoolean();
this.mll_save_accum= gd.getNextBoolean();
this.mll_randomize_offsets= gd.getNextBoolean();
......@@ -1327,7 +1343,11 @@ public class BiQuadParameters {
properties.setProperty(prefix+"fsplit_adiff", this.fsplit_adiff+""); // double
properties.setProperty(prefix+"fsplit_rdiff", this.fsplit_rdiff+""); // double
properties.setProperty(prefix+"fsplit_kfg_min", this.fsplit_kfg_min+""); // double
properties.setProperty(prefix+"fsplit_dbg", this.fsplit_dbg+"");
properties.setProperty(prefix+"fsplit_min_ratio", this.fsplit_min_ratio+""); // double
properties.setProperty(prefix+"fsplit_min_diff", this.fsplit_min_diff+""); // double
properties.setProperty(prefix+"fsplit_rms_gain", this.fsplit_rms_gain+""); // double
properties.setProperty(prefix+"fsplit_dbg", this.fsplit_dbg+""); // boolean
properties.setProperty(prefix+"mll_add_combo", this.mll_add_combo+"");
properties.setProperty(prefix+"mll_save_accum", this.mll_save_accum+"");
......@@ -1587,6 +1607,9 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"fsplit_adiff")!=null) this.fsplit_adiff=Double.parseDouble(properties.getProperty(prefix+"fsplit_adiff"));
if (properties.getProperty(prefix+"fsplit_rdiff")!=null) this.fsplit_rdiff=Double.parseDouble(properties.getProperty(prefix+"fsplit_rdiff"));
if (properties.getProperty(prefix+"fsplit_kfg_min")!=null) this.fsplit_kfg_min=Double.parseDouble(properties.getProperty(prefix+"fsplit_kfg_min"));
if (properties.getProperty(prefix+"fsplit_min_ratio")!=null) this.fsplit_min_ratio=Double.parseDouble(properties.getProperty(prefix+"fsplit_min_ratio"));
if (properties.getProperty(prefix+"fsplit_min_diff")!=null) this.fsplit_min_diff=Double.parseDouble(properties.getProperty(prefix+"fsplit_min_diff"));
if (properties.getProperty(prefix+"fsplit_rms_gain")!=null) this.fsplit_rms_gain=Double.parseDouble(properties.getProperty(prefix+"fsplit_rms_gain"));
if (properties.getProperty(prefix+"fsplit_dbg")!=null) this.fsplit_dbg=Boolean.parseBoolean(properties.getProperty(prefix+"fsplit_dbg"));
if (properties.getProperty(prefix+"mll_generate_scene_outlines")!=null) this.mll_generate_scene_outlines=Boolean.parseBoolean(properties.getProperty(prefix+"mll_generate_scene_outlines"));
......@@ -1848,8 +1871,12 @@ public class BiQuadParameters {
bqp.fsplit_disp = this.fsplit_disp;
bqp.fsplit_adiff = this.fsplit_adiff;
bqp.fsplit_rdiff = this.fsplit_rdiff;
bqp.fsplit_kfg_min = this.fsplit_kfg_min;
bqp.fsplit_kfg_min = this.fsplit_kfg_min;
bqp.fsplit_min_ratio = this.fsplit_min_ratio;
bqp.fsplit_min_diff = this.fsplit_min_diff;
bqp.fsplit_rms_gain = this.fsplit_rms_gain;
bqp.fsplit_dbg = this.fsplit_dbg;
bqp.mll_generate_scene_outlines = this.mll_generate_scene_outlines;
bqp.mll_add_combo = this.mll_add_combo;
......
......@@ -4765,78 +4765,82 @@ public class Correlation2d {
int high_marg = corr_size - imgdtt_params.lma_soft_marg -1;
boolean [] used_pairs = pair_mask.clone();
int num_used_pairs = 0;
for (int npair = 0; npair < pair_mask.length; npair++) if ((corrs[npair] != null) && (pair_mask[npair])){
double [] corr_blur = null;
if (imgdtt_params.cnvx_en) { // || (pair_shape_masks == null)) {
corr_blur = corrs[npair].clone();
if (corr_wnd_inv_limited != null) {
for (int i = 0; i < corr_blur.length; i++) {
corr_blur[i] *= corr_wnd_inv_limited[i];
}
}
if (imgdtt_params.lma_sigma > 0) {
gb.blurDouble(corr_blur, corr_size, corr_size, imgdtt_params.lma_sigma, imgdtt_params.lma_sigma, 0.01);
}
if (dbg_corr != null) {
dbg_corr[npair] = corr_blur;
}
for (int nmax = 0; nmax < lma_corr_weights.length; nmax++) { // use same blurred version for all max-es
int x00 = (int) Math.round(pair_offsets[nmax][npair][0])+center;
int y00 = (int) Math.round(pair_offsets[nmax][npair][1])+center;
int x_min = Math.max (x00 - imgdtt_params.bimax_rad_convex_search,imgdtt_params.lma_soft_marg);
int x_max = Math.min(x00 + imgdtt_params.bimax_rad_convex_search , high_marg);
int y_min = Math.max (y00 - imgdtt_params.bimax_rad_convex_search,imgdtt_params.lma_soft_marg);
int y_max = Math.min(y00 + imgdtt_params.bimax_rad_convex_search, high_marg);
int imx = x_min + y_min * corr_size;
double [] own_mask = own_masks[nmax][npair];
for (int iy = y_min; iy <= y_max; iy++) {
for (int ix = x_min; ix <= x_max; ix++) {
int indx = iy * corr_size + ix;
if (corr_blur[indx] * own_mask[indx] > corr_blur[imx] * own_mask[imx]) {
imx = indx;
}
}
}
// filter convex
int ix0 = (imx % corr_size) - center; // signed, around center to match filterConvex
int iy0 = (imx / corr_size) - center; // signed, around center to match filterConvex
filtWeight[nmax][npair] = filterConvex(
corr_blur, // double [] corr_data,
imgdtt_params.cnvx_hwnd_size, // int hwin,
ix0, // int x0,
iy0, // int y0,
imgdtt_params.cnvx_add3x3, // boolean add3x3,
imgdtt_params.cnvx_weight, // double nc_cost,
(debug_level > 2)); // boolean debug);
//WRONG!!!
if (imgdtt_params.cnvx_or) {
for (int i = 0; i < filtWeight[nmax][npair].length; i++){
lma_corr_weights[nmax][npair][i] = Math.max(lma_corr_weights[nmax][npair][i],filtWeight[nmax][npair][i]);
}
} else {
for (int i = 0; i < filtWeight[nmax][npair].length; i++){
lma_corr_weights[nmax][npair][i] *= filtWeight[nmax][npair][i];
}
}
}
}
used_pairs[npair] = true;
for (int nmax = 0; nmax < lma_corr_weights.length; nmax++) { // use same blurred version for all max-es
int num_pair_samples = 0;
for (int i = 0; i < lma_corr_weights[nmax][npair].length; i++) if (lma_corr_weights[nmax][npair][i] > 0.0) {
num_pair_samples++;
}
if (num_pair_samples < imgdtt_params.bimax_min_num_samples) {
lma_corr_weights[nmax][npair] = null;
used_pairs[npair] = false;
}
}
if (used_pairs[npair]) {
num_used_pairs++;
}
for (int npair = 0; npair < pair_mask.length; npair++) if ((corrs[npair] != null) && (pair_mask[npair])){
double [] corr_blur = null;
if (imgdtt_params.cnvx_en) { // || (pair_shape_masks == null)) {
corr_blur = corrs[npair].clone();
if (corr_wnd_inv_limited != null) {
for (int i = 0; i < corr_blur.length; i++) {
corr_blur[i] *= corr_wnd_inv_limited[i];
}
}
if (imgdtt_params.lma_sigma > 0) {
gb.blurDouble(corr_blur, corr_size, corr_size, imgdtt_params.lma_sigma, imgdtt_params.lma_sigma, 0.01);
}
if (dbg_corr != null) {
dbg_corr[npair] = corr_blur;
}
for (int nmax = 0; nmax < lma_corr_weights.length; nmax++) { // use same blurred version for all max-es
int x00 = (int) Math.round(pair_offsets[nmax][npair][0])+center;
int y00 = (int) Math.round(pair_offsets[nmax][npair][1])+center;
int x_min = Math.max (x00 - imgdtt_params.bimax_rad_convex_search,imgdtt_params.lma_soft_marg);
int x_max = Math.min(x00 + imgdtt_params.bimax_rad_convex_search , high_marg);
int y_min = Math.max (y00 - imgdtt_params.bimax_rad_convex_search,imgdtt_params.lma_soft_marg);
int y_max = Math.min(y00 + imgdtt_params.bimax_rad_convex_search, high_marg);
// got illegal index x00=38
if ((x_min > x_max) || (y_min > y_max)) {
continue;
}
int imx = x_min + y_min * corr_size;
double [] own_mask = own_masks[nmax][npair];
for (int iy = y_min; iy <= y_max; iy++) {
for (int ix = x_min; ix <= x_max; ix++) {
int indx = iy * corr_size + ix;
if (corr_blur[indx] * own_mask[indx] > corr_blur[imx] * own_mask[imx]) {
imx = indx;
}
}
}
// filter convex
int ix0 = (imx % corr_size) - center; // signed, around center to match filterConvex
int iy0 = (imx / corr_size) - center; // signed, around center to match filterConvex
filtWeight[nmax][npair] = filterConvex(
corr_blur, // double [] corr_data,
imgdtt_params.cnvx_hwnd_size, // int hwin,
ix0, // int x0,
iy0, // int y0,
imgdtt_params.cnvx_add3x3, // boolean add3x3,
imgdtt_params.cnvx_weight, // double nc_cost,
(debug_level > 2)); // boolean debug);
//WRONG!!!
if (imgdtt_params.cnvx_or) {
for (int i = 0; i < filtWeight[nmax][npair].length; i++){
lma_corr_weights[nmax][npair][i] = Math.max(lma_corr_weights[nmax][npair][i],filtWeight[nmax][npair][i]);
}
} else {
for (int i = 0; i < filtWeight[nmax][npair].length; i++){
lma_corr_weights[nmax][npair][i] *= filtWeight[nmax][npair][i];
}
}
}
}
used_pairs[npair] = true;
for (int nmax = 0; nmax < lma_corr_weights.length; nmax++) { // use same blurred version for all max-es
int num_pair_samples = 0;
for (int i = 0; i < lma_corr_weights[nmax][npair].length; i++) if (lma_corr_weights[nmax][npair][i] > 0.0) {
num_pair_samples++;
}
if (num_pair_samples < imgdtt_params.bimax_min_num_samples) {
lma_corr_weights[nmax][npair] = null;
used_pairs[npair] = false;
}
}
if (used_pairs[npair]) {
num_used_pairs++;
}
}
if (num_used_pairs < imgdtt_params.bimax_min_num_pairs) {
return null;
......
......@@ -1751,6 +1751,7 @@ public class ImageDtt extends ImageDttCPU {
final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
//optional, may be null
final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
final double [][][][] ddnd, // [tilesY][tilesX][num_sensors][2] data for LY. Should be either null or [tilesY][tilesX][][]. disparity_map should be non-null
final boolean run_lma, // calculate LMA, false - CM only
......@@ -1929,12 +1930,22 @@ public class ImageDtt extends ImageDttCPU {
if (disparity_map != null){ // only slices that are needed, keep others
boolean use_bimax = imgdtt_params.bimax_dual_LMA;
ArrayList<Integer> used_slices = new ArrayList<Integer>();
for (int i : new int[] {DISPARITY_INDEX_CM, DISPARITY_INDEX_CM+1,DISPARITY_STRENGTH_INDEX}) used_slices.add(i);
if (run_lma) for (int i : new int[] {DISPARITY_INDEX_POLY,DISPARITY_INDEX_POLY+1}) used_slices.add(i);
for (int i : new int[] {DISPARITY_INDEX_CM, DISPARITY_INDEX_CM+1,DISPARITY_STRENGTH_INDEX}) {
used_slices.add(i);
}
if (run_lma) for (int i : new int[] {DISPARITY_INDEX_POLY,DISPARITY_INDEX_POLY+1}) {
used_slices.add(i);
}
if (use_bimax) used_slices.add(DISPARITY_VARIATIONS_INDEX);
ArrayList<Integer> nan_slices = new ArrayList<Integer>();
nan_slices.add(DISPARITY_INDEX_CM);
if (run_lma) nan_slices.add(DISPARITY_INDEX_POLY);
if (run_lma) {
nan_slices.add(DISPARITY_INDEX_POLY);
if (use_rms) {
nan_slices.add(DISPARITY_STRENGTH_INDEX); // will be used for RMS if LMA succeeded
}
}
for (int indx:used_slices) {
disparity_map[indx] = new double[tilesY*tilesX];
}
......@@ -1958,6 +1969,7 @@ public class ImageDtt extends ImageDttCPU {
if (fcorr_td[tileY][tileX] == null) {
continue; // nothing accumulated for this tile
}
double lma_rms = Double.NaN;
// boolean dbg_val=globalDebugLevel>100;
nTile = tileY * tilesX + tileX;
if (tp_tasks[iTile].getTask() == 0) continue; // nothing to do for this tile
......@@ -2190,6 +2202,7 @@ public class ImageDtt extends ImageDttCPU {
((lma_dual== null)? "null": " not null"));
}
if (lma_dual != null) {
lma_rms = lma_dual.getRmsTile()[0];
boolean dbg_dispStrs = (debug_lma != null);
double [][][] dispStrs = lma_dual.lmaDisparityStrengths( //TODO: add parameter to filter out negative minimums ?
dbg_dispStrs, // false, // boolean bypass_tests, // keep even weak for later analysis. Normally - only in test mode
......@@ -2251,6 +2264,9 @@ public class ImageDtt extends ImageDttCPU {
// set BG to DISPARITY_INDEX_CM/DISPARITY_INDEX_CM+1
disparity_map[DISPARITY_INDEX_CM ][nTile] = disp_str_lma[1-indx][0]; // disparity LMA
disparity_map[DISPARITY_INDEX_CM + 1][nTile] = disp_str_lma[1-indx][2]; // strength LMA
if (use_rms) {
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = lma_rms;
}
if (debugTile1) { // FIXME: remove debugTile1!
System.out.println("clt_process_tl_correlations() disp_str_lma:");
for (int nmax = 0; nmax < disp_str_lma.length; nmax++) {
......@@ -2263,7 +2279,11 @@ public class ImageDtt extends ImageDttCPU {
} else {
disparity_map[DISPARITY_INDEX_CM ][nTile] = disp_str_sel[0][0]; // disparity non-LMA
disparity_map[DISPARITY_INDEX_CM + 1 ][nTile] = disp_str_sel[0][1]; // strength non-LMA;
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = disp_str_sel[0][1]; // strength non-LMA;
if (use_rms) {
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = lma_rms;
} else {
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = disp_str_sel[0][1]; // strength non-LMA;
}
if ((disp_str_lma!=null) && (disp_str_lma.length>0)) {
if (disp_str_lma.length == 1) {
if (!Double.isNaN(disp_str_lma[0][0])) {
......@@ -2301,7 +2321,9 @@ public class ImageDtt extends ImageDttCPU {
disp_str = new double [] {-corr_stat[0], corr_stat[1]};
disparity_map[DISPARITY_INDEX_CM ][nTile] = disp_str[0];
disparity_map[DISPARITY_INDEX_CM + 1 ][nTile] = disp_str[1];
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = disp_str[1];
if (!use_rms) {
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = disp_str[1];
}
}
}
} // if (imgdtt_params.bimax_dual_LMA) else
......@@ -2346,6 +2368,7 @@ public class ImageDtt extends ImageDttCPU {
}
double [][] ds = null;
if (lma2 != null) {
lma_rms = lma2.getRmsTile()[0];
ds = lma2.lmaDisparityStrength(
false, // boolean bypass_tests, // keep even weak for later analysis. Normally - only in test mode
imgdtt_params.lmas_min_amp, // minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
......@@ -2363,7 +2386,11 @@ public class ImageDtt extends ImageDttCPU {
// if (disparity_map!=null) {
disparity_map[DISPARITY_INDEX_POLY ][nTile] = ds[0][0];
disparity_map[DISPARITY_INDEX_POLY + 1][nTile] = ds[0][2]; // LMA strength as is
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = ds[0][1]; // overwrite with LMA strength
if (use_rms) {
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = lma_rms;
} else {
disparity_map[DISPARITY_STRENGTH_INDEX][nTile] = ds[0][1]; // overwrite with LMA strength
}
// }
if (ddnd != null) {
ddnd[tileY][tileX] = lma2.getDdNd();
......
......@@ -36,6 +36,7 @@ public class IntersceneMatchParameters {
// Maybe add parameters to make sure there is enough data? Enough in each zone? Enough spread?
public boolean force_ref_dsi = false; // true;
public boolean force_orientations = false;
public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation
public int min_num_orient = 2; // make from parameters, should be >= 1
public int min_num_interscene = 2; // make from parameters, should be >= 1
......@@ -374,6 +375,8 @@ public class IntersceneMatchParameters {
"Calculate reference scene DSI even if the file exists.");
gd.addCheckbox ("Force egomotion calculation", this.force_orientations,
"Calculate relative poses of each scene camera relative to the reference scene even if the data exists.");
gd.addCheckbox ("Run LY adjustments", this.run_ly,
"Adjust cameras orientations (after building DSI) and exit without generatin result files.");
gd.addNumericField("Minimal number of egomotion calculations",this.min_num_orient, 0,3,"",
"Minimal number of fitting scenes cycles, should be >=1. First cycle includes spiral search for the first scene");
gd.addNumericField("Minimal number of interscene accumulations", this.min_num_interscene, 0,3,"",
......@@ -963,6 +966,7 @@ public class IntersceneMatchParameters {
public void dialogAnswers(GenericJTabbedDialog gd) {
this.force_ref_dsi = gd.getNextBoolean();
this.force_orientations = gd.getNextBoolean();
this.run_ly = gd.getNextBoolean();
this.min_num_orient = (int) gd.getNextNumber(); if (min_num_orient < 1) min_num_orient = 1;
this.min_num_interscene = (int) gd.getNextNumber(); if (min_num_interscene < 1) min_num_interscene = 1;
this.generate_mapped = gd.getNextBoolean();
......@@ -1280,6 +1284,7 @@ public class IntersceneMatchParameters {
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"force_ref_dsi", this.force_ref_dsi + ""); // boolean
properties.setProperty(prefix+"force_orientations", this.force_orientations + ""); // boolean
properties.setProperty(prefix+"run_ly", this.run_ly + ""); // boolean
// properties.setProperty(prefix+"readjust_orient", this.readjust_orient + ""); // boolean
// properties.setProperty(prefix+"force_interscene", this.force_interscene + ""); // boolean
properties.setProperty(prefix+"min_num_orient", this.min_num_orient+""); // int
......@@ -1556,6 +1561,7 @@ public class IntersceneMatchParameters {
public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"force_ref_dsi")!=null) this.force_ref_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"force_ref_dsi"));
if (properties.getProperty(prefix+"force_orientations")!=null) this.force_orientations=Boolean.parseBoolean(properties.getProperty(prefix+"force_orientations"));
if (properties.getProperty(prefix+"run_ly")!=null) this.run_ly=Boolean.parseBoolean(properties.getProperty(prefix+"run_ly"));
if (properties.getProperty(prefix+"min_num_orient")!=null) this.min_num_orient=Integer.parseInt(properties.getProperty(prefix+"min_num_orient"));
if (properties.getProperty(prefix+"min_num_interscene")!=null) this.min_num_interscene=Integer.parseInt(properties.getProperty(prefix+"min_num_interscene"));
if (properties.getProperty(prefix+"generate_mapped")!=null) this.generate_mapped=Boolean.parseBoolean(properties.getProperty(prefix+"generate_mapped"));
......@@ -1855,8 +1861,7 @@ public class IntersceneMatchParameters {
IntersceneMatchParameters imp = new IntersceneMatchParameters();
imp.force_ref_dsi = this.force_ref_dsi;
imp.force_orientations = this.force_orientations;
// imp.readjust_orient = this.readjust_orient;
// imp.force_interscene = this.force_interscene;
imp.run_ly = this.run_ly;
imp.min_num_orient = this.min_num_orient;
imp.min_num_interscene = this.min_num_interscene;
imp.generate_mapped = this.generate_mapped;
......
......@@ -105,6 +105,7 @@ public class MultisceneLY {
double [] inf_avg,
boolean debug
) {
TileNeibs tn = new TileNeibs(tp.getTilesX(), tp.getTilesY());
int num_bins = 256;
int [] hist = new int [num_bins];
double [][] dbg_img = debug? (new double[2][]): null;
......@@ -168,20 +169,22 @@ public class MultisceneLY {
}
}
// grow sure fg
tp.growTiles(
// tp.growTiles(
tn.growSelection(
2, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
is_fg, // boolean [] tiles,
null); // boolean [] prohibit)
// Remove even core infinity if it is expanden FG
// Remove even core infinity if it is expanded FG
for (int nTile = 0; nTile < is_inf.length; nTile++) {
is_inf[nTile] &= !is_fg[nTile];
}
tp.growTiles(
// tp.growTiles(
tn.growSelection(
2, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
is_inf, // boolean [] tiles,
is_fg); // boolean [] prohibit)
// uses deprecated - update with tn.growSelection
tp.fillGaps( // grows, then shrinks
2, // int depth, // same as grow - odd - 4 directions, even - 8
true, // false, // boolean poison, // do not fill gaps that even touch prohibited
......@@ -390,7 +393,6 @@ public class MultisceneLY {
for (int nscene = 0; nscene < num_scenes; nscene++) {
target_disparities[nscene] = scenes[nscene].getDSRBG()[0];
Arrays.fill(rslt_disparities[nscene], Double.NaN);
}
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
......@@ -1017,8 +1019,9 @@ public class MultisceneLY {
tp_tasks_combo); // final TpTask[] tp_tasks
double [][][] dcorr_tiles = show_corr? (new double [tp_tasks_combo.length][][]):null;
final double[][] disparity_map = new double [image_dtt.getDisparityTitles().length][];
final double[][] disparity_map = new double [image_dtt.getDisparityTitles().length][];
final double [][][][] ddnd = new double [tilesY][tilesX][][];
// Does not use disparity_map[DISPARITY_STRENGTH_INDEX]
image_dtt.clt_process_tl_correlations( // 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
fcorr_td_acc, // final float [][][][] fcorr_td, // [tilesY][tilesX][pair][4*64] transform domain representation of all selected corr pairs
......@@ -1037,6 +1040,7 @@ public class MultisceneLY {
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
false, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
ddnd, // [tilesY][tilesX][num_sensors][2] data for LY. Should be either null or [tilesY][tilesX][][]. disparity_map should be non-null
......
......@@ -58,6 +58,7 @@ import com.elphel.imagej.gpu.GpuQuad;
import com.elphel.imagej.gpu.TpTask;
import com.elphel.imagej.jp4.JP46_Reader_camera;
import Jama.Matrix;
import ij.ImagePlus;
import ij.ImageStack;
import ij.Prefs;
......@@ -4674,7 +4675,7 @@ public class OpticalFlow {
* @param threadsMax
* @param updateStatus
* @param debugLevel
* @return null on failure, or String path to the reference model directory
* @return null on failure or after LY adjustments, or String path to the reference model directory
* @throws Exception
*/
public String buildSeries(
......@@ -4701,6 +4702,7 @@ public class OpticalFlow {
boolean build_ref_dsi = clt_parameters.imp.force_ref_dsi;
boolean force_initial_orientations = clt_parameters.imp.force_orientations ;
boolean run_ly = clt_parameters.imp.run_ly; // run LY adjust and exit
int min_num_interscene = clt_parameters.imp.min_num_interscene; // 2; // make from parameters, should be >= 1
int min_num_orient = clt_parameters.imp.min_num_orient; // 2; // make from parameters, should be >= 1
......@@ -5058,6 +5060,46 @@ public class OpticalFlow {
debugLevel+1);
}
}
if (run_ly) {
if (debugLevel > -3) {
System.out.println("**** Running LY adjustments *****");
}
// Calculate and fill per-scene target disparities as scene.dsrbg
double [] ref_target_disparity=quadCLTs[ref_index].getDLS()[0]; // 0];
double [][] interpolated_disparities = intepolateSceneDisparity(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes,
ref_index, // final int indx_ref,
ref_target_disparity, // final double [] disparity_ref, // disparity in the reference view tiles (Double.NaN - invalid)
debugLevel + 2); // final int debug_level
for (int i = 0; i < quadCLTs.length; i++) {
double [][] dsrbg=quadCLTs[i].getDSRBG();
if (dsrbg == null) {
quadCLTs[i].dsrbg = new double[1][];
quadCLTs[i].dsrbg[0] = interpolated_disparities[i];
}
//double [] target_disparity = scene.getDSRBG()[0];
}
adjustLYSeries(
quadCLT_main, // QuadCLT quadCLT_main, // update extrinsics here too
quadCLTs, // QuadCLT [] quadCLTs,
ref_index, // int ref_index,
clt_parameters, // CLTParameters clt_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
channelGainParameters, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
equirectangularParameters, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
properties, // Properties properties,
reset_from_extrinsics, // boolean reset_from_extrinsics,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel) throws Exception
if (debugLevel > -3) {
System.out.println("**** Exiting without output files generation after running LY adjustments *****");
}
return null;
}
if (photo_en && !reuse_video) {
if (debugLevel > -3) {
......@@ -5651,7 +5693,6 @@ public class OpticalFlow {
null, // testr, // null, // final Rectangle full_woi_in, // show larger than sensor WOI (or null)
clt_parameters, // CLTParameters clt_parameters,
constant_disparity, // double [] disparity_ref,
ZERO3, // final double [] scene_xyz, // camera center in world coordinates
ZERO3, // new double[] {.1,0.1,.1}, // ZERO3, // final double [] scene_atr, // camera orientation relative to world frame
quadCLTs[ref_index], // final QuadCLT scene,
......@@ -5930,6 +5971,382 @@ public class OpticalFlow {
return quadCLTs[ref_index].getX3dTopDirectory();
}
public void adjustLYSeries(
QuadCLT quadCLT_main, // update extrinsics here too
QuadCLT [] quadCLTs,
int ref_index,
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
Properties properties,
boolean reset_from_extrinsics,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) throws Exception
{
MultisceneLY.MSLY_MODE adjust_mode = MultisceneLY.MSLY_MODE.INF_NOINF;
if (clt_parameters.ofp.pattern_mode) {
adjust_mode = MultisceneLY.MSLY_MODE.NOINF_ONLY;
}
boolean pattern_mode = clt_parameters.ofp.pattern_mode;
this.startTime=System.nanoTime();
boolean proc_infinity = (adjust_mode == MultisceneLY.MSLY_MODE.INF_ONLY) || (adjust_mode == MultisceneLY.MSLY_MODE.INF_NOINF); // true;
boolean lma_only = true; // use clt_parameters
double dbg_disparity_offset = 0.0; // 0.1
double inf_disp_ref = 0.0;
int ref_scene_index = quadCLTs.length-1;
if (pattern_mode) {
ref_scene_index = clt_parameters.ofp.center_index;
}
QuadCLT ref_scene = quadCLTs[ref_scene_index];
String composite_suffix = "-INTER-INTRA-LMA"; // is already read if available!
String num_corr_max_suffix = "-NUM-CORR-MAX";
int [] wh = new int[2];
double [][] composite_ds = ref_scene.readDoubleArrayFromModelDirectory(
composite_suffix, // String suffix,
0, // int num_slices, // (0 - all)
wh); // int [] wh)
// composite_ds == null if no file
MultisceneLY multisceneLY = new MultisceneLY (
quadCLTs[0].getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
// read interscene composite data
boolean [][] is_scene_infinity = null; // per scene, per tile - is infinity.
int tilesX = ref_scene.tp.getTilesX();
int tilesY = ref_scene.tp.getTilesY();
int clustersX = (int) Math.ceil(1.0 * tilesX / clt_parameters.lyms_clust_size);
int clustersY = (int) Math.ceil(1.0 * tilesY / clt_parameters.lyms_clust_size);
int clusters = clustersX * clustersY;
boolean debug = debugLevel > -3;
if (proc_infinity) {
double [] inf_avg = new double[1];
boolean [] ref_inf = MultisceneLY.getComboInfinity(
ref_scene.tp, // TileProcessor tp,
composite_ds, // double [][] composite_ds,
clt_parameters.lyms_far_inf, // double far_inf,
clt_parameters.lyms_near_inf, // double near_inf,
clt_parameters.lyms_far_fract, // double far_fract,
clt_parameters.lyms_inf_range_offs, // double inf_range_offs,
clt_parameters.lyms_inf_range, // double inf_range,
clt_parameters.lyms_min_inf_str, // double min_inf_str,
clt_parameters.lyms_min_fg_str, // double min_fg_str,
inf_avg, // double [] inf_avg,
debug); // boolean debug)
is_scene_infinity = MultisceneLY.infinityPerScene(
quadCLTs, // QuadCLT [] scenes,
inf_avg[0], // double inf_disp_ref, // average disparity at infinity for ref scene
ref_inf, // boolean [] infinity_ref,
debug, // boolean debug,
threadsMax); // int threadsMax)
inf_disp_ref = inf_avg[0];
}
// Read or generate+save number of correlation maximums per scene, per tile
// Will use only tiles with one and only one correlation maximum
int [][] numCorrMax = new int [quadCLTs.length][]; // ->
double [][] dNumCorrMax =ref_scene.readDoubleArrayFromModelDirectory(
num_corr_max_suffix, // String suffix,
0, // int num_slices, // (0 - all)
wh); // int [] wh)
if ((dNumCorrMax != null) && (dNumCorrMax.length == numCorrMax.length)) {
for (int nscene = 0; nscene < numCorrMax.length; nscene++) {
numCorrMax[nscene] = new int[dNumCorrMax[nscene].length];
for (int i = 0; i < dNumCorrMax[nscene].length; i++) {
numCorrMax[nscene][i] = (int) dNumCorrMax[nscene][i];
}
}
} else {
for (int i = 0; i < quadCLTs.length; i++) { // require DSI for each model
numCorrMax[i] = multisceneLY.getNumCorrMax(
clt_parameters, // CLTParameters clt_parameters,
lma_only, // boolean lma_only,
quadCLTs[i], // QuadCLT scene, // ordered by increasing timestamps
debugLevel); // int debug_level)
}
dNumCorrMax = new double[numCorrMax.length][numCorrMax[0].length];
for (int nscene = 0; nscene < numCorrMax.length; nscene++) {
dNumCorrMax[nscene] = new double[dNumCorrMax[nscene].length];
for (int i = 0; i < dNumCorrMax[nscene].length; i++) {
dNumCorrMax[nscene][i] = numCorrMax[nscene][i];
}
}
ref_scene.saveDoubleArrayInModelDirectory( // error
num_corr_max_suffix, // String suffix,
null, // null, // String [] labels, // or null
dNumCorrMax, // dbg_data, // double [][] data,
ref_scene.tp.getTilesX(), // int width,
ref_scene.tp.getTilesY()); // int height)
}
// valid tile - one and only one maximum
boolean [][] valid_tile = new boolean[numCorrMax.length][numCorrMax[0].length];
for (int nscene = 0; nscene < numCorrMax.length; nscene++) {
for (int nTile = 0; nTile < numCorrMax[nscene].length; nTile++) {
valid_tile[nscene][nTile] = numCorrMax[nscene][nTile] == 1; // only single-maximum
if (clt_parameters.lyms_margin > 0) {
int tileX = nTile % tilesX;
int tileY = nTile / tilesX;
if ( (tileY < clt_parameters.lyms_margin) ||
(tileX < clt_parameters.lyms_margin) ||
(tileY >= (tilesY - clt_parameters.lyms_margin)) ||
(tileX >= (tilesX - clt_parameters.lyms_margin))) {
valid_tile[nscene][nTile] = false;
}
}
}
}
int [][] num_tiles2 = new int[2][];
double [][][] target_disparities = new double [2][][];
boolean use_tarz = false; // true; //false;
double delta = 0.001; // 0.01;
boolean debug_derivs = false;
ExtrinsicAdjustment ea = new ExtrinsicAdjustment (
ref_scene.getErsCorrection(), // GeometryCorrection gc,
clt_parameters.lyms_clust_size, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY)
boolean [] force_disparity = new boolean[clusters];
boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0);
// int max_tries = 5; // organize cycle with comparing results
int max_tries = clt_parameters.lym_iter; // 25;
double inf_min = -1.0;
double inf_max = 1.0;
double [] old_new_rms = new double [2];
double min_sym_update = clt_parameters.getLymChange(ref_scene.isAux()); // 4e-6; // stop iterations if no angle changes more than this
double comp_diff = min_sym_update + 1; // (> min_sym_update)
double [] disparity_offset = new double [clusters]; // 0.1
if (dbg_disparity_offset != 0.0) {
Arrays.fill(disparity_offset, dbg_disparity_offset);
}
int nrefine = 4;
for (int num_iter = 0; num_iter < max_tries; num_iter++){
// (re-)measure LY here, update all scenes? or just accumulater difference?
double [][][] lazy_eye_data2 = MultisceneLY.getLYDataInfNoinf(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, // final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
target_disparities, // final double[][] target_disparities,
dbg_disparity_offset, // final double dbg_disparity_offset,
num_tiles2, // final int [][] in_num_tiles, // null or number of tiles per cluster to multiply strength
null, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
nrefine, // final int nrefine, // number of disparity refines for non-inf
threadsMax, // final int threadsMax,
debugLevel); // final int debug_level);
if (debug_derivs && (num_iter == 0)) { // only once if any
MultisceneLY.debugLYDerivatives(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
lazy_eye_data2, // double [][][] lazy_eye_data2, // inf, no_inf
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, //final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
threadsMax, // final int threadsMax, // maximal number of threads to launch
delta, // double delta,
use_tarz, // boolean use_tarz, // derivatives by tarz, not symmetrical vectors
debugLevel); // final int debugLevel);
}
for (int nly = 00; nly < lazy_eye_data2.length; nly++) if (lazy_eye_data2[nly] != null ) {
ea.showInput(
lazy_eye_data2[nly], // double[][] data,
"drv_reference-"+MultisceneLY.SINF_NOINF[nly]);// String title);
}
double [][] lazy_eye_data = MultisceneLY.mergeLY(
adjust_mode, // MSLY_MODE adjust_mode,
lazy_eye_data2, // double [][][] lazy_eye_data2,
force_disparity); // boolean [] force_disparity // null or [clusters]
ea.setForceDisparity(force_disparity);
ea.showInput(
lazy_eye_data, // double[][] data,
"ly_combo-"+lazy_eye_data.toString());// String title);
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
// 1.0 - to skip filtering infinity
inf_min, //double inf_min_disparity, // minimal disparity for infinity
inf_max, // double inf_max_disparity, // minimal disparity for infinity
clt_parameters.ly_inf_min_broad, // inf_min_disp_abs, // minimal disparity for infinity (absolute)
clt_parameters.ly_inf_max_broad, // maximal disparity for infinity (absolute)
clt_parameters.ly_inf_tilt, // boolean en_infinity_tilt, // select infinity tiles form right/left tilted (false - from average)
clt_parameters.ly_right_left, // boolean infinity_right_left, // balance weights between right and left halves of infinity
clt_parameters.ly_aztilt_en, // boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
clt_parameters.ly_diff_roll_en, // boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
// clt_parameters.ly_inf_force, // boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity
clt_parameters.ly_min_forced, // int min_num_forced, // minimal number of clusters with forced disparity to use it
// data, using just radial distortions
clt_parameters.ly_com_roll, // boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength , // boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
clt_parameters.ly_weight_disparity, //0.0, // double weight_disparity, // 0.0 disparity weight relative to the sum of 8 lazy eye values of the same tile
clt_parameters.ly_weight_disparity_inf,//0.5, // double weight_disparity_inf,// 0.5 disparity weight relative to the sum of 8 lazy eye values of the same tile for infinity
clt_parameters.ly_max_disparity_far, //5.0, // double max_disparity_far, // 5.0 reduce weights of near tiles proportional to sqrt(max_disparity_far/disparity)
clt_parameters.ly_max_disparity_use, //5.0, // double max_disparity_use, // 5.0 (default 1000)disable near objects completely - use to avoid ERS
0.0, // clt_parameters.ly_inf_min_dfe, //1.75,// double min_dfe, // = 1.75;
0.0, // clt_parameters.ly_inf_max_dfe, //5.0, // double max_dfe, // = 5.0; // <=0 - disable feature
// moving objects filtering
false, // clt_parameters.ly_moving_en, // boolean moving_en, // enable filtering areas with potentially moving objects
clt_parameters.ly_moving_apply, // boolean moving_apply, // apply filtering areas with potentially moving objects
clt_parameters.ly_moving_sigma, // double moving_sigma, // blurring sigma for moving objects = 1.0;
clt_parameters.ly_max_mov_disparity, // double max_mov_disparity, // disparity limit for moving objects detection = 75.0;
clt_parameters.ly_rad_to_hdiag_mov, // double rad_to_hdiag_mov, // radius to half-diagonal ratio to remove high-distortion corners = 0.7 ; // 0.8
clt_parameters.ly_max_mov_average, // double max_mov_average, // do not attempt to detect moving objects if ERS is not accurate for terrain = .25;
clt_parameters.ly_mov_min_L2, // double mov_min_L2, // threshold for moving objects = 0.75;
lazy_eye_data, // scan.getLazyEyeData(), // dsxy, // double [][] measured_dsxy,
force_disparity, // scan.getLazyEyeForceDisparity(), // null, // boolean [] force_disparity, // boolean [] force_disparity,
false, // boolean use_main, // corr_rots_aux != null;
ref_scene.getGeometryCorrection().getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // + 5);// int debugLevel) >=2 to show images
if (debugLevel > -2){
System.out.println("Old extrinsic corrections:");
System.out.println(ref_scene.getGeometryCorrection().getCorrVector().toString());
}
if (corr_vector != null) {
CorrVector diff_corr = corr_vector.diffFromVector(ref_scene.getGeometryCorrection().getCorrVector());
comp_diff = diff_corr.getNorm(); // apply this to all scenes
if (debugLevel > -2){
System.out.println("New extrinsic corrections:");
System.out.println(corr_vector.toString());
}
if (debugLevel > -3){
System.out.println("Increment extrinsic corrections:");
System.out.println(diff_corr.toString());
}
ref_scene.gpuResetCorrVector(); // next time GPU will need to set correction vector (and re-calculate offsets?)
if (apply_extrinsic){
// Apply correction to all scenes (adding, as ERS can be different)
// will need to update all scenes GC (write back to disk), but only after all are done
for (int i = 0; i < quadCLTs.length; i++) {
QuadCLT scene = quadCLTs[i];
CorrVector scene_vector = scene.getGeometryCorrection().getCorrVector();
scene_vector.incrementVector(diff_corr, 1.0); // no scale here
scene.getGeometryCorrection().setCorrVector(scene_vector);
}
quadCLTs[ref_index].getGeometryCorrection().setCorrVector(corr_vector); // updated system corr vector with the current updated one
// was in TwoQuadCLT:
quadCLT_main.getGeometryCorrection().setCorrVector(corr_vector); // updated system corr vector with the current updated one
System.out.println("Extrinsic correction updated (can be disabled by setting clt_parameters.ly_corr_scale = 0.0) ");
} else {
System.out.println("Correction is not applied according clt_parameters.ly_corr_scale == 0.0) ");
}
} else {
if (debugLevel > -3){
System.out.println("LMA failed"); // What now?
}
}
boolean done = (comp_diff < min_sym_update) || (num_iter == (max_tries - 1));
// System.out.println("done="+done);
if (debugLevel > -10) { // should work even in batch mode
System.out.println("#### extrinsicsCLT(): iteration step = "+(num_iter + 1) + " ( of "+max_tries+") change = "+
comp_diff + " ("+min_sym_update+"), previous RMS = " + old_new_rms[0]+
" final RMS = " + old_new_rms[1]+ " (debugLevel = "+debugLevel+")");
}
if (debugLevel > -10) {
if ((debugLevel > -3) || done) {
System.out.println("New extrinsic corrections:");
System.out.println(ref_scene.getGeometryCorrection().getCorrVector().toString());
}
}
if (comp_diff < min_sym_update) {
break;
}
inf_disp_ref = 0.0; // after first adjustment set infinity to 0.0
}
// Now update correction vector for all scenes to disk - how was it read?
// update
if (debugLevel > -200) {
return;
}
// debug images
if (debugLevel > -2) {
double [][] dbg_numCorrMax = new double[numCorrMax.length][];
for (int i = 0; i < dbg_numCorrMax.length; i++) {
dbg_numCorrMax[i] = new double[numCorrMax[i].length];
for (int ntile=0; ntile < numCorrMax[i].length; ntile++) {
dbg_numCorrMax[i][ntile] = numCorrMax[i][ntile];
}
}
ShowDoubleFloatArrays.showArrays(
dbg_numCorrMax,
tilesX,
tilesY,
true,
"numCorrMax");
double [][] dbg_num_tiles = new double[2][];
for (int i = 0; i < num_tiles2.length; i++ ) {
dbg_num_tiles[i] = new double [clusters];
for (int nClust = 0; nClust < clusters; nClust++) {
dbg_num_tiles[i][nClust] = num_tiles2[i][nClust];
}
}
ShowDoubleFloatArrays.showArrays(
dbg_num_tiles,
clustersX,
clustersY,
true,
"clusters_num_inf_boinf",
new String[] {"inf tiles", "noinf tiles"});
}
/* TODO: move all adjustments there?
if (lazy_eye_data != null) {
multisceneLY.processLYdata( // TODO: move all adjustments there?
clt_parameters, // final CLTParameters clt_parameters,
adjust_mode, // MSLY_MODE adjust_mode,
quadCLTs, // final QuadCLT [] scenes, // ordered by increasing timestamps
lazy_eye_data2, // final double [][][] lazy_eye_data,
valid_tile, // final boolean [][] valid_tile, // tile with lma and single correlation maximum
inf_disp_ref, // final double inf_disp_ref, // average disparity at infinity for ref scene // is_scene_infinity
is_scene_infinity, // final boolean [][] is_scene_infinity, // may be null, if not - may be infinity from the composite depth map
false, // boolean update_disparity, // re-measure disparity before measuring LY
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
}
*/
if (debugLevel > -2) {
System.out.println("adjustLYSeries() Done");
}
System.out.println("End of adjustLYSeries()");
}
public static void testERS(
CLTParameters clt_parameters,
int indx0, // reference scene in a pair
......@@ -7541,7 +7958,7 @@ public class OpticalFlow {
}
@Deprecated
public void IntersceneAccumulate(
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -7672,6 +8089,7 @@ public class OpticalFlow {
mcorr_sel, // final int mcorr_sel, // = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[nscene].getNumSensors());
null, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
false, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
false, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
debug_level-5); // final int debug_level)
/// Runtime.getRuntime().gc();
......@@ -7955,6 +8373,9 @@ public class OpticalFlow {
final double fsplit_adiff = clt_parameters.rig.fsplit_adiff; // 0.08;// minimal tile (combo) absolute disparity difference from neighbors
final double fsplit_rdiff = clt_parameters.rig.fsplit_rdiff; // 0.1; // minimal tile (combo) relative disparity difference from neighbors
final double fsplit_kfg_min = clt_parameters.rig.fsplit_kfg_min; // 0.1; // minimal fraction of kfg and (1.0-kfg)
final double fsplit_min_ratio = clt_parameters.rig.fsplit_min_ratio;// 0.8; // minimal ratio of the weakest to strongest of fg and bg strengths
final double fsplit_min_diff = clt_parameters.rig.fsplit_min_diff; // 0.08;// minimal FG to BG disparity difference
final double fsplit_rms_gain = clt_parameters.rig.fsplit_rms_gain; // 1.1; // minimal LMA RMS improvement of splitting to FG and BG
final boolean fsplit_dbg = clt_parameters.rig.fsplit_dbg;
int fsplit_refines = 0;
if (fsplit_en) switch (fsplit_mode) {
......@@ -8161,7 +8582,11 @@ public class OpticalFlow {
boolean [] far_split = null; // new boolean [nTiles];
double [][] far_fg_ds_merge = new double[2][];
double [][] far_bg_ds_merge = new double[2][];
double [] used_rms_lma = new double[selection.length]; // last rms from LMA, not including BG refine
double [] split_rms_lma = new double[selection.length];
Arrays.fill(used_rms_lma, Double.NaN);
boolean use_rms = true; // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
if (nrefine == clt_parameters.rig.mll_max_refines_pre) {
min_disp_change = clt_parameters.rig.mll_min_disp_change_lma;
......@@ -8263,7 +8688,8 @@ public class OpticalFlow {
mcorr_sel, // final int mcorr_sel, // =
null, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
false, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
debug_level-8); // final int debug_level)
use_rms, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
debug_level-8); // final int debug_level)
if (debug_level > 0) { //-3) {
ShowDoubleFloatArrays.showArrays(
......@@ -8277,8 +8703,19 @@ public class OpticalFlow {
}
// update disparities
double [] map_disparity = disparity_map[ImageDtt.DISPARITY_INDEX_CM]; // 2
double [] map_strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX]; // 10
double [] map_disparity_lma = disparity_map[ImageDtt.DISPARITY_INDEX_POLY]; // 8
// double [] map_strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX]; // 10
double [] map_strength_lma = disparity_map[ImageDtt.DISPARITY_INDEX_POLY+1]; // 9
double [] map_strength = disparity_map[ImageDtt.DISPARITY_INDEX_CM+1]; // 3
if (use_rms && clt_parameters.correlate_lma) { // non-elegant way to build old DISPARITY_STRENGTH_INDEX
map_strength = map_strength.clone();
for (int i = 0; i < map_strength.length; i++) if (map_strength_lma[i] > 0.0) {
map_strength[i] = map_strength_lma[i];
}
}
double [] map_rms_lma = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX]; // 8
double [] map_disparity_lma = disparity_map[ImageDtt.DISPARITY_INDEX_POLY]; // 8
// only for far split.
double [] map_far_fg_disparity = disparity_map[ImageDtt.DISPARITY_INDEX_POLY];
double [] map_far_fg_strength = disparity_map[ImageDtt.DISPARITY_INDEX_POLY+1];
......@@ -8329,8 +8766,6 @@ public class OpticalFlow {
double [][] predicted_bg_ds = new double[2][nTiles];
double [][] predicted_fg_ds_merge = new double[2][];
double [][] predicted_bg_ds_merge = new double[2][];
// predicted_fg_ds[0] = new double[nTiles];
// predicted_bg_ds[0] = new double[nTiles];
Arrays.fill(predicted_fg_ds[0], Double.NaN);
Arrays.fill(predicted_bg_ds[0], Double.NaN);
predicted_fg_ds_merge[0]= avg_ds[0].clone();
......@@ -8363,6 +8798,7 @@ public class OpticalFlow {
predicted_bg_ds_merge[0][tile] = predicted_bg_ds[0][tile]; // disparity(BG)
predicted_fg_ds_merge[1][tile] = avg_ds[1][tile] * kfg; // strength(FG)
predicted_bg_ds_merge[1][tile] = avg_ds[1][tile] * (1.0 - kfg); // strength(BG)
split_rms_lma[tile] = map_rms_lma[tile];
}
}
......@@ -8387,7 +8823,11 @@ public class OpticalFlow {
"fg_str_predicted_err", // 17
"bg_str_predicted_err", // 18
"sel", // 19
"target_disparity"}; // 20
"target_disparity", // 20
"rrms_single", // 21
"rrms_split", // 22
"rrms_gain", // 23
"str_ratio"}; // 24
double [][] dbg_img = new double[dbg_far_spit_titles.length][];
dbg_img[ 0] = avg_ds[0];
......@@ -8410,10 +8850,22 @@ public class OpticalFlow {
dbg_img[17] = fg_predicted_err[1];
dbg_img[18] = bg_predicted_err[1];
dbg_img[19] = new double [nTiles];
dbg_img[21] = new double [nTiles];
dbg_img[22] = new double [nTiles];
dbg_img[23] = new double [nTiles];
dbg_img[24] = new double [nTiles];
for (int tile = 0; tile < nTiles; tile++) {
// update index below !
dbg_img[19][tile] = (selection[tile] ? 0.5:0.0) + (far_split[tile] ? 0.6:0.0);
dbg_img[ 3][tile] = dbg_img[ 1][tile] - dbg_img[ 2][tile];
dbg_img[21][tile] = 1.0/used_rms_lma[tile];
dbg_img[22][tile] = 1.0/map_rms_lma[tile];
dbg_img[23][tile] = used_rms_lma[tile]/map_rms_lma[tile];
double sr = far_fg_ds[1][tile]/far_bg_ds[1][tile];
if (sr > 1.0) {
sr = 1.0/sr;
}
dbg_img[24][tile] = sr;
}
dbg_img[20] = target_disparity;
......@@ -8425,7 +8877,6 @@ public class OpticalFlow {
"far-split"+split_pass,
dbg_far_spit_titles);
}
} else { //if (split_pass >= 0) { // pre-far_fgbg disparity processing
int num_tomeas = 0; // number of tiles to measure
Arrays.fill(selection, false);
......@@ -8470,6 +8921,10 @@ public class OpticalFlow {
combo_dsn_final[COMBO_DSN_INDX_LMA][nTile] = combo_dsn_change[COMBO_DSN_INDX_DISP][nTile];
if (map_disparity_lma != null) {
combo_dsn_final[COMBO_DSN_INDX_LMA][nTile] = Double.isNaN(map_disparity_lma[nTile])? Double.NaN : combo_dsn_final[COMBO_DSN_INDX_DISP][nTile];
// saving last LMA RMS to compare against split FG/BG to see if it improves (or significantly improves?)
if (!Double.isNaN(map_disparity_lma[nTile])) {
used_rms_lma[nTile] = map_rms_lma[nTile];
}
}
combo_dsn_final[COMBO_DSN_INDX_VALID][nTile] = combo_dsn[COMBO_DSN_INDX_VALID][nTile]; // not much sense
combo_dsn_final[COMBO_DSN_INDX_CHANGE][nTile] = combo_dsn_change[COMBO_DSN_INDX_CHANGE][nTile];
......@@ -8540,15 +8995,34 @@ public class OpticalFlow {
boolean mod_cumul_bg_disp = true;
if (far_fg_ds[0] != null) {
for (int nTile =0; nTile < combo_dsn_change[0].length; nTile++) {
if (!Double.isNaN(far_fg_ds[0][nTile])) {
if (!Double.isNaN(far_fg_ds[0][nTile]) && !Double.isNaN(far_bg_ds[0][nTile])) {
// filtering
double fg_bg_diff = far_fg_ds[0][nTile] - far_bg_ds[0][nTile];
if (fg_bg_diff < fsplit_min_diff) {
continue;
}
double rms_gain = used_rms_lma[nTile] / split_rms_lma[nTile];
if (rms_gain < fsplit_rms_gain) {
continue;
}
double weak_strong_ratio = far_fg_ds[1][nTile] / far_bg_ds[1][nTile];
if (weak_strong_ratio > 1) {
weak_strong_ratio = 1.0 / weak_strong_ratio;
}
if (weak_strong_ratio < fsplit_min_ratio) {
continue;
}
combo_dsn_final[COMBO_DSN_INDX_DISP_FG][nTile] = far_fg_ds[0][nTile];
combo_dsn_final[COMBO_DSN_INDX_LMA][nTile] = far_fg_ds[0][nTile];
if (mod_cumul_disp) {
combo_dsn_final[COMBO_DSN_INDX_DISP][nTile] = far_fg_ds[0][nTile];
}
combo_dsn_final[COMBO_DSN_INDX_STRENGTH][nTile] = far_fg_ds[1][nTile] * scale_far_split_strength;
}
if (!Double.isNaN(far_bg_ds[0][nTile])) {
combo_dsn_final[COMBO_DSN_INDX_DISP_BG_ALL][nTile] = far_bg_ds[0][nTile];
combo_dsn_final[COMBO_DSN_INDX_LMA_BG][nTile] = far_bg_ds[0][nTile];
if (mod_cumul_bg_disp) {
......@@ -9115,6 +9589,7 @@ public class OpticalFlow {
mcorr_sel, // final int mcorr_sel, // =
facc_2d_img, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
no_map, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
false, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
clt_parameters.img_dtt.lmamask_dbg? 1:(debug_level-8)); // final int debug_level)
if (disparity_map != null) {
ShowDoubleFloatArrays.showArrays(
......@@ -9649,6 +10124,7 @@ public class OpticalFlow {
mcorr_sel, // final int mcorr_sel, // =
null, // final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
false, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
false, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
debug_level-5); // final int debug_level)
if (debug_level > 0) {
......@@ -9905,7 +10381,197 @@ public class OpticalFlow {
return combo_dsn;
}
public static double [][] intepolateSceneDisparity(
final CLTParameters clt_parameters,
final QuadCLT [] scenes,
final int indx_ref,
final double [] disparity_ref, // disparity in the reference view tiles (Double.NaN - invalid)
final int debug_level
)
{
final int scene_extrap_irad = 1;
final double scene_extrap_rad = scene_extrap_irad + 0.5;
final QuadCLT ref_scene = scenes[indx_ref];
final ErsCorrection ers_reference = ref_scene.getErsCorrection();
final int tilesX = ref_scene.getTileProcessor().getTilesX();
final int tilesY = ref_scene.getTileProcessor().getTilesY();
final int tileSize = ref_scene.getTileProcessor().getTileSize();
double max_rad2 = scene_extrap_rad * scene_extrap_rad * tileSize * tileSize; // in pixels
final double [][] disparity_scenes = new double [scenes.length][tilesX*tilesY];
// final double [][] ref_pXpYD = new double[3][];
final int dbg_tileX=70;
final int dbg_tileY=19;
final int dbg_tile=dbg_tileY * tilesX + dbg_tileX;
for (int nscene = scenes.length-1; nscene >= 0; nscene--) {
String ts = scenes[nscene].getImageName();
double [][] scene_pXpYD;
if (nscene == indx_ref) {
// transform to self - maybe use a method that sets central points
scene_pXpYD = transformToScenePxPyD( // check it is all 0.5
null, // final Rectangle [] extra_woi, // show larger than sensor WOI (or null)
disparity_ref, // final double [] disparity_ref, // invalid tiles - NaN in disparity (maybe it should not be masked by margins?)
ZERO3, // final double [] scene_xyz, // camera center in world coordinates
ZERO3, // final double [] scene_atr, // camera orientation relative to world frame
ref_scene, // final QuadCLT scene_QuadClt,
ref_scene); // final QuadCLT reference_QuadClt)
disparity_scenes[indx_ref] = disparity_ref; // .clone();
// for (int i = 0; i < ref_pXpYD.length; i++) {
// ref_pXpYD[i] = scene_pXpYD[i];
// }
} else {
final Matrix [][] scene_approx = new Matrix[disparity_ref.length][];
Arrays.fill(disparity_scenes[nscene], Double.NaN);
double [] scene_xyz = ers_reference.getSceneXYZ(ts);
double [] scene_atr = ers_reference.getSceneATR(ts);
if ((scene_xyz == null) || (scene_atr == null)){
continue; // scene is not matched
}
double [] scene_ers_xyz_dt = ers_reference.getSceneErsXYZ_dt(ts);
double [] scene_ers_atr_dt = ers_reference.getSceneErsATR_dt(ts);
scenes[nscene].getErsCorrection().setErsDt(
scene_ers_xyz_dt, // double [] ers_xyz_dt,
scene_ers_atr_dt); // double [] ers_atr_dt)(ers_scene_original_xyz_dt);
//setupERS() will be inside transformToScenePxPyD()
double [][] scene_pXpYD_prefilter = transformToScenePxPyD( // will be null for disparity == NaN, total size - tilesX*tilesY
null, // final Rectangle [] extra_woi, // show larger than sensor WOI (or null)
disparity_ref, // final double [] disparity_ref, // invalid tiles - NaN in disparity (maybe it should not be masked by margins?)
scene_xyz, // final double [] scene_xyz, // camera center in world coordinates
scene_atr, // final double [] scene_atr, // camera orientation relative to world frame
scenes[nscene], // final QuadCLT scene_QuadClt,
ref_scene); // final QuadCLT reference_QuadClt)
double max_overlap = 0.6;
double min_adisp_cam = 0.2;
double min_rdisp_cam = 0.03;
double [][] scene_ds =conditionInitialDS(
clt_parameters, // CLTParameters clt_parameters,
scenes[nscene], // QuadCLT scene,
-1); // int debug_level);
if (scene_ds != null) {
double [] disparity_cam = scene_ds[0]; // null; // for now
scene_pXpYD = filterBG (
scenes[indx_ref].getTileProcessor(), // final TileProcessor tp,
scene_pXpYD_prefilter, // final double [][] pXpYD,
max_overlap, // final double max_overlap,
null, // disparity_cam, // final double [] disparity_cam,
min_adisp_cam, // final double min_adisp_cam,
min_rdisp_cam, // final double min_rdisp_cam,
clt_parameters.tileX, // final int dbg_tileX,
clt_parameters.tileY, // final int dbg_tileY,
0); // 1); //debug_level); // final int debug_level);
} else {
scene_pXpYD = scene_pXpYD_prefilter;
}
// acummulate single-thread
// tileSize
for (int nTile = 0; nTile < scene_pXpYD.length; nTile++) if ((scene_pXpYD[nTile] != null) && !Double.isNaN(scene_pXpYD[nTile][2])) {
// final int scene_extrap_irad = 1;
// double max_rad2 = scene_extrap_irad * scene_extrap_irad;
// int tileX0=nTile % tilesX;
// int tileY0=nTile / tilesX;
int tileX0=(int) Math.floor(scene_pXpYD[nTile][0]/tileSize);
int tileY0=(int) Math.floor(scene_pXpYD[nTile][1]/tileSize);
if ((debug_level > -1) && (Math.abs(tileY0-dbg_tileY) < 2) && (Math.abs(tileX0-dbg_tileX) < 2)) {
System.out.println("nTile="+nTile+", tilX0="+tileX0+", tileY0="+tileY0);
}
for (int dTy = -scene_extrap_irad; dTy <= scene_extrap_irad; dTy++) {
int tileY = tileY0 + dTy;
double dy = tileY * tileSize + tileSize/2 - scene_pXpYD[nTile][1];
if ((tileY >=0) && (tileY < tilesY)) {
for (int dTx = -scene_extrap_irad; dTx <= scene_extrap_irad; dTx++) {
int tileX = tileX0 + dTx;
if ((tileX >=0) && (tileX < tilesX)) {
if ((debug_level > -1) && (tileY == dbg_tileY) && (tileX == dbg_tileX)) {
System.out.println("tileX="+tileX+", tileY="+tileY);
}
double dx = tileX * tileSize + tileSize/2 - scene_pXpYD[nTile][0];
double rad2 = dy*dy+dx*dx;
if (rad2 < max_rad2) {
int tile = tileY * tilesX + tileX;
double w = 1 - (rad2/max_rad2);
if (scene_approx[tile] == null) {
scene_approx[tile] = new Matrix[2];
scene_approx[tile][0] = new Matrix(3,3); // A
scene_approx[tile][1] = new Matrix(3,1); // B
}
double d = scene_pXpYD[nTile][2];
double dsx = w *dx;
double dsy = w *dy;
double dsx2 = dsx*dx;
double dsy2 = dsy*dy;
double dsxy = dsx*dy;
double ds0 = w;
double dsxd = dsx * d;
double dsyd = dsy * d;
double dsd = ds0 * d;
double [][] A = scene_approx[tile][0].getArray();
A[0][0] += dsx2;
A[0][1] += dsxy;
A[0][2] += dsx;
A[1][1] += dsy2;
A[1][2] += dsy;
A[2][2] += ds0;
double [][] B = scene_approx[tile][1].getArray();
B[0][0] += dsxd;
B[1][0] += dsyd;
B[2][0] += dsd;
/* ax + by + c ~= d
a * sx2 + b * sxy + c * sx - sxd = 0
a * sxy + b * sy2 + c * sy - syd = 0
a * sx + b * sy + c * s0 - sd = 0
| sx2 sxy sx | | a | | sxd |
| sxy sy2 sy | * | b | = | syd |
| sx sy s0 | | c | | sd | */
}
}
}
}
}
}
for (int nTile = 0; nTile < scene_pXpYD.length; nTile++) if (scene_approx[nTile] != null) {
if (debug_level > -1) {
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
if ((tileY == dbg_tileY) && (tileX == dbg_tileX)) {
System.out.println("tileX="+tileX+", tileY="+tileY);
}
}
double [][] A = scene_approx[nTile][0].getArray();
if (A[2][2] > 0) {
A[1][0] = A[0][1];
A[2][0] = A[0][2];
A[2][1] = A[1][2];
try {
Matrix abc = scene_approx[nTile][0].solve(scene_approx[nTile][1]);
disparity_scenes[nscene][nTile] = abc.get(2, 0) + abc.get(0, 0)*tileSize/2 + abc.get(1, 0)*tileSize/2;
} catch (RuntimeException e){
// Use just average of disparities
disparity_scenes[nscene][nTile] = scene_approx[nTile][1].get(2,0) / A[2][2]; // Double.NaN;
}
}
}
}
if (debug_level > -1) {
if (nscene == indx_ref) {
// System.out.println("Correlating reference scene, nrefine = "+nrefine);
} else {
// System.out.println("Correlating scene "+nrefine+":"+nscene);
}
}
}
if (debug_level > -1) {
ShowDoubleFloatArrays.showArrays(
disparity_scenes,
tilesX,
tilesY,
true,
"disparity_scenes");
}
return disparity_scenes;
}
// Cleaned up and optimized version to reduce memory usage (on-the-fly integration, not saving full correlation data)
public static double[][] correlateInterscene(
final CLTParameters clt_parameters,
......@@ -9920,6 +10586,7 @@ public class OpticalFlow {
final int mcorr_sel, // = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[nscene].getNumSensors());
final float [][][] accum_2d_corr, // if [1][][] - return accumulated 2d correlations (all pairs)
final boolean no_map, // do not generate disparity_map (time-consuming LMA)
final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
final int debug_level
)
{
......@@ -10091,6 +10758,7 @@ public class OpticalFlow {
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
use_rms, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
......@@ -10140,6 +10808,7 @@ public class OpticalFlow {
if ((nscene == indx_ref) && show_reference_correlations) { // prepare 2d correlations for visualization, double/CPU mode
double [][][] dcorr_tiles = (fclt_corr != null)? (new double [tp_tasks_ref.length][][]):null;
// non-GPU (broken)
image_dtt.clt_process_tl_correlations( // 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
tp_tasks_ref, // final TpTask [] tp_tasks, // data from the reference frame - will be applied to LMW for the integrated correlations
......@@ -10243,6 +10912,7 @@ public class OpticalFlow {
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
use_rms, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
......@@ -10467,6 +11137,7 @@ public class OpticalFlow {
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
false, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
//optional, may be null
null, // disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
......
......@@ -13963,6 +13963,7 @@ public class QuadCLTCPU {
// to be converted to float
dcorr_tiles, // final double [][][] dcorr_tiles, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// When clt_mismatch is non-zero, no far objects extraction will be attempted
false, // final boolean use_rms, // DISPARITY_STRENGTH_INDEX means LMA RMS (18/04/2023)
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
null, // final double [][] ddnd, // data for LY. SHould be either null or [num_sensors][]
......
......@@ -11428,12 +11428,14 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
boolean proc_infinity = (adjust_mode == MultisceneLY.MSLY_MODE.INF_ONLY) || (adjust_mode == MultisceneLY.MSLY_MODE.INF_NOINF); // true;
boolean lma_only = true; // use clt_parameters
double dbg_disparity_offset = 0.0; // 0.1
double inf_disp_ref = 0.0;
// int last_scene_index = quadCLTs.length-1;
int ref_scene_index = quadCLTs.length-1;
if (pattern_mode) {
......@@ -11441,8 +11443,6 @@ if (debugLevel > -100) return true; // temporarily !
}
// QuadCLT last_scene = quadCLTs[last_scene_index];
QuadCLT ref_scene = quadCLTs[ref_scene_index];
String composite_suffix = "-INTER-INTRA-LMA"; // is already read if available!
String num_corr_max_suffix = "-NUM-CORR-MAX";
......
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