Commit bc3b706a authored by Andrey Filippov's avatar Andrey Filippov

disabling SfM if there is not much movement

parent f760790f
......@@ -44,6 +44,9 @@ public class IntersceneMatchParameters {
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_gain = 5.0; // Minimal SfM gain to apply SfM to the depth map
public double sfm_min_frac = 0.5; // Minimal fraction of defined tiles to have SfM correction
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
......@@ -461,8 +464,10 @@ public class IntersceneMatchParameters {
"Use SfM for the depth map enhancement for laterally moving camera.");
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.");
gd.addNumericField("Minimal SfM gain", this.sfm_min_gain, 5,8,"",
"Minimal SfM gain to apply SfM to the depth map.");
gd.addNumericField("Minimal SfM fraction", this.sfm_min_frac, 5,8,"",
"Minimal fraction of defined tiles to have SfM correction.");
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,"",
......@@ -1174,6 +1179,8 @@ public class IntersceneMatchParameters {
this.ims_mount_xyz = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 3);
this.sfm_use = gd.getNextBoolean();
this.sfm_min_base = gd.getNextNumber();
this.sfm_min_gain = gd.getNextNumber();
this.sfm_min_frac = gd.getNextNumber();
this.sfm_num_pairs = (int) gd.getNextNumber();
this.sfp_tolerance = gd.getNextNumber();
this.sfm_readjust = (int) gd.getNextNumber();
......@@ -1549,6 +1556,8 @@ public class IntersceneMatchParameters {
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_min_base", this.sfm_min_base+""); // double
properties.setProperty(prefix+"sfm_min_gain", this.sfm_min_gain+""); // double
properties.setProperty(prefix+"sfm_min_frac", this.sfm_min_frac+""); // 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
......@@ -1884,6 +1893,8 @@ 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+"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_gain")!=null) this.sfm_min_gain=Double.parseDouble(properties.getProperty(prefix+"sfm_min_gain"));
if (properties.getProperty(prefix+"sfm_min_frac")!=null) this.sfm_min_frac=Double.parseDouble(properties.getProperty(prefix+"sfm_min_frac"));
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"));
......@@ -2246,6 +2257,8 @@ public class IntersceneMatchParameters {
imp.ims_mount_xyz = this.ims_mount_xyz.clone();
imp.sfm_use = this.sfm_use;
imp.sfm_min_base = this.sfm_min_base;
imp.sfm_min_gain = this.sfm_min_gain;
imp.sfm_min_frac = this.sfm_min_frac;
imp.sfm_num_pairs = this.sfm_num_pairs;
imp.sfp_tolerance = this.sfp_tolerance;
imp.sfm_readjust = this.sfm_readjust;
......
......@@ -4775,8 +4775,54 @@ public class OpticalFlow {
// 1. Reference scene DSI
// while ((quadCLTs[ref_index] == null) || (quadCLTs[ref_index].getBlueSky() == null)) { // null
// String center_ts = null; // name of the center scene - not yet known
double [][] combo_dsn_final = null;
while ((quadCLTs[last_index] == null) || !quadCLTs[last_index].hasBlueSky()) { // null
//hasBlueSky()
// creating early photometric
/*
if (photo_en && !reuse_video) {
if (debugLevel > -3) {
System.out.println("**** Running photometric equalization *****");
}
if (combo_dsn_final == null) { // always re-read?
/// combo_dsn_final =quadCLTs[ref_index].readDoubleArrayFromModelDirectory( // always re-read?
/// "-INTER-INTRA-LMA", // String suffix,
/// 0, // int num_slices, // (0 - all)
/// null); // int [] wh);
combo_dsn_final =quadCLTs[ref_index].restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky
}
double [][] combo_dsn_final_filtered =
conditionComboDsnFinal(
true, // boolean use_conf, // use configuration parameters, false - use following
clt_parameters, // CLTParameters clt_parameters,
combo_dsn_final, // double [][] combo_dsn_final, // dls,
quadCLTs[ref_index], // QuadCLT scene,
debugLevel); // int debugLevel);// > 0
// replace
runPhotometric(
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
set_channels[ref_index].set_name, // String set_name
quadCLTs, // QuadCLT[] quadCLTs,
earliest_scene, // int earliest_scene,
last_index, // int last_scene,
ref_index, // int ref_index,
combo_dsn_final_filtered, // double [][] combo_dsn_final_filtered,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel);
} else {
if (debugLevel> -3) {
System.out.println("Using photometric calibration from scene "+quadCLTs[ref_index].getPhotometricScene());
}
}
*/
if (build_ref_dsi) {
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing?
......@@ -5017,7 +5063,7 @@ public class OpticalFlow {
// just in case that orientations were calculated before:
// earliest_scene = getEarliestScene(quadCLTs);
double [][] combo_dsn_final = null;
// double [][] combo_dsn_final = null;
// below ref_index is not necessary the last (fix all where it is supposed to be the last
ErsCorrection ers_reference = quadCLTs[ref_index].getErsCorrection();
while (!reuse_video && ((quadCLTs[ref_index].getNumOrient() < min_num_orient) || (quadCLTs[ref_index].getNumAccum() < min_num_interscene))) {
......@@ -5049,6 +5095,8 @@ public class OpticalFlow {
}
}
QuadCLT[][][] scenes_seq_pairs = new QuadCLT[3][num_avg_pairs][2];
// TODO: calculate horizontal offset and compare with sfm_min_base
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][1] = quadCLTs[earliest_scene + num_avg_pairs - 1 - i];
......
......@@ -6261,9 +6261,13 @@ public class QuadCLTCPU {
int [][] fileIndices=new int [numImagesToProcess][2]; // file index, channel number
int index=0;
for (int nFile=0;nFile<enabledFiles.length;nFile++){ // enabledFiles not used anymore?
// if ((single_set_name != null) && (correctionsParameters.getNameFromTiff(sourceFiles[nFile])==null)) {
// System.out.println("sourceFiles["+nFile+"]==null");
// continue;
// }
if ( (sourceFiles[nFile]!=null) &&
(sourceFiles[nFile].length()>1) &&
((single_set_name == null) || (correctionsParameters.getNameFromTiff(sourceFiles[nFile]).contains(single_set_name)))) { // not used in lwir
((single_set_name == null) || ((correctionsParameters.getNameFromTiff(sourceFiles[nFile]) != null)&& correctionsParameters.getNameFromTiff(sourceFiles[nFile]).contains(single_set_name)))) { // not used in lwir
int [] channels= fileChannelToSensorChannels(correctionsParameters.getChannelFromSourceTiff(sourceFiles[nFile]));
if (channels!=null){
for (int i=0;i<channels.length;i++) if (eyesisCorrections.isChannelEnabled(channels[i])){
......@@ -6690,6 +6694,16 @@ public class QuadCLTCPU {
pixels[i] += fcorr;
}
}
} else {
for (int i = 0; i < imp_srcs.length; i++) {
if (ImagejJp4Tiff.needsFix000E6410C435(imp_srcs[i])) {
needs_fix = i;
break; // only one, and always 6
}
}
if (needs_fix >= 0) {
System.out.println("Need to correct "+imp_srcs[needs_fix].getTitle()+" **************");
}
}
channelLwirApplyEqualize( // now apply (was part of channelLwirEqualize() )
......
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