Commit 70892387 authored by Andrey Filippov's avatar Andrey Filippov

Before reorganizing DISPARITY_STRENGTH_INDEX

parent 9a8fd5dc
...@@ -260,6 +260,7 @@ public class BiQuadParameters { ...@@ -260,6 +260,7 @@ public class BiQuadParameters {
// FG/BG split for far tiles where dual max can only be detected with LMA as it is too small // FG/BG split for far tiles where dual max can only be detected with LMA as it is too small
public boolean fsplit_en = true; // enable split of far tiles into FG/BG with LMA public boolean fsplit_en = true; // enable split of far tiles into FG/BG with LMA
// fsplit_mode==2 now (04/17/2023) worse than fsplit_mode==1
public int fsplit_mode = 1; // 0: disable, 1:avg->fg+bg, 2: avg->fg+fg:fg:bg public int fsplit_mode = 1; // 0: disable, 1:avg->fg+bg, 2: avg->fg+fg:fg:bg
public double fsplit_str = 0.4; // minimal strength of the tile to split public double fsplit_str = 0.4; // minimal strength of the tile to split
public int fsplit_neibs = 3; // minimal number of neighbors to consider split public int fsplit_neibs = 3; // minimal number of neighbors to consider split
...@@ -270,6 +271,7 @@ public class BiQuadParameters { ...@@ -270,6 +271,7 @@ public class BiQuadParameters {
public double fsplit_adiff = 0.02; //4;// minimal tile (combo) absolute disparity difference from neighbors 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_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) public double fsplit_kfg_min = 0.05; // *** minimal fraction of kfg and (1.0-kfg)
public boolean fsplit_dbg = false;
public boolean mll_generate_scene_outlines = false; // Uses 2 GB - change format, add dimensions (separate color for ref) public boolean mll_generate_scene_outlines = false; // Uses 2 GB - change format, add dimensions (separate color for ref)
...@@ -741,6 +743,8 @@ public class BiQuadParameters { ...@@ -741,6 +743,8 @@ public class BiQuadParameters {
"Maximal relative (to average) disparity difference from average of neighbors for FG/BG split."); "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,"", gd.addNumericField("Minimal kFG fraction", this.fsplit_kfg_min, 3,6,"",
"Minimal fraction of kfg and (1.0-kfg)."); "Minimal fraction of kfg and (1.0-kfg).");
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)");
gd.addMessage("Other"); gd.addMessage("Other");
gd.addCheckbox ("Generate scene outlines", this.mll_generate_scene_outlines, gd.addCheckbox ("Generate scene outlines", this.mll_generate_scene_outlines,
...@@ -1059,7 +1063,7 @@ public class BiQuadParameters { ...@@ -1059,7 +1063,7 @@ public class BiQuadParameters {
this.fsplit_adiff = gd.getNextNumber(); this.fsplit_adiff = gd.getNextNumber();
this.fsplit_rdiff = gd.getNextNumber(); this.fsplit_rdiff = gd.getNextNumber();
this.fsplit_kfg_min = gd.getNextNumber(); this.fsplit_kfg_min = 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_add_combo= gd.getNextBoolean();
...@@ -1323,8 +1327,7 @@ public class BiQuadParameters { ...@@ -1323,8 +1327,7 @@ public class BiQuadParameters {
properties.setProperty(prefix+"fsplit_adiff", this.fsplit_adiff+""); // double properties.setProperty(prefix+"fsplit_adiff", this.fsplit_adiff+""); // double
properties.setProperty(prefix+"fsplit_rdiff", this.fsplit_rdiff+""); // 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_kfg_min", this.fsplit_kfg_min+""); // double
properties.setProperty(prefix+"fsplit_dbg", this.fsplit_dbg+"");
properties.setProperty(prefix+"mll_generate_scene_outlines",this.mll_generate_scene_outlines+"");
properties.setProperty(prefix+"mll_add_combo", this.mll_add_combo+""); properties.setProperty(prefix+"mll_add_combo", this.mll_add_combo+"");
properties.setProperty(prefix+"mll_save_accum", this.mll_save_accum+""); properties.setProperty(prefix+"mll_save_accum", this.mll_save_accum+"");
...@@ -1584,6 +1587,7 @@ public class BiQuadParameters { ...@@ -1584,6 +1587,7 @@ 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_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_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_kfg_min")!=null) this.fsplit_kfg_min=Double.parseDouble(properties.getProperty(prefix+"fsplit_kfg_min"));
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")); if (properties.getProperty(prefix+"mll_generate_scene_outlines")!=null) this.mll_generate_scene_outlines=Boolean.parseBoolean(properties.getProperty(prefix+"mll_generate_scene_outlines"));
...@@ -1845,7 +1849,7 @@ public class BiQuadParameters { ...@@ -1845,7 +1849,7 @@ public class BiQuadParameters {
bqp.fsplit_adiff = this.fsplit_adiff; bqp.fsplit_adiff = this.fsplit_adiff;
bqp.fsplit_rdiff = this.fsplit_rdiff; bqp.fsplit_rdiff = this.fsplit_rdiff;
bqp.fsplit_kfg_min = this.fsplit_kfg_min; bqp.fsplit_kfg_min = this.fsplit_kfg_min;
bqp.fsplit_dbg = this.fsplit_dbg;
bqp.mll_generate_scene_outlines = this.mll_generate_scene_outlines; bqp.mll_generate_scene_outlines = this.mll_generate_scene_outlines;
bqp.mll_add_combo = this.mll_add_combo; bqp.mll_add_combo = this.mll_add_combo;
......
...@@ -7955,7 +7955,7 @@ public class OpticalFlow { ...@@ -7955,7 +7955,7 @@ 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_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_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_kfg_min = clt_parameters.rig.fsplit_kfg_min; // 0.1; // minimal fraction of kfg and (1.0-kfg)
final boolean fsplit_dbg = clt_parameters.rig.fsplit_dbg;
int fsplit_refines = 0; int fsplit_refines = 0;
if (fsplit_en) switch (fsplit_mode) { if (fsplit_en) switch (fsplit_mode) {
case 1: fsplit_refines = 1; break; case 1: fsplit_refines = 1; break;
...@@ -8159,6 +8159,9 @@ public class OpticalFlow { ...@@ -8159,6 +8159,9 @@ public class OpticalFlow {
double [][] far_bg_ds = null; double [][] far_bg_ds = null;
boolean [] sel_split = new boolean [selection.length]; boolean [] sel_split = new boolean [selection.length];
boolean [] far_split = null; // new boolean [nTiles]; boolean [] far_split = null; // new boolean [nTiles];
double [][] far_fg_ds_merge = new double[2][];
double [][] far_bg_ds_merge = new double[2][];
for (int nrefine = 0; nrefine < max_refines; nrefine++) { for (int nrefine = 0; nrefine < max_refines; nrefine++) {
if (nrefine == clt_parameters.rig.mll_max_refines_pre) { if (nrefine == clt_parameters.rig.mll_max_refines_pre) {
min_disp_change = clt_parameters.rig.mll_min_disp_change_lma; min_disp_change = clt_parameters.rig.mll_min_disp_change_lma;
...@@ -8201,6 +8204,7 @@ public class OpticalFlow { ...@@ -8201,6 +8204,7 @@ public class OpticalFlow {
if (split_pass >= 0) { if (split_pass >= 0) {
if (split_pass == 0) { if (split_pass == 0) {
split_src= 0 ; // AVG split_src= 0 ; // AVG
target_disparity=avg_ds[0];
} else if (split_pass == 1) { } else if (split_pass == 1) {
split_src= 1 ; clt_parameters.img_dtt.bimax_combine_mode = Correlation2d.CAMEL_FG; split_src= 1 ; clt_parameters.img_dtt.bimax_combine_mode = Correlation2d.CAMEL_FG;
target_disparity=far_fg_ds[0]; target_disparity=far_fg_ds[0];
...@@ -8227,7 +8231,7 @@ public class OpticalFlow { ...@@ -8227,7 +8231,7 @@ public class OpticalFlow {
far_bg_ds, // final double [][] bg_ds, far_bg_ds, // final double [][] bg_ds,
far_split, // null, // final boolean [] selection, // may be null, does not apply to neighbors far_split, // null, // final boolean [] selection, // may be null, does not apply to neighbors
tilesX, // final int tilesX, tilesX, // final int tilesX,
ref_scene.getImageName()+"-FGBG-"+split_pass); // final String dbg_title); fsplit_dbg? (ref_scene.getImageName()+"-FGBG-"+split_pass):null); // final String dbg_title);
//far_split //far_split
selection = sel_split; // for correlateInterscene() selection = sel_split; // for correlateInterscene()
if (split_src == 0) { if (split_src == 0) {
...@@ -8237,6 +8241,11 @@ public class OpticalFlow { ...@@ -8237,6 +8241,11 @@ public class OpticalFlow {
far_bg_ds[0] = new double[nTiles]; far_bg_ds[0] = new double[nTiles];
Arrays.fill(far_fg_ds[0], Double.NaN); Arrays.fill(far_fg_ds[0], Double.NaN);
Arrays.fill(far_bg_ds[0], Double.NaN); Arrays.fill(far_bg_ds[0], Double.NaN);
far_fg_ds_merge[0] = avg_ds[0].clone();
far_bg_ds_merge[0] = avg_ds[0].clone();
far_fg_ds_merge[1] = avg_ds[1].clone();
far_bg_ds_merge[1] = avg_ds[1].clone();
} }
} }
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,num_sensors); int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,num_sensors);
...@@ -8275,32 +8284,18 @@ public class OpticalFlow { ...@@ -8275,32 +8284,18 @@ public class OpticalFlow {
double [] map_far_fg_strength = disparity_map[ImageDtt.DISPARITY_INDEX_POLY+1]; double [] map_far_fg_strength = disparity_map[ImageDtt.DISPARITY_INDEX_POLY+1];
double [] map_far_bg_disparity = disparity_map[ImageDtt.DISPARITY_INDEX_CM]; double [] map_far_bg_disparity = disparity_map[ImageDtt.DISPARITY_INDEX_CM];
double [] map_far_bg_strength = disparity_map[ImageDtt.DISPARITY_INDEX_CM+1]; double [] map_far_bg_strength = disparity_map[ImageDtt.DISPARITY_INDEX_CM+1];
double [][] far_fg_ds_merge = new double[2][];
double [][] far_bg_ds_merge = new double[2][];
far_fg_ds_merge[0] = avg_ds[0].clone();
far_bg_ds_merge[0] = avg_ds[0].clone();
far_fg_ds_merge[1] = avg_ds[1].clone();
far_bg_ds_merge[1] = avg_ds[1].clone();
if (split_pass >= 0) { if (split_pass >= 0) {
if (far_split == null) { if (far_split == null) {
far_split = new boolean [nTiles]; far_split = new boolean [nTiles];
} }
// Arrays.fill(far_split, false);
// boolean [] far_split = new boolean [nTiles];
// double [][] far_fg_ds_merge = new double[2][];
// double [][] far_bg_ds_merge = new double[2][];
// far_fg_ds_merge[0] = avg_ds[0].clone();
// far_bg_ds_merge[0] = avg_ds[0].clone();
// far_fg_ds_merge[1] = avg_ds[1].clone();
// far_bg_ds_merge[1] = avg_ds[1].clone();
// single-threaded // single-threaded
if (split_src == 0) { if (split_src == 0) {
for (int tile = 0; tile < nTiles; tile++) { for (int tile = 0; tile < nTiles; tile++) {
if (!Double.isNaN(map_far_fg_disparity[tile]) && !Double.isNaN(map_far_bg_disparity[tile])) { if (!Double.isNaN(map_far_fg_disparity[tile]) && !Double.isNaN(map_far_bg_disparity[tile])) {
far_split[tile] = true; far_split[tile] = true;
far_fg_ds[0][tile] = avg_ds[0][tile] + map_far_fg_disparity[tile]; far_fg_ds[0][tile] = target_disparity[tile] + map_far_fg_disparity[tile];
far_bg_ds[0][tile] = avg_ds[0][tile] + map_far_bg_disparity[tile]; far_bg_ds[0][tile] = target_disparity[tile] + map_far_bg_disparity[tile];
far_fg_ds_merge[0][tile] = far_fg_ds[0][tile]; far_fg_ds_merge[0][tile] = far_fg_ds[0][tile];
far_bg_ds_merge[0][tile] = far_bg_ds[0][tile]; far_bg_ds_merge[0][tile] = far_bg_ds[0][tile];
far_fg_ds_merge[1][tile] = map_far_fg_strength[tile]; far_fg_ds_merge[1][tile] = map_far_fg_strength[tile];
...@@ -8311,7 +8306,7 @@ public class OpticalFlow { ...@@ -8311,7 +8306,7 @@ public class OpticalFlow {
for (int tile = 0; tile < nTiles; tile++) { for (int tile = 0; tile < nTiles; tile++) {
if (!Double.isNaN(map_far_fg_disparity[tile])) { if (!Double.isNaN(map_far_fg_disparity[tile])) {
far_split[tile] = true; far_split[tile] = true;
far_fg_ds[0][tile] += map_far_fg_disparity[tile]; far_fg_ds[0][tile] = target_disparity[tile] + map_far_fg_disparity[tile];
far_fg_ds_merge[0][tile] = far_fg_ds[0][tile]; far_fg_ds_merge[0][tile] = far_fg_ds[0][tile];
far_fg_ds_merge[1][tile] = map_far_fg_strength[tile]; far_fg_ds_merge[1][tile] = map_far_fg_strength[tile];
} }
...@@ -8320,7 +8315,7 @@ public class OpticalFlow { ...@@ -8320,7 +8315,7 @@ public class OpticalFlow {
for (int tile = 0; tile < nTiles; tile++) { for (int tile = 0; tile < nTiles; tile++) {
if (!Double.isNaN(map_far_bg_disparity[tile])) { if (!Double.isNaN(map_far_bg_disparity[tile])) {
far_split[tile] = true; far_split[tile] = true;
far_bg_ds[0][tile] += map_far_bg_disparity[tile]; far_bg_ds[0][tile] = target_disparity[tile] + map_far_bg_disparity[tile];
far_bg_ds_merge[0][tile] = far_bg_ds[0][tile]; far_bg_ds_merge[0][tile] = far_bg_ds[0][tile];
far_bg_ds_merge[1][tile] = map_far_bg_strength[tile]; far_bg_ds_merge[1][tile] = map_far_bg_strength[tile];
} }
...@@ -8375,49 +8370,52 @@ public class OpticalFlow { ...@@ -8375,49 +8370,52 @@ public class OpticalFlow {
"avg_disp", // 0 "avg_disp", // 0
"fg_disp", // 1 "fg_disp", // 1
"bg_disp", // 2 "bg_disp", // 2
"fg_disp_only", // 3 "fg-bg", // 3
"bg_disp_only", // 4 "fg_disp_only", // 4
"fg_disp_predicted_only",// 5 "bg_disp_only", // 5
"bg_disp_predicted_only",// 6 "fg_disp_predicted_only",// 6
"fg_disp_predicted_err", // 7 "bg_disp_predicted_only",// 7
"bg_disp_predicted_err", // 8 "fg_disp_predicted_err", // 8
"avg_str", // 9 "bg_disp_predicted_err", // 9
"fg_str", // 10 "avg_str", // 10
"bg_str", // 11 "fg_str", // 11
"fg_str_only", // 12 "bg_str", // 12
"bg_str_only", // 13 "fg_str_only", // 13
"fg_str_predicted_only", // 14 "bg_str_only", // 14
"bg_str_predicted_only", // 15 "fg_str_predicted_only", // 15
"fg_str_predicted_err", // 16 "bg_str_predicted_only", // 16
"bg_str_predicted_err", // 17 "fg_str_predicted_err", // 17
"sel", // 18 "bg_str_predicted_err", // 18
"target_disparity"}; // 19 "sel", // 19
"target_disparity"}; // 20
double [][] dbg_img = new double[dbg_far_spit_titles.length][]; double [][] dbg_img = new double[dbg_far_spit_titles.length][];
dbg_img[ 0] = avg_ds[0]; dbg_img[ 0] = avg_ds[0];
dbg_img[ 1] = far_fg_ds_merge[0]; dbg_img[ 1] = far_fg_ds_merge[0];
dbg_img[ 2] = far_bg_ds_merge[0]; dbg_img[ 2] = far_bg_ds_merge[0];
dbg_img[ 3] = far_fg_ds[0]; dbg_img[ 3] = new double [nTiles];
dbg_img[ 4] = far_bg_ds[0]; dbg_img[ 4] = far_fg_ds[0];
dbg_img[ 5] = predicted_fg_ds[0]; dbg_img[ 5] = far_bg_ds[0];
dbg_img[ 6] = predicted_bg_ds[0]; dbg_img[ 6] = predicted_fg_ds[0];
dbg_img[ 7] = fg_predicted_err[0]; dbg_img[ 7] = predicted_bg_ds[0];
dbg_img[ 8] = bg_predicted_err[0]; dbg_img[ 8] = fg_predicted_err[0];
dbg_img[ 9] = avg_ds[1]; dbg_img[ 9] = bg_predicted_err[0];
dbg_img[10] = far_fg_ds_merge[1]; dbg_img[10] = avg_ds[1];
dbg_img[11] = far_bg_ds_merge[1]; dbg_img[11] = far_fg_ds_merge[1];
dbg_img[12] = far_fg_ds[1]; dbg_img[12] = far_bg_ds_merge[1];
dbg_img[13] = far_bg_ds[1]; dbg_img[13] = far_fg_ds[1];
dbg_img[14] = predicted_fg_ds[1]; dbg_img[14] = far_bg_ds[1];
dbg_img[15] = predicted_bg_ds[1]; dbg_img[15] = predicted_fg_ds[1];
dbg_img[16] = fg_predicted_err[1]; dbg_img[16] = predicted_bg_ds[1];
dbg_img[17] = bg_predicted_err[1]; dbg_img[17] = fg_predicted_err[1];
dbg_img[18] = new double [nTiles]; dbg_img[18] = bg_predicted_err[1];
dbg_img[19] = new double [nTiles];
for (int tile = 0; tile < nTiles; tile++) { for (int tile = 0; tile < nTiles; tile++) {
// update index below ! // update index below !
dbg_img[18][tile] = (selection[tile] ? 0.5:0.0) + (far_split[tile] ? 0.6:0.0); 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[19] = target_disparity; dbg_img[20] = target_disparity;
ShowDoubleFloatArrays.showArrays( ShowDoubleFloatArrays.showArrays(
dbg_img, dbg_img,
...@@ -13129,7 +13127,7 @@ public class OpticalFlow { ...@@ -13129,7 +13127,7 @@ public class OpticalFlow {
/// null); // int [] wh); /// null); // int [] wh);
double [][] combo_dsn_final = quadCLTs[ref_index].restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky double [][] combo_dsn_final = quadCLTs[ref_index].restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky
double [][] dls = { double [][] dls = { // Update to use FG? Or FG/no BG?
combo_dsn_final[COMBO_DSN_INDX_DISP], combo_dsn_final[COMBO_DSN_INDX_DISP],
combo_dsn_final[COMBO_DSN_INDX_LMA], combo_dsn_final[COMBO_DSN_INDX_LMA],
combo_dsn_final[COMBO_DSN_INDX_STRENGTH] combo_dsn_final[COMBO_DSN_INDX_STRENGTH]
...@@ -13172,11 +13170,9 @@ public class OpticalFlow { ...@@ -13172,11 +13170,9 @@ public class OpticalFlow {
if (test_motion_blur) { if (test_motion_blur) {
dbg_mb_img = new double[quadCLTs.length][]; dbg_mb_img = new double[quadCLTs.length][];
} }
// }
ErsCorrection ers_reference = quadCLTs[ref_index].getErsCorrection(); ErsCorrection ers_reference = quadCLTs[ref_index].getErsCorrection();
// double [][][] dxyzatr_dt = new double[quadCLTs.length][][];
double [][][] scenes_xyzatr = new double [quadCLTs.length][][]; // previous scene relative to the next one double [][][] scenes_xyzatr = new double [quadCLTs.length][][]; // previous scene relative to the next one
scenes_xyzatr[ref_index] = new double[2][3]; // all zeros scenes_xyzatr[ref_index] = new double[2][3]; // all zeros
......
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