Commit 96562ce2 authored by Andrey Filippov's avatar Andrey Filippov

Next snapshot, debugging

parent 019655f7
...@@ -258,6 +258,9 @@ public class Interscene { ...@@ -258,6 +258,9 @@ public class Interscene {
quadCLTs[cent_index].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) // null pointer quadCLTs[cent_index].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) // null pointer
null, // String path, // full name with extension or w/o path to use x3d directory null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1); debugLevel+1);
if (debugLevel > -3) {
System.out.println("setInitialOrientationsCenterIms(): return earliest_scene2="+earliest_scene2);
}
return earliest_scene2; return earliest_scene2;
} }
...@@ -448,6 +451,7 @@ public class Interscene { ...@@ -448,6 +451,7 @@ public class Interscene {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
use_lma_dsi, // clt_parameters.imp.use_lma_dsi, use_lma_dsi, // clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
true, // boolean disable_ers,
min_max, // double [] min_max, // null or pair of minimal and maximal offsets min_max, // double [] min_max, // null or pair of minimal and maximal offsets
fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
quadCLTs[ref_index], // QuadCLT reference_QuadCLT, quadCLTs[ref_index], // QuadCLT reference_QuadCLT,
...@@ -820,6 +824,7 @@ public class Interscene { ...@@ -820,6 +824,7 @@ public class Interscene {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
use_lma_dsi, // clt_parameters.imp.use_lma_dsi, use_lma_dsi, // clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
true, // boolean disable_ers,
min_max, // double [] min_max, // null or pair of minimal and maximal offsets min_max, // double [] min_max, // null or pair of minimal and maximal offsets
fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
quadCLTs[ref_index], // QuadCLT reference_QuadCLT, quadCLTs[ref_index], // QuadCLT reference_QuadCLT,
...@@ -966,6 +971,7 @@ public class Interscene { ...@@ -966,6 +971,7 @@ public class Interscene {
public static int reAdjustPairsLMAInterscene( // after combo dgi is available and preliminary poses are known public static int reAdjustPairsLMAInterscene( // after combo dgi is available and preliminary poses are known
CLTParameters clt_parameters, CLTParameters clt_parameters,
double mb_max_gain, double mb_max_gain,
boolean disable_ers,
boolean [] reliable_ref, // null or bitmask of reliable reference tiles boolean [] reliable_ref, // null or bitmask of reliable reference tiles
QuadCLT [] quadCLTs, QuadCLT [] quadCLTs,
int ref_index, int ref_index,
...@@ -1363,6 +1369,7 @@ public class Interscene { ...@@ -1363,6 +1369,7 @@ public class Interscene {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
false, // boolean initial_adjust, false, // boolean initial_adjust,
fpn_disable, // boolean fpn_disable, // disable fpn filter if images are known to be too close fpn_disable, // boolean fpn_disable, // disable fpn filter if images are known to be too close
disable_ers, // boolean disable_ers,
min_max, // double [] min_max, // null or pair of minimal and maximal offsets min_max, // double [] min_max, // null or pair of minimal and maximal offsets
fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
quadCLTs[ref_index], // QuadCLT reference_QuadCLT, quadCLTs[ref_index], // QuadCLT reference_QuadCLT,
...@@ -1484,6 +1491,7 @@ public class Interscene { ...@@ -1484,6 +1491,7 @@ public class Interscene {
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean use_lma_dsi, boolean use_lma_dsi,
boolean fpn_disable, // disable fpn filter if images are known to be too close boolean fpn_disable, // disable fpn filter if images are known to be too close
boolean disable_ers,
double [] min_max, // null or pair of minimal and maximal offsets double [] min_max, // null or pair of minimal and maximal offsets
int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
QuadCLT reference_QuadClt, QuadCLT reference_QuadClt,
...@@ -1533,6 +1541,7 @@ public class Interscene { ...@@ -1533,6 +1541,7 @@ public class Interscene {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
true, // boolean initial_adjust, true, // boolean initial_adjust,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
disable_ers, // boolean disable_ers,
min_max, // double [] min_max, // null or pair of minimal and maximal offsets min_max, // double [] min_max, // null or pair of minimal and maximal offsets
fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max fail_reason, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
reference_QuadClt, // QuadCLT reference_QuadClt, reference_QuadClt, // QuadCLT reference_QuadClt,
...@@ -1561,6 +1570,7 @@ public class Interscene { ...@@ -1561,6 +1570,7 @@ public class Interscene {
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean initial_adjust, boolean initial_adjust,
boolean fpn_disable, // disable fpn filter if images are known to be too close boolean fpn_disable, // disable fpn filter if images are known to be too close
boolean disable_ers,
double [] min_max, // null or pair of minimal and maximal offsets double [] min_max, // null or pair of minimal and maximal offsets
int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
QuadCLT reference_QuadClt, QuadCLT reference_QuadClt,
...@@ -1641,9 +1651,8 @@ public class Interscene { ...@@ -1641,9 +1651,8 @@ public class Interscene {
for (int i:ErsCorrection.DP_ERS_INDICES) { for (int i:ErsCorrection.DP_ERS_INDICES) {
ers_lma |= param_select[i]; ers_lma |= param_select[i];
} }
boolean disable_ers=false;
boolean [] param_select_mod = param_select; boolean [] param_select_mod = param_select;
if (ers_lma && filter_by_ers) { if (ers_lma && filter_by_ers && !disable_ers) {
double [][] quad_strengths = getQuadStrengths( double [][] quad_strengths = getQuadStrengths(
coord_motion, // double [][][] coord_motion, coord_motion, // double [][][] coord_motion,
gap_frac, //double gap_frac, // 0.25 gap_frac, //double gap_frac, // 0.25
...@@ -1651,9 +1660,19 @@ public class Interscene { ...@@ -1651,9 +1660,19 @@ public class Interscene {
for (int i = 0; i < quad_strengths[0].length; i++) { for (int i = 0; i < quad_strengths[0].length; i++) {
if ((quad_strengths[0][i] < min_quad_tiles) || (quad_strengths[1][i] < min_quad_weight)) { if ((quad_strengths[0][i] < min_quad_tiles) || (quad_strengths[1][i] < min_quad_weight)) {
disable_ers = true; disable_ers = true;
if (clt_parameters.imp.debug_level > -2) {
System.out.print("adjustPairsLMAInterscene(): insufficient data for ERS, skipping. ");
System.out.println ("quad_defined = ["+((int)quad_strengths[0][0])+","
+((int)quad_strengths[0][1])+","+((int)quad_strengths[0][2])+","+((int)quad_strengths[0][3])+"] (needed = "+
min_quad_tiles +"), rel_strengths = ["
+quad_strengths[1][0]+","+quad_strengths[1][1]+","
+quad_strengths[1][2]+","+quad_strengths[1][3]+"] (needed "
+min_quad_weight+")");
}
break; break;
} }
} }
}
if (disable_ers) { if (disable_ers) {
param_select_mod = param_select.clone(); param_select_mod = param_select.clone();
for (int i:ErsCorrection.DP_ERS_INDICES) { for (int i:ErsCorrection.DP_ERS_INDICES) {
...@@ -1664,18 +1683,7 @@ public class Interscene { ...@@ -1664,18 +1683,7 @@ public class Interscene {
ErsCorrection ers_scene = scene_QuadClt.getErsCorrection(); ErsCorrection ers_scene = scene_QuadClt.getErsCorrection();
ers_scene.ers_watr_center_dt = ers_ref.ers_watr_center_dt.clone(); ers_scene.ers_watr_center_dt = ers_ref.ers_watr_center_dt.clone();
ers_scene.ers_wxyz_center_dt = ers_ref.ers_wxyz_center_dt.clone(); ers_scene.ers_wxyz_center_dt = ers_ref.ers_wxyz_center_dt.clone();
if (clt_parameters.imp.debug_level > -2) {
System.out.print("adjustPairsLMAInterscene(): insufficient data for ERS, skipping. ");
System.out.println ("quad_defined = ["+((int)quad_strengths[0][0])+","
+((int)quad_strengths[0][1])+","+((int)quad_strengths[0][2])+","+((int)quad_strengths[0][3])+"] (needed = "+
min_quad_tiles +"), rel_strengths = ["
+quad_strengths[1][0]+","+quad_strengths[1][1]+","
+quad_strengths[1][2]+","+quad_strengths[1][3]+"] (needed "
+min_quad_weight+")");
}
} }
}
intersceneLma.prepareLMA( intersceneLma.prepareLMA(
camera_xyz0, // final double [] scene_xyz0, // camera center in world coordinates (or null to use instance) camera_xyz0, // final double [] scene_xyz0, // camera center in world coordinates (or null to use instance)
camera_atr0, // final double [] scene_atr0, // camera orientation relative to world frame (or null to use instance) camera_atr0, // final double [] scene_atr0, // camera orientation relative to world frame (or null to use instance)
......
...@@ -44,6 +44,16 @@ public class IntersceneMatchParameters { ...@@ -44,6 +44,16 @@ public class IntersceneMatchParameters {
public boolean sfm_use = true; // use SfM to improve depth map public boolean sfm_use = true; // use SfM to improve depth map
public double sfm_min_base = 2.0; // use SfM if baseline exceeds this public double sfm_min_base = 2.0; // use SfM if baseline exceeds this
public int sfm_num_pairs = 16; // desired number of SfM pairs to average
public double sfp_tolerance = 0.05; // average SfM pairs if their baselines differ less
public int sfm_readjust = 5; // number of SfM readjustment cycles
public double sfm_prev_frac = 0.6; // update if new sfm gain > this fraction of the old one
public int sfm_shrink = 2; // shrink sfm gain area before applying sfm_fade_sigma
public double sfm_fade_sigma = 3.0; // fade SfM gains at the edges
public double sfm_min_str = 0.4; // update if correction strength exceeds
public boolean sfm_use_neibs = true; // use neighbors if individual corr is too weak
public double sfm_neib_too_str= 0.4; // do not count neighbors stronger than that
public double sfm_neib_str= 0.5; // update if no-individual and neibs correction strength exceeds
public double [] getImsMountATR() { public double [] getImsMountATR() {
...@@ -443,6 +453,28 @@ public class IntersceneMatchParameters { ...@@ -443,6 +453,28 @@ public class IntersceneMatchParameters {
gd.addNumericField("Minimal SfM baseline", this.sfm_min_base, 5,8,"m", gd.addNumericField("Minimal SfM baseline", this.sfm_min_base, 5,8,"m",
"Use SfM only if the baseline (lateral offset between scenes in a series) exceeds this value."); "Use SfM only if the baseline (lateral offset between scenes in a series) exceeds this value.");
gd.addNumericField("Number of SfM pairs to average", this.sfm_num_pairs, 0,3,"",
"Desired number of SfM pairs to average, will be reduced if not enough or tolerance (below) is violated.");
gd.addNumericField("SfP inter-pair baseline tolerance", this.sfp_tolerance, 5,8,"",
"Average SfM pairs if their baselines differ less.");
gd.addNumericField("Readjust SfM cycles", this.sfm_readjust, 0,3,"",
"Number of SfM readjustment cycles.");
gd.addNumericField("Minimal SfM gain from previous", this.sfm_prev_frac, 5,8,"",
"Update if new sfm gain > this fraction of the old one.");
gd.addNumericField("Shrink SfM area", this.sfm_shrink, 0,3,"",
"Shrink sfm gain area before applying sfm_fade_sigmas.");
gd.addNumericField("Fade SfM area sigma", this.sfm_fade_sigma, 5,8,"",
"Fade SfM gains at the edges.");
gd.addNumericField("Minimal correlation strength", this.sfm_min_str, 5,8,"",
"Update if correction strength of individual tiles exceeds.");
gd.addCheckbox ("Use neighbors", this.sfm_use_neibs,
"Use neighbors if individual corr is too weak.");
gd.addNumericField("Too strong neighbors", this.sfm_neib_too_str, 5,8,"",
"Do not accumulate neighbors stronger than that.");
gd.addNumericField("Minimal neighbors strength", this.sfm_neib_str, 5,8,"",
"Update if no-individual and neighbors correction strength exceeds this.");
gd.addTab ("Scene Series", "Processing series of scenes and multi-series sets"); gd.addTab ("Scene Series", "Processing series of scenes and multi-series sets");
gd.addMessage ("Build series options"); gd.addMessage ("Build series options");
...@@ -1114,6 +1146,16 @@ public class IntersceneMatchParameters { ...@@ -1114,6 +1146,16 @@ public class IntersceneMatchParameters {
this.ims_mount_xyz = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 3); this.ims_mount_xyz = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 3);
this.sfm_use = gd.getNextBoolean(); this.sfm_use = gd.getNextBoolean();
this.sfm_min_base = gd.getNextNumber(); this.sfm_min_base = gd.getNextNumber();
this.sfm_num_pairs = (int) gd.getNextNumber();
this.sfp_tolerance = gd.getNextNumber();
this.sfm_readjust = (int) gd.getNextNumber();
this.sfm_prev_frac = gd.getNextNumber();
this.sfm_shrink = (int) gd.getNextNumber();
this.sfm_fade_sigma = gd.getNextNumber();
this.sfm_min_str = gd.getNextNumber();
this.sfm_use_neibs = gd.getNextBoolean();
this.sfm_neib_too_str = gd.getNextNumber();
this.sfm_neib_str = gd.getNextNumber();
this.center_reference = gd.getNextBoolean(); this.center_reference = gd.getNextBoolean();
this.force_ref_dsi = gd.getNextBoolean(); this.force_ref_dsi = gd.getNextBoolean();
this.force_orientations = gd.getNextBoolean(); this.force_orientations = gd.getNextBoolean();
...@@ -1469,6 +1511,16 @@ public class IntersceneMatchParameters { ...@@ -1469,6 +1511,16 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"ims_mount_xyz", IntersceneMatchParameters.doublesToString(this.ims_mount_xyz)); properties.setProperty(prefix+"ims_mount_xyz", IntersceneMatchParameters.doublesToString(this.ims_mount_xyz));
properties.setProperty(prefix+"sfm_use", this.sfm_use + ""); // boolean properties.setProperty(prefix+"sfm_use", this.sfm_use + ""); // boolean
properties.setProperty(prefix+"sfm_min_base", this.sfm_min_base+""); // double properties.setProperty(prefix+"sfm_min_base", this.sfm_min_base+""); // double
properties.setProperty(prefix+"sfm_num_pairs", this.sfm_num_pairs+""); // int
properties.setProperty(prefix+"sfp_tolerance", this.sfp_tolerance+""); // double
properties.setProperty(prefix+"sfm_readjust", this.sfm_readjust+""); // int
properties.setProperty(prefix+"sfm_prev_frac", this.sfm_prev_frac+""); // double
properties.setProperty(prefix+"sfm_shrink", this.sfm_shrink+""); // int
properties.setProperty(prefix+"sfm_fade_sigma", this.sfm_fade_sigma+""); // double
properties.setProperty(prefix+"sfm_min_str", this.sfm_min_str+""); // double
properties.setProperty(prefix+"sfm_use_neibs", this.sfm_use_neibs+""); // boolean
properties.setProperty(prefix+"sfm_neib_too_str", this.sfm_neib_too_str+""); // double
properties.setProperty(prefix+"sfm_neib_str", this.sfm_neib_str +""); // double
properties.setProperty(prefix+"center_reference", this.center_reference + ""); // boolean properties.setProperty(prefix+"center_reference", this.center_reference + ""); // boolean
properties.setProperty(prefix+"force_ref_dsi", this.force_ref_dsi + ""); // boolean properties.setProperty(prefix+"force_ref_dsi", this.force_ref_dsi + ""); // boolean
properties.setProperty(prefix+"force_orientations", this.force_orientations + ""); // boolean properties.setProperty(prefix+"force_orientations", this.force_orientations + ""); // boolean
...@@ -1784,6 +1836,16 @@ public class IntersceneMatchParameters { ...@@ -1784,6 +1836,16 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"ims_mount_xyz")!=null) this.ims_mount_xyz= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"ims_mount_xyz"),3); if (properties.getProperty(prefix+"ims_mount_xyz")!=null) this.ims_mount_xyz= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"ims_mount_xyz"),3);
if (properties.getProperty(prefix+"sfm_use")!=null) this.sfm_use=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_use")); if (properties.getProperty(prefix+"sfm_use")!=null) this.sfm_use=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_use"));
if (properties.getProperty(prefix+"sfm_min_base")!=null) this.sfm_min_base=Double.parseDouble(properties.getProperty(prefix+"sfm_min_base")); if (properties.getProperty(prefix+"sfm_min_base")!=null) this.sfm_min_base=Double.parseDouble(properties.getProperty(prefix+"sfm_min_base"));
if (properties.getProperty(prefix+"sfm_num_pairs")!=null) this.sfm_num_pairs=Integer.parseInt(properties.getProperty(prefix+"sfm_num_pairs"));
if (properties.getProperty(prefix+"sfp_tolerance")!=null) this.sfp_tolerance=Double.parseDouble(properties.getProperty(prefix+"sfp_tolerance"));
if (properties.getProperty(prefix+"sfm_readjust")!=null) this.sfm_readjust=Integer.parseInt(properties.getProperty(prefix+"sfm_readjust"));
if (properties.getProperty(prefix+"sfm_prev_frac")!=null) this.sfm_prev_frac=Double.parseDouble(properties.getProperty(prefix+"sfm_prev_frac"));
if (properties.getProperty(prefix+"sfm_shrink")!=null) this.sfm_shrink=Integer.parseInt(properties.getProperty(prefix+"sfm_shrink"));
if (properties.getProperty(prefix+"sfm_fade_sigma")!=null) this.sfm_fade_sigma=Double.parseDouble(properties.getProperty(prefix+"sfm_fade_sigma"));
if (properties.getProperty(prefix+"sfm_min_str")!=null) this.sfm_min_str=Double.parseDouble(properties.getProperty(prefix+"sfm_min_str"));
if (properties.getProperty(prefix+"sfm_use_neibs")!=null) this.sfm_use_neibs=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_use_neibs"));
if (properties.getProperty(prefix+"sfm_neib_too_str")!=null) this.sfm_neib_too_str=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_too_str"));
if (properties.getProperty(prefix+"sfm_neib_str")!=null) this.sfm_neib_str=Double.parseDouble(properties.getProperty(prefix+"sfm_neib_str"));
if (properties.getProperty(prefix+"center_reference")!=null) this.center_reference=Boolean.parseBoolean(properties.getProperty(prefix+"center_reference")); if (properties.getProperty(prefix+"center_reference")!=null) this.center_reference=Boolean.parseBoolean(properties.getProperty(prefix+"center_reference"));
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_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+"force_orientations")!=null) this.force_orientations=Boolean.parseBoolean(properties.getProperty(prefix+"force_orientations"));
...@@ -2126,6 +2188,16 @@ public class IntersceneMatchParameters { ...@@ -2126,6 +2188,16 @@ public class IntersceneMatchParameters {
imp.ims_mount_xyz = this.ims_mount_xyz.clone(); imp.ims_mount_xyz = this.ims_mount_xyz.clone();
imp.sfm_use = this.sfm_use; imp.sfm_use = this.sfm_use;
imp.sfm_min_base = this.sfm_min_base; imp.sfm_min_base = this.sfm_min_base;
imp.sfm_num_pairs = this.sfm_num_pairs;
imp.sfp_tolerance = this.sfp_tolerance;
imp.sfm_readjust = this.sfm_readjust;
imp.sfm_prev_frac = this.sfm_prev_frac;
imp.sfm_shrink = this.sfm_shrink;
imp.sfm_fade_sigma = this.sfm_fade_sigma;
imp.sfm_min_str = this.sfm_min_str;
imp.sfm_use_neibs = this.sfm_use_neibs;
imp.sfm_neib_too_str = this.sfm_neib_too_str;
imp.sfm_neib_str = this.sfm_neib_str;
imp.center_reference = this.center_reference; imp.center_reference = this.center_reference;
imp.force_ref_dsi = this.force_ref_dsi; imp.force_ref_dsi = this.force_ref_dsi;
imp.force_orientations = this.force_orientations; imp.force_orientations = this.force_orientations;
......
...@@ -3572,6 +3572,7 @@ public class OpticalFlow { ...@@ -3572,6 +3572,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.use_lma_dsi, clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
false, // boolean disable_ers,
null, // double [] min_max, // null or pair of minimal and maximal offsets null, // double [] min_max, // null or pair of minimal and maximal offsets
null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
...@@ -4885,7 +4886,7 @@ public class OpticalFlow { ...@@ -4885,7 +4886,7 @@ public class OpticalFlow {
boolean OK = false; boolean OK = false;
int es1 = -1; int es1 = -1;
if (center_reference) { if (center_reference) {
ref_index = Interscene.setInitialOrientationsCenterIms( es1 = Interscene.setInitialOrientationsCenterIms(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
min_num_scenes, // int min_num_scenes, min_num_scenes, // int min_num_scenes,
colorProcParameters, // final ColorProcParameters colorProcParameters, colorProcParameters, // final ColorProcParameters colorProcParameters,
...@@ -4896,14 +4897,20 @@ public class OpticalFlow { ...@@ -4896,14 +4897,20 @@ public class OpticalFlow {
last_index, // final int ref_index, last_index, // final int ref_index,
set_channels, // final QuadCLT.SetChannels [] set_channels, set_channels, // final QuadCLT.SetChannels [] set_channels,
batch_mode, // final boolean batch_mode, batch_mode, // final boolean batch_mode,
earliest_scene, // int earliest_scene, earliest_scene, // int ,
start_ref_pointers, // int [] start_ref_pointers, // [0] - earliest valid scene, [1] ref_index start_ref_pointers, // int [] start_ref_pointers, // [0] - earliest valid scene, [1] ref_index
threadsMax, // final int threadsMax, threadsMax, // final int threadsMax,
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); debugLevel);
OK = ref_index >= 0; OK = es1 >= 0;
if (OK) {
ref_index =quadCLTs[last_index].getReferenceIndex(quadCLTs);
int [] first_last_index = quadCLTs[ref_index].getFirstLastIndex(quadCLTs);
earliest_scene = first_last_index[0];
last_index = first_last_index[1];
}
} else if (ims_use) { } else if (ims_use) {
es1 = Interscene.setInitialOrientationsIms( earliest_scene = Interscene.setInitialOrientationsIms(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
min_num_scenes, // int min_num_scenes, min_num_scenes, // int min_num_scenes,
colorProcParameters, // final ColorProcParameters colorProcParameters, colorProcParameters, // final ColorProcParameters colorProcParameters,
...@@ -4916,9 +4923,9 @@ public class OpticalFlow { ...@@ -4916,9 +4923,9 @@ public class OpticalFlow {
threadsMax, // final int threadsMax, threadsMax, // final int threadsMax,
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
OK = es1 >=0; OK = earliest_scene >=0;
} else { } else {
es1= Interscene.setInitialOrientations( earliest_scene= Interscene.setInitialOrientations(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
min_num_scenes, // int min_num_scenes, min_num_scenes, // int min_num_scenes,
colorProcParameters, // final ColorProcParameters colorProcParameters, colorProcParameters, // final ColorProcParameters colorProcParameters,
...@@ -4931,7 +4938,7 @@ public class OpticalFlow { ...@@ -4931,7 +4938,7 @@ public class OpticalFlow {
threadsMax, // final int threadsMax, threadsMax, // final int threadsMax,
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
OK = es1 >=0; OK = earliest_scene >=0;
} }
if (!OK) { if (!OK) {
return null; return null;
...@@ -5033,7 +5040,7 @@ public class OpticalFlow { ...@@ -5033,7 +5040,7 @@ public class OpticalFlow {
debugLevel); // final int debugLevel) debugLevel); // final int debugLevel)
*/ */
// int num_avg_pairs = 16; // number of scene pairs to average // int num_avg_pairs = 16; // number of scene pairs to average
int num_avg_pairs = 1; // number of scene pairs to average int num_avg_pairs = clt_parameters.imp.sfm_num_pairs; // number of scene pairs to average
QuadCLT[][][] scenes_seq_pairs = new QuadCLT[3][num_avg_pairs][2]; QuadCLT[][][] scenes_seq_pairs = new QuadCLT[3][num_avg_pairs][2];
for (int i = 0; i < num_avg_pairs; i++) { for (int i = 0; i < num_avg_pairs; i++) {
scenes_seq_pairs[0][i][0] = quadCLTs[ref_index + num_avg_pairs - 1 - i]; scenes_seq_pairs[0][i][0] = quadCLTs[ref_index + num_avg_pairs - 1 - i];
...@@ -5045,7 +5052,19 @@ public class OpticalFlow { ...@@ -5045,7 +5052,19 @@ public class OpticalFlow {
scenes_seq_pairs[2][i][0] = quadCLTs[last_index - i]; scenes_seq_pairs[2][i][0] = quadCLTs[last_index - i];
scenes_seq_pairs[2][i][1] = quadCLTs[earliest_scene + num_avg_pairs - 1 - i]; scenes_seq_pairs[2][i][1] = quadCLTs[earliest_scene + num_avg_pairs - 1 - i];
} }
double [][] sfm_dsn = StructureFromMotion.sfmPairsSet(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs[ref_index], // final QuadCLT ref_scene,
scenes_seq_pairs, // scenes_pairs, // final QuadCLT [][] scenes_pairs,
mb_max_gain, // double mb_max_gain,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel)
if (sfm_dsn != null) {
combo_dsn_final = sfm_dsn;
done_sfm = true;
}
/*
for (int num_seq = 0; num_seq < scenes_seq_pairs.length; num_seq++) { for (int num_seq = 0; num_seq < scenes_seq_pairs.length; num_seq++) {
double [][] sfm_dsn = StructureFromMotion.sfmPair( double [][] sfm_dsn = StructureFromMotion.sfmPair(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
...@@ -5059,6 +5078,7 @@ public class OpticalFlow { ...@@ -5059,6 +5078,7 @@ public class OpticalFlow {
done_sfm = true; done_sfm = true;
} }
} }
*/
} }
if (!done_sfm) { // first pass or sfm failed if (!done_sfm) { // first pass or sfm failed
// should skip scenes w/o orientation 06/29/2022 // should skip scenes w/o orientation 06/29/2022
...@@ -5119,9 +5139,11 @@ public class OpticalFlow { ...@@ -5119,9 +5139,11 @@ public class OpticalFlow {
if (quadCLTs[ref_index].getNumOrient() < (min_num_orient - 1)) { if (quadCLTs[ref_index].getNumOrient() < (min_num_orient - 1)) {
mb_max_gain = clt_parameters.imp.mb_max_gain_inter; mb_max_gain = clt_parameters.imp.mb_max_gain_inter;
} }
boolean disable_ers = (quadCLTs[ref_index].getNumOrient() < 2); // first orient - no ERS!
earliest_scene = Interscene.reAdjustPairsLMAInterscene( // after combo dsi is available and preliminary poses are known earliest_scene = Interscene.reAdjustPairsLMAInterscene( // after combo dsi is available and preliminary poses are known
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
mb_max_gain, // double mb_max_gain, mb_max_gain, // double mb_max_gain,
disable_ers, // boolean disable_ers,
reliable_ref, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles reliable_ref, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
ref_index, // int ref_index, ref_index, // int ref_index,
...@@ -6698,6 +6720,7 @@ public class OpticalFlow { ...@@ -6698,6 +6720,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.use_lma_dsi, clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
false, // boolean disable_ers,
null, // double [] min_max, // null or pair of minimal and maximal offsets null, // double [] min_max, // null or pair of minimal and maximal offsets
null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
quadCLTs[other_ref[1]], // QuadCLT reference_QuadCLT, quadCLTs[other_ref[1]], // QuadCLT reference_QuadCLT,
...@@ -7267,6 +7290,7 @@ public class OpticalFlow { ...@@ -7267,6 +7290,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.use_lma_dsi, clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
false, // boolean disable_ers,
null, // double [] min_max, // null or pair of minimal and maximal offsets null, // double [] min_max, // null or pair of minimal and maximal offsets
null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
...@@ -7381,6 +7405,7 @@ public class OpticalFlow { ...@@ -7381,6 +7405,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.use_lma_dsi, clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
false, // boolean disable_ers,
null, // double [] min_max, // null or pair of minimal and maximal offsets null, // double [] min_max, // null or pair of minimal and maximal offsets
null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
...@@ -7527,6 +7552,7 @@ public class OpticalFlow { ...@@ -7527,6 +7552,7 @@ public class OpticalFlow {
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.use_lma_dsi, clt_parameters.imp.use_lma_dsi,
false, // boolean fpn_disable, // disable fpn filter if images are known to be too close false, // boolean fpn_disable, // disable fpn filter if images are known to be too close
false, // boolean disable_ers,
null, // double [] min_max, // null or pair of minimal and maximal offsets null, // double [] min_max, // null or pair of minimal and maximal offsets
null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max null, // int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
reference_QuadClt, // QuadCLT reference_QuadCLT, reference_QuadClt, // QuadCLT reference_QuadCLT,
...@@ -11927,7 +11953,7 @@ public class OpticalFlow { ...@@ -11927,7 +11953,7 @@ public class OpticalFlow {
final int tilesY = scene.getTileProcessor().getTilesY(); final int tilesY = scene.getTileProcessor().getTilesY();
final int transform_size = scene.getTileProcessor().getTileSize(); final int transform_size = scene.getTileProcessor().getTileSize();
final int tiles =tilesX * tilesY; final int tiles =tilesX * tilesY;
boolean debug_images = (debug_level > 0) && clt_parameters.ofp.enable_debug_images;
String [] dbg_titles = {"str", "lma", "clean-lma", "disp","-sky","-lma","by-lma","-nonlma", "few_weak", "old-disp","old-sngl","weak","filled"}; String [] dbg_titles = {"str", "lma", "clean-lma", "disp","-sky","-lma","by-lma","-nonlma", "few_weak", "old-disp","old-sngl","weak","filled"};
double [][] dbg_img = new double [dbg_titles.length][]; double [][] dbg_img = new double [dbg_titles.length][];
double [] clean_lma = dls[1].clone(); double [] clean_lma = dls[1].clone();
...@@ -12121,7 +12147,7 @@ public class OpticalFlow { ...@@ -12121,7 +12147,7 @@ public class OpticalFlow {
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
if ((debug_level > 0) && (clt_parameters.ofp.enable_debug_images)) { if (debug_images) {
dbg_titles = new String[]{"disp", "disp_outliers", "disp_blur", "disp_filled", "str", "str_filled"}; dbg_titles = new String[]{"disp", "disp_outliers", "disp_blur", "disp_filled", "str", "str_filled"};
dbg_img = new double[][]{dls[0], disp_outliers, ds[0], ds_filled[0], ds[1], ds_filled[1]}; dbg_img = new double[][]{dls[0], disp_outliers, ds[0], ds_filled[0], ds[1], ds_filled[1]};
ShowDoubleFloatArrays.showArrays( ShowDoubleFloatArrays.showArrays(
......
...@@ -255,6 +255,10 @@ public class TDCorrTile { ...@@ -255,6 +255,10 @@ public class TDCorrTile {
* @param neib_weights_od 2-element array of the relative (to the center tile) weights * @param neib_weights_od 2-element array of the relative (to the center tile) weights
* of neighbors in four orthogonal [0] and four diagonal [1] * of neighbors in four orthogonal [0] and four diagonal [1]
* directions. * directions.
* @param corr_pd pixel-domain phase correlation corresponding to tiles to discard too
* strong neighbors. They likely belong the foreground while this (weak)
* is from the background. If null - do not filter by strength.
* @param neib_too_strong discard stronger neighbors from accumulating.
* @param process_all process tiles even if the center tile is null. False - process only * @param process_all process tiles even if the center tile is null. False - process only
* the tiles around non-null ones. * the tiles around non-null ones.
* @return * @return
...@@ -263,6 +267,8 @@ public class TDCorrTile { ...@@ -263,6 +267,8 @@ public class TDCorrTile {
TDCorrTile [] tiles, TDCorrTile [] tiles,
final int tilesX, final int tilesX,
double [] neib_weights_od, // {orhto, diag} double [] neib_weights_od, // {orhto, diag}
double [][] corr_pd,
double neib_too_strong,
final boolean process_all final boolean process_all
) { ) {
final int tilesY = tiles.length / tilesX; final int tilesY = tiles.length / tilesX;
...@@ -286,6 +292,16 @@ public class TDCorrTile { ...@@ -286,6 +292,16 @@ public class TDCorrTile {
for (int dir = 0; dir < tn.dirs; dir++) { for (int dir = 0; dir < tn.dirs; dir++) {
int iTile1 = tn.getNeibIndex(iTile, dir); int iTile1 = tn.getNeibIndex(iTile, dir);
if ((iTile1 >=0) && (tiles[iTile1] != null)) { if ((iTile1 >=0) && (tiles[iTile1] != null)) {
if ((corr_pd != null) && (corr_pd[iTile1] != null)) {
boolean is_weak = true;
for (double s:corr_pd[iTile1]) if (s >= neib_too_strong) {
is_weak = false;
break;
}
if (!is_weak) {
continue; // skip this strong neighbor from accumulating
}
}
if (rslt[iTile] == null) { if (rslt[iTile] == null) {
rslt[iTile] = tiles[iTile1].clone(); rslt[iTile] = tiles[iTile1].clone();
rslt[iTile].scale(weights[dir]); rslt[iTile].scale(weights[dir]);
...@@ -413,12 +429,18 @@ public class TDCorrTile { ...@@ -413,12 +429,18 @@ public class TDCorrTile {
int nTile = (indices[nt * num_pairs] >> GPUTileProcessor.CORR_NTILE_SHIFT); int nTile = (indices[nt * num_pairs] >> GPUTileProcessor.CORR_NTILE_SHIFT);
int fdata_offset = (nt * num_pairs + index_combo) * corr_size_td; int fdata_offset = (nt * num_pairs + index_combo) * corr_size_td;
double [] tile_data = new double [corr_size_td]; double [] tile_data = new double [corr_size_td];
copy_data: {
for (int i = 0; i < tile_data.length; i++) { for (int i = 0; i < tile_data.length; i++) {
tile_data[i] =fdata[fdata_offset+i]; double d = fdata[fdata_offset+i];
if (Double.isNaN(d)) {
break copy_data; // accumulated tile may be NaN
}
tile_data[i] =d;
} }
tiles[nTile] = new TDCorrTile (index_combo, tile_data); // default weight = 16? tiles[nTile] = new TDCorrTile (index_combo, tile_data); // default weight = 16?
} }
} }
}
}; };
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
......
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