Commit 99fcbcc4 authored by Andrey Filippov's avatar Andrey Filippov

Debugging, IMU-ERS

parent bc3b706a
...@@ -763,7 +763,7 @@ public class CalibrationIllustration { ...@@ -763,7 +763,7 @@ public class CalibrationIllustration {
try { try {
Files.createSymbolicLink(newLink, target); Files.createSymbolicLink(newLink, target);
} catch (IOException x) { } catch (IOException x) {
System.err.println(x); System.out.println(x);
} catch (UnsupportedOperationException x) { } catch (UnsupportedOperationException x) {
// Some file systems do not support symbolic links. // Some file systems do not support symbolic links.
System.err.println(x); System.err.println(x);
...@@ -775,7 +775,7 @@ public class CalibrationIllustration { ...@@ -775,7 +775,7 @@ public class CalibrationIllustration {
return true; return true;
} }
public int [] getStartEndTS(String p) { public static int [] getStartEndTS(String p) {
int istart = p.lastIndexOf(Prefs.getFileSeparator()); int istart = p.lastIndexOf(Prefs.getFileSeparator());
if (istart < 0) { if (istart < 0) {
istart = 0; istart = 0;
......
...@@ -267,6 +267,7 @@ public class EventLogger { ...@@ -267,6 +267,7 @@ public class EventLogger {
byte [][] payload, byte [][] payload,
int debug_level) throws IOException // initialize to [2][] - will return a pair of byte arrays int debug_level) throws IOException // initialize to [2][] - will return a pair of byte arrays
{ {
int min_debug = 1; //-1 to enable
// 1 find file with the first subpacket // 1 find file with the first subpacket
int type = (EventLoggerFileInfo.REC_TYPE_GPS << 4) | EventLoggerFileInfo.REC_SUBTYPE_IMX5; // 0x18 - first subpacket int type = (EventLoggerFileInfo.REC_TYPE_GPS << 4) | EventLoggerFileInfo.REC_SUBTYPE_IMX5; // 0x18 - first subpacket
int file_index_below = 0; // if ts_master is between the two files? use last of previous int file_index_below = 0; // if ts_master is between the two files? use last of previous
...@@ -327,6 +328,10 @@ public class EventLogger { ...@@ -327,6 +328,10 @@ public class EventLogger {
double ts_below = logger_files[file_index_below].getMasterTS(nrec_below); double ts_below = logger_files[file_index_below].getMasterTS(nrec_below);
double ts_above = logger_files[file_index_above].getMasterTS(nrec_above); double ts_above = logger_files[file_index_above].getMasterTS(nrec_above);
double frac = (ts_master - ts_below)/(ts_above - ts_below); double frac = (ts_master - ts_below)/(ts_above - ts_below);
if ((debug_level >= min_debug) && (did == Imx5.DID_INS_2)) {
System.out.println (String.format("%6d - %6d frac=%6.4f, ts_master = %17.6f, ts_below = %17.6f, ts_above = %17.6f",
nrec_below, nrec_above, frac, ts_master, ts_below, ts_above));
}
// now read both byte arrays and set byte [][] payload // now read both byte arrays and set byte [][] payload
EventLoggerFileInfo fileinfo_next_below = EventLoggerFileInfo fileinfo_next_below =
......
...@@ -130,9 +130,14 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> { ...@@ -130,9 +130,14 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
for (; (nrec > first_last_index[0]) && (nrec < first_last_index[1]); nrec += drec) { for (; (nrec > first_last_index[0]) && (nrec < first_last_index[1]); nrec += drec) {
double ts_master_indx = getMasterTS(bb, nrec); double ts_master_indx = getMasterTS(bb, nrec);
if (after?(ts_master_indx <= ts_master):(ts_master_indx > ts_master)) { if (after?(ts_master_indx <= ts_master):(ts_master_indx > ts_master)) {
// still need to check type, as master timestamp may be in wrong order
// Timestamp is frame start for images
int [] full_type = getFullType(bb, nrec);
if ((full_type != null) && (full_type[0] == type) && (full_type[1] == did)) {
break search_opposite; // return nrec; break search_opposite; // return nrec;
} }
} }
}
System.out.println("getLastBeforeIndex(): could not find oppposite, ts_master="+ts_master+", after="+after); System.out.println("getLastBeforeIndex(): could not find oppposite, ts_master="+ts_master+", after="+after);
return first_last_index[after ? 1 : 0]; // could not find return first_last_index[after ? 1 : 0]; // could not find
} }
......
...@@ -194,8 +194,8 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -194,8 +194,8 @@ public class ErsCorrection extends GeometryCorrection {
public double [] ers_wxyz_center; // world camera XYZ (meters) for the lens center (in camera coordinates, typically 0) public double [] ers_wxyz_center; // world camera XYZ (meters) for the lens center (in camera coordinates, typically 0)
public double [] ers_wxyz_center_dt; // world camera Vx, Vy, Vz (m/s) public double [] ers_wxyz_center_dt; // world camera Vx, Vy, Vz (m/s)
public double [] ers_wxyz_center_d2t; // world camera Vx, Vy, Vz (m/s^2) public double [] ers_wxyz_center_d2t; // world camera Vx, Vy, Vz (m/s^2)
public double [] ers_watr_center_dt; // camera rotaions (az, tilt, roll in radians/s, corresponding to the frame center) public double [] ers_watr_center_dt; // camera rotations (az, tilt, roll in radians/s, corresponding to the frame center)
public double [] ers_watr_center_d2t; // camera rotaions (az, tilt, roll in radians/s, corresponding to the frame center) public double [] ers_watr_center_d2t; // camera rotations (az, tilt, roll in radians/s, corresponding to the frame center)
// absolute position and orientation of this camera in World coordinates // absolute position and orientation of this camera in World coordinates
public double [] camera_xyz = new double[3]; // camera center in world coordinates public double [] camera_xyz = new double[3]; // camera center in world coordinates
......
...@@ -91,12 +91,12 @@ public class IntersceneLma { ...@@ -91,12 +91,12 @@ public class IntersceneLma {
public double [] getReferenceERSXYZ(boolean initial) { // never used public double [] getReferenceERSXYZ(boolean initial) { // never used
double [] full_vector = initial? backup_parameters_full: getFullVector(parameters_vector); double [] full_vector = initial? backup_parameters_full: getFullVector(parameters_vector);
return new double[] { return new double[] {
full_vector[ErsCorrection.DP_DSVX],full_vector[ErsCorrection.DP_DSVY],full_vector[ErsCorrection.DP_DSVZ]}; full_vector[ErsCorrection.DP_DVX],full_vector[ErsCorrection.DP_DVY],full_vector[ErsCorrection.DP_DVZ]};
} }
public double [] getReferenceERSATR(boolean initial) { // never used public double [] getReferenceERSATR(boolean initial) { // never used
double [] full_vector = initial? backup_parameters_full: getFullVector(parameters_vector); double [] full_vector = initial? backup_parameters_full: getFullVector(parameters_vector);
return new double[] { return new double[] {
full_vector[ErsCorrection.DP_DSVAZ],full_vector[ErsCorrection.DP_DSVTL],full_vector[ErsCorrection.DP_DSVRL]}; full_vector[ErsCorrection.DP_DVAZ],full_vector[ErsCorrection.DP_DVTL],full_vector[ErsCorrection.DP_DVRL]};
} }
public String [] printOldNew(boolean allvectors) { public String [] printOldNew(boolean allvectors) {
......
...@@ -75,6 +75,7 @@ public class IntersceneMatchParameters { ...@@ -75,6 +75,7 @@ public class IntersceneMatchParameters {
ims_mount_atr[2] * Math.PI/180}; ims_mount_atr[2] * Math.PI/180};
} }
public boolean center_reference = false; public boolean center_reference = false;
public boolean reset_photometric = true; // reset photometric calibration - once for each new series
public boolean force_ref_dsi = false; // true; public boolean force_ref_dsi = false; // true;
public boolean force_orientations = false; public boolean force_orientations = false;
public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation
...@@ -298,7 +299,9 @@ public class IntersceneMatchParameters { ...@@ -298,7 +299,9 @@ public class IntersceneMatchParameters {
public double half_avg_diff = 0.2; // when L2 of x,y difference from average of neibs - reduce twice public double half_avg_diff = 0.2; // when L2 of x,y difference from average of neibs - reduce twice
// Detect initial match // Detect initial match
public boolean use_combo_relaible = true; // use combo dsi if available for relaib;le tiles public boolean use_combo_relaible = true; // use combo dsi if available for relaible tiles
public boolean ref_need_lma = true; // need LMA output for reliable tiles (no combo available)
public boolean ref_need_lma_combo = true; // need LMA output for reliable tiles (when combo is available)
public double min_ref_str = 0.33; // 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger public double min_ref_str = 0.33; // 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger
public double min_ref_frac = 0.2; // 0.22; if fraction number of reliable tiles is less than this, use best possible public double min_ref_frac = 0.2; // 0.22; if fraction number of reliable tiles is less than this, use best possible
public int pix_step = 4; // Azimuth/tilt search step in pixels public int pix_step = 4; // Azimuth/tilt search step in pixels
...@@ -513,6 +516,8 @@ public class IntersceneMatchParameters { ...@@ -513,6 +516,8 @@ public class IntersceneMatchParameters {
gd.addCheckbox ("Use center scene as a reference", this.center_reference, gd.addCheckbox ("Use center scene as a reference", this.center_reference,
"True for mapping with post-processing. If false, use the last scene as a reference (driving)."); "True for mapping with post-processing. If false, use the last scene as a reference (driving).");
gd.addCheckbox ("Reset photometric calibration", this.reset_photometric,
"Reset photometric calibration, will use basic one before re-calibrating.");
gd.addCheckbox ("Force reference scene DSI calculation", this.force_ref_dsi, gd.addCheckbox ("Force reference scene DSI calculation", this.force_ref_dsi,
"Calculate reference scene DSI even if the file exists."); "Calculate reference scene DSI even if the file exists.");
gd.addCheckbox ("Force egomotion calculation", this.force_orientations, gd.addCheckbox ("Force egomotion calculation", this.force_orientations,
...@@ -926,6 +931,10 @@ public class IntersceneMatchParameters { ...@@ -926,6 +931,10 @@ public class IntersceneMatchParameters {
gd.addCheckbox ("Use combo DSI (if available) for reliable", this.use_combo_relaible, gd.addCheckbox ("Use combo DSI (if available) for reliable", this.use_combo_relaible,
"Use interscene DSI if available (instead of the single-scene) for selecting reliable tiles"); "Use interscene DSI if available (instead of the single-scene) for selecting reliable tiles");
gd.addCheckbox ("Need LMA", this.ref_need_lma,
"Require LMA result for reliable reference");
gd.addCheckbox ("Need LMA if combo", this.ref_need_lma_combo,
"Require LMA result for reliable reference");
gd.addNumericField("DSI_MAIN minimal strength", this.min_ref_str, 5,7,"", gd.addNumericField("DSI_MAIN minimal strength", this.min_ref_str, 5,7,"",
"Match only tiles where DSI_MAIN is stronger than that (and has LMA)."); "Match only tiles where DSI_MAIN is stronger than that (and has LMA).");
...@@ -1202,6 +1211,7 @@ public class IntersceneMatchParameters { ...@@ -1202,6 +1211,7 @@ public class IntersceneMatchParameters {
this.sfm_extrapolate = gd.getNextBoolean(); this.sfm_extrapolate = gd.getNextBoolean();
this.center_reference = gd.getNextBoolean(); this.center_reference = gd.getNextBoolean();
this.reset_photometric = gd.getNextBoolean();
this.force_ref_dsi = gd.getNextBoolean(); this.force_ref_dsi = gd.getNextBoolean();
this.force_orientations = gd.getNextBoolean(); this.force_orientations = gd.getNextBoolean();
this.run_ly = gd.getNextBoolean(); this.run_ly = gd.getNextBoolean();
...@@ -1391,6 +1401,8 @@ public class IntersceneMatchParameters { ...@@ -1391,6 +1401,8 @@ public class IntersceneMatchParameters {
this.half_disparity = gd.getNextNumber(); this.half_disparity = gd.getNextNumber();
this.half_avg_diff = gd.getNextNumber(); this.half_avg_diff = gd.getNextNumber();
this.use_combo_relaible = gd.getNextBoolean(); this.use_combo_relaible = gd.getNextBoolean();
this.ref_need_lma = gd.getNextBoolean();
this.ref_need_lma_combo = gd.getNextBoolean();
this.min_ref_str = gd.getNextNumber(); this.min_ref_str = gd.getNextNumber();
this.min_ref_frac = gd.getNextNumber(); this.min_ref_frac = gd.getNextNumber();
this.pix_step = (int) gd.getNextNumber(); this.pix_step = (int) gd.getNextNumber();
...@@ -1579,6 +1591,7 @@ public class IntersceneMatchParameters { ...@@ -1579,6 +1591,7 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"sfm_extrapolate", this.sfm_extrapolate + ""); // boolean properties.setProperty(prefix+"sfm_extrapolate", this.sfm_extrapolate + ""); // boolean
properties.setProperty(prefix+"center_reference", this.center_reference + ""); // boolean properties.setProperty(prefix+"center_reference", this.center_reference + ""); // boolean
properties.setProperty(prefix+"reset_photometric", this.reset_photometric + ""); // 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
properties.setProperty(prefix+"run_ly", this.run_ly + ""); // boolean properties.setProperty(prefix+"run_ly", this.run_ly + ""); // boolean
...@@ -1778,6 +1791,8 @@ public class IntersceneMatchParameters { ...@@ -1778,6 +1791,8 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"half_disparity", this.half_disparity+""); // double properties.setProperty(prefix+"half_disparity", this.half_disparity+""); // double
properties.setProperty(prefix+"half_avg_diff", this.half_avg_diff+""); // double properties.setProperty(prefix+"half_avg_diff", this.half_avg_diff+""); // double
properties.setProperty(prefix+"use_combo_relaible", this.use_combo_relaible+""); // boolean properties.setProperty(prefix+"use_combo_relaible", this.use_combo_relaible+""); // boolean
properties.setProperty(prefix+"ref_need_lma", this.ref_need_lma+""); // boolean
properties.setProperty(prefix+"ref_need_lma_combo", this.ref_need_lma_combo+""); // boolean
properties.setProperty(prefix+"pix_step", this.pix_step+""); // int properties.setProperty(prefix+"pix_step", this.pix_step+""); // int
properties.setProperty(prefix+"search_rad", this.search_rad+""); // int properties.setProperty(prefix+"search_rad", this.search_rad+""); // int
properties.setProperty(prefix+"maybe_sum", this.maybe_sum+""); // double properties.setProperty(prefix+"maybe_sum", this.maybe_sum+""); // double
...@@ -1916,6 +1931,7 @@ public class IntersceneMatchParameters { ...@@ -1916,6 +1931,7 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"sfm_extrapolate")!=null) this.sfm_extrapolate=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_extrapolate")); if (properties.getProperty(prefix+"sfm_extrapolate")!=null) this.sfm_extrapolate=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_extrapolate"));
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+"reset_photometric")!=null) this.reset_photometric=Boolean.parseBoolean(properties.getProperty(prefix+"reset_photometric"));
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"));
if (properties.getProperty(prefix+"run_ly")!=null) this.run_ly=Boolean.parseBoolean(properties.getProperty(prefix+"run_ly")); if (properties.getProperty(prefix+"run_ly")!=null) this.run_ly=Boolean.parseBoolean(properties.getProperty(prefix+"run_ly"));
...@@ -2121,6 +2137,8 @@ public class IntersceneMatchParameters { ...@@ -2121,6 +2137,8 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"half_disparity")!=null) this.half_disparity=Double.parseDouble(properties.getProperty(prefix+"half_disparity")); if (properties.getProperty(prefix+"half_disparity")!=null) this.half_disparity=Double.parseDouble(properties.getProperty(prefix+"half_disparity"));
if (properties.getProperty(prefix+"half_avg_diff")!=null) this.half_avg_diff=Double.parseDouble(properties.getProperty(prefix+"half_avg_diff")); if (properties.getProperty(prefix+"half_avg_diff")!=null) this.half_avg_diff=Double.parseDouble(properties.getProperty(prefix+"half_avg_diff"));
if (properties.getProperty(prefix+"use_combo_relaible")!=null) this.use_combo_relaible=Boolean.parseBoolean(properties.getProperty(prefix+"use_combo_relaible")); if (properties.getProperty(prefix+"use_combo_relaible")!=null) this.use_combo_relaible=Boolean.parseBoolean(properties.getProperty(prefix+"use_combo_relaible"));
if (properties.getProperty(prefix+"ref_need_lma")!=null) this.ref_need_lma=Boolean.parseBoolean(properties.getProperty(prefix+"ref_need_lma"));
if (properties.getProperty(prefix+"ref_need_lma_combo")!=null) this.ref_need_lma_combo=Boolean.parseBoolean(properties.getProperty(prefix+"ref_need_lma_combo"));
if (properties.getProperty(prefix+"pix_step")!=null) this.pix_step=Integer.parseInt(properties.getProperty(prefix+"pix_step")); if (properties.getProperty(prefix+"pix_step")!=null) this.pix_step=Integer.parseInt(properties.getProperty(prefix+"pix_step"));
if (properties.getProperty(prefix+"search_rad")!=null) this.search_rad=Integer.parseInt(properties.getProperty(prefix+"search_rad")); if (properties.getProperty(prefix+"search_rad")!=null) this.search_rad=Integer.parseInt(properties.getProperty(prefix+"search_rad"));
if (properties.getProperty(prefix+"maybe_sum")!=null) this.maybe_sum=Double.parseDouble(properties.getProperty(prefix+"maybe_sum")); if (properties.getProperty(prefix+"maybe_sum")!=null) this.maybe_sum=Double.parseDouble(properties.getProperty(prefix+"maybe_sum"));
...@@ -2280,6 +2298,7 @@ public class IntersceneMatchParameters { ...@@ -2280,6 +2298,7 @@ public class IntersceneMatchParameters {
imp.sfm_extrapolate = this.sfm_extrapolate; imp.sfm_extrapolate = this.sfm_extrapolate;
imp.center_reference = this.center_reference; imp.center_reference = this.center_reference;
imp.reset_photometric = this.reset_photometric;
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;
imp.run_ly = this.run_ly; imp.run_ly = this.run_ly;
...@@ -2477,6 +2496,8 @@ public class IntersceneMatchParameters { ...@@ -2477,6 +2496,8 @@ public class IntersceneMatchParameters {
imp.half_disparity = this.half_disparity; imp.half_disparity = this.half_disparity;
imp.half_avg_diff = this.half_avg_diff; imp.half_avg_diff = this.half_avg_diff;
imp.use_combo_relaible = this.use_combo_relaible; imp.use_combo_relaible = this.use_combo_relaible;
imp.ref_need_lma = this.ref_need_lma;
imp.ref_need_lma_combo = this.ref_need_lma_combo;
imp.pix_step = this.pix_step; imp.pix_step = this.pix_step;
imp.search_rad = this.search_rad; imp.search_rad = this.search_rad;
imp.maybe_sum = this.maybe_sum; imp.maybe_sum = this.maybe_sum;
......
...@@ -3830,6 +3830,11 @@ public class OpticalFlow { ...@@ -3830,6 +3830,11 @@ public class OpticalFlow {
boolean photo_each_debug = !batch_mode && clt_parameters.photo_each_debug; // false; // true; // false; boolean photo_each_debug = !batch_mode && clt_parameters.photo_each_debug; // false; // true; // false;
boolean photo_each_debug2 = !batch_mode && clt_parameters.photo_each_debug; // false; // true; // false; boolean photo_each_debug2 = !batch_mode && clt_parameters.photo_each_debug; // false; // true; // false;
double [] offsets_bkp= quadCLT_ref.getLwirOffsets();
double [] scales_bkp= quadCLT_ref.getLwirScales();
double [] scales2_bkp = quadCLT_ref.getLwirScales2();
String photometric_scene_backup = quadCLT_ref.getPhotometricScene();
for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) { // maybe need to correct just offsets? for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) { // maybe need to correct just offsets?
int poly_order = photo_order; int poly_order = photo_order;
if ((poly_order > 1) && (nrecalib == 0)) { if ((poly_order > 1) && (nrecalib == 0)) {
...@@ -3852,10 +3857,10 @@ public class OpticalFlow { ...@@ -3852,10 +3857,10 @@ public class OpticalFlow {
photo_each_debug); //final boolean debug) photo_each_debug); //final boolean debug)
if (!ok) { if (!ok) {
System.out.println("************** Failed calibratePhotometric2, restoring original"); System.out.println("************** Failed calibratePhotometric2, restoring original");
quadCLT_ref.setLwirOffsets(quadCLT_main.getLwirOffsets()); // quadCLT_ref.setLwirOffsets(quadCLT_main.getLwirOffsets());
quadCLT_ref.setLwirScales (quadCLT_main.getLwirScales ()); // quadCLT_ref.setLwirScales (quadCLT_main.getLwirScales ());
quadCLT_ref.setLwirScales2(quadCLT_main.getLwirScales2()); // quadCLT_ref.setLwirScales2(quadCLT_main.getLwirScales2());
quadCLT_ref.setPhotometricScene(quadCLT_main.getPhotometricScene()); // quadCLT_ref.setPhotometricScene(quadCLT_main.getPhotometricScene());
// Retry linear only // Retry linear only
ok = QuadCLT.calibratePhotometric2( ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
...@@ -3874,6 +3879,10 @@ public class OpticalFlow { ...@@ -3874,6 +3879,10 @@ public class OpticalFlow {
photo_each_debug); //final boolean debug) photo_each_debug); //final boolean debug)
if (!ok) { if (!ok) {
System.out.println("Failed even linear photometric on pass "+nrecalib+", abandoning calibration"); System.out.println("Failed even linear photometric on pass "+nrecalib+", abandoning calibration");
quadCLT_ref.setLwirOffsets(offsets_bkp);
quadCLT_ref.setLwirScales (scales_bkp);
quadCLT_ref.setLwirScales2(scales2_bkp);
quadCLT_ref.setPhotometricScene(photometric_scene_backup);
break; break;
} }
...@@ -4586,6 +4595,7 @@ public class OpticalFlow { ...@@ -4586,6 +4595,7 @@ public class OpticalFlow {
*/ */
public String buildSeries( public String buildSeries(
boolean batch_mode, boolean batch_mode,
boolean first_in_series,
QuadCLT quadCLT_main, // tiles should be set QuadCLT quadCLT_main, // tiles should be set
int last_index, // -1 - last int last_index, // -1 - last
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -4607,6 +4617,7 @@ public class OpticalFlow { ...@@ -4607,6 +4617,7 @@ public class OpticalFlow {
int earliest_scene = 0; // increase on failure int earliest_scene = 0; // increase on failure
boolean center_reference = clt_parameters.imp.center_reference; boolean center_reference = clt_parameters.imp.center_reference;
int min_num_scenes = clt_parameters.imp.min_num_scenes; // abandon series if there are less than this number of scenes in it int min_num_scenes = clt_parameters.imp.min_num_scenes; // abandon series if there are less than this number of scenes in it
boolean reset_photometric = clt_parameters.imp.reset_photometric;
boolean build_ref_dsi = clt_parameters.imp.force_ref_dsi; boolean build_ref_dsi = clt_parameters.imp.force_ref_dsi;
boolean force_initial_orientations = clt_parameters.imp.force_orientations ; boolean force_initial_orientations = clt_parameters.imp.force_orientations ;
boolean run_ly = clt_parameters.imp.run_ly; // run LY adjust and exit boolean run_ly = clt_parameters.imp.run_ly; // run LY adjust and exit
...@@ -4701,7 +4712,10 @@ public class OpticalFlow { ...@@ -4701,7 +4712,10 @@ public class OpticalFlow {
int test_ers1 = clt_parameters.imp.test_ers1; // try adjusting a pair of scenes with ERS. Other scene index int test_ers1 = clt_parameters.imp.test_ers1; // try adjusting a pair of scenes with ERS. Other scene index
test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0); test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0);
boolean use_combo_relaible = clt_parameters.imp.use_combo_relaible; boolean use_combo_relaible = clt_parameters.imp.use_combo_relaible;
boolean ref_need_lma = clt_parameters.imp.ref_need_lma;
boolean ref_need_lma_combo = clt_parameters.imp.ref_need_lma_combo;
double min_ref_str = clt_parameters.imp.min_ref_str; double min_ref_str = clt_parameters.imp.min_ref_str;
double min_ref_frac= clt_parameters.imp.min_ref_frac; double min_ref_frac= clt_parameters.imp.min_ref_frac;
double [] ref_blue_sky = null; // turn off "lma" in the ML output double [] ref_blue_sky = null; // turn off "lma" in the ML output
if (reuse_video) { // disable all other options if (reuse_video) { // disable all other options
...@@ -4776,53 +4790,24 @@ public class OpticalFlow { ...@@ -4776,53 +4790,24 @@ public class OpticalFlow {
// while ((quadCLTs[ref_index] == null) || (quadCLTs[ref_index].getBlueSky() == null)) { // null // while ((quadCLTs[ref_index] == null) || (quadCLTs[ref_index].getBlueSky() == null)) { // null
// String center_ts = null; // name of the center scene - not yet known // String center_ts = null; // name of the center scene - not yet known
double [][] combo_dsn_final = null; double [][] combo_dsn_final = null;
while ((quadCLTs[last_index] == null) || !quadCLTs[last_index].hasBlueSky()) { // null
//hasBlueSky()
// creating early photometric
/* if (reset_photometric && first_in_series && build_ref_dsi) {
if (photo_en && !reuse_video) {
if (debugLevel > -3) { if (debugLevel > -3) {
System.out.println("**** Running photometric equalization *****"); System.out.println("buildSeries(): *** resetting photometric calibration for a new series ***");
}
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
} }
quadCLT_main.resetLwirCalibration();
// and immediately recalibrate offsets
quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnNoModelQuadCLT( // will conditionImageSet
set_channels[last_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel-2);
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());
}
} }
*/ while ((quadCLTs[last_index] == null) || !quadCLTs[last_index].hasBlueSky()) { // null
if (build_ref_dsi) { if (build_ref_dsi) {
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing? // processing?
...@@ -4954,6 +4939,8 @@ public class OpticalFlow { ...@@ -4954,6 +4939,8 @@ public class OpticalFlow {
int [] first_last_index = quadCLTs[ref_index].getFirstLastIndex(quadCLTs); int [] first_last_index = quadCLTs[ref_index].getFirstLastIndex(quadCLTs);
earliest_scene = first_last_index[0]; earliest_scene = first_last_index[0];
last_index = first_last_index[1]; last_index = first_last_index[1];
} else {
earliest_scene = start_ref_pointers[0];
} }
} else if (ims_use) { } else if (ims_use) {
earliest_scene = Interscene.setInitialOrientationsIms( earliest_scene = Interscene.setInitialOrientationsIms(
...@@ -5094,11 +5081,15 @@ public class OpticalFlow { ...@@ -5094,11 +5081,15 @@ public class OpticalFlow {
" is more than half-range. Reducing to "+num_avg_pairs); " is more than half-range. Reducing to "+num_avg_pairs);
} }
} }
// if (num_avg_pairs > (last_index - ref_index)) {
// num_avg_pairs = last_index - ref_index;
// }
QuadCLT[][][] scenes_seq_pairs = new QuadCLT[3][num_avg_pairs][2]; QuadCLT[][][] scenes_seq_pairs = new QuadCLT[3][num_avg_pairs][2];
// TODO: calculate horizontal offset and compare with sfm_min_base // TODO: calculate horizontal offset and compare with sfm_min_base
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];
scenes_seq_pairs[0][i][0] = quadCLTs[last_index - i];
scenes_seq_pairs[0][i][1] = quadCLTs[earliest_scene + num_avg_pairs - 1 - i]; scenes_seq_pairs[0][i][1] = quadCLTs[earliest_scene + num_avg_pairs - 1 - i];
scenes_seq_pairs[1][i][0] = quadCLTs[last_index - i]; scenes_seq_pairs[1][i][0] = quadCLTs[last_index - i];
...@@ -5171,7 +5162,8 @@ public class OpticalFlow { ...@@ -5171,7 +5162,8 @@ public class OpticalFlow {
use_combo_relaible, // boolean use_combo, use_combo_relaible, // boolean use_combo,
min_ref_str, // double min_strength, min_ref_str, // double min_strength,
min_ref_frac, // double min_ref_frac, min_ref_frac, // double min_ref_frac,
true, // boolean needs_lma); ref_need_lma, // boolean needs_lma);
ref_need_lma_combo, // boolean needs_lma);
reduced_strength); // if not null will return >0 if had to reduce strength (no change if did not reduce) reduced_strength); // if not null will return >0 if had to reduce strength (no change if did not reduce)
if (show_reliable_ref) { if (show_reliable_ref) {
...@@ -5195,6 +5187,9 @@ public class OpticalFlow { ...@@ -5195,6 +5187,9 @@ public class OpticalFlow {
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! boolean disable_ers = (quadCLTs[ref_index].getNumOrient() < 2); // first orient - no ERS!
boolean ers_from_ims = false; // change later
int ers_mode = (quadCLTs[ref_index].getNumOrient() < 2) ? (ers_from_ims? 2 : 1):0;
ers_mode = 1; // TODO: remove later!
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,
...@@ -5203,6 +5198,7 @@ public class OpticalFlow { ...@@ -5203,6 +5198,7 @@ public class OpticalFlow {
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
ref_index, // int ref_index, ref_index, // int ref_index,
new int [] {earliest_scene, last_index}, //int [] range, new int [] {earliest_scene, last_index}, //int [] range,
ers_mode, // int ers_mode, // 0 - keep, 1 - set from velocity, 2 - set from IMS
!batch_mode, // boolean test_motion_blur, !batch_mode, // boolean test_motion_blur,
debugLevel) ; // int debugLevel) debugLevel) ; // int debugLevel)
// should update earliest_scene // should update earliest_scene
......
...@@ -850,7 +850,11 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -850,7 +850,11 @@ public class QuadCLT extends QuadCLTCPU {
int threadsMax, int threadsMax,
final boolean debug) final boolean debug)
{ {
// does not update ref_scene if fails
// double [] offsets_bkp= ref_scene.getLwirOffsets();
// double [] scales_bkp= ref_scene.getLwirScales();
// double [] scales2_bkp = ref_scene.getLwirScales2();
// String photometric_scene_backup = ref_scene.getPhotometricScene();
// filter disparity by LMA only, same bg and fg // filter disparity by LMA only, same bg and fg
double [] disparity_ref= combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_DISP].clone(); double [] disparity_ref= combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_DISP].clone();
for (int i = 0; i < disparity_ref.length; i++) { for (int i = 0; i < disparity_ref.length; i++) {
...@@ -928,7 +932,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -928,7 +932,7 @@ public class QuadCLT extends QuadCLTCPU {
if (num_good < min_good) { if (num_good < min_good) {
System.out.println("calibratePhotometric2(): Too few good pixels for calibration: "+ System.out.println("calibratePhotometric2(): Too few good pixels for calibration: "+
num_good+" < "+min_good+", abandoning photometric calibration."); num_good+" < "+min_good+", abandoning photometric calibration.");
return false; return false; // nothing changed?
} }
avg_img /= num_good; avg_img /= num_good;
double wavg_offs = photo_offs; double wavg_offs = photo_offs;
...@@ -965,7 +969,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -965,7 +969,7 @@ public class QuadCLT extends QuadCLTCPU {
double d2 = b*b - 4 * a * c; double d2 = b*b - 4 * a * c;
if (d2 < 0) { if (d2 < 0) {
System.out.println("calibratePhotometric2() 0: Failed quadratic: a = "+a+", b = "+b+", c="+c); System.out.println("calibratePhotometric2() 0: Failed quadratic: a = "+a+", b = "+b+", c="+c);
return false; return false; // nothing changed?
} }
p= (-b + Math.sqrt(d2))/(2 * a); p= (-b + Math.sqrt(d2))/(2 * a);
} }
...@@ -1034,7 +1038,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -1034,7 +1038,7 @@ public class QuadCLT extends QuadCLTCPU {
c = -s/num_good*b; c = -s/num_good*b;
if (Double.isNaN(c)) { if (Double.isNaN(c)) {
System.out.println("calibratePhotometric2().1 c=NaN"); System.out.println("calibratePhotometric2().1 c=NaN");
return false; return false; // nothing changed?
} }
} else { } else {
// need to balance quadratic so their average is 0 // need to balance quadratic so their average is 0
...@@ -1045,26 +1049,26 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -1045,26 +1049,26 @@ public class QuadCLT extends QuadCLTCPU {
a = (pa_coeff[nsens].length > 2) ? pa_coeff[nsens][2] : 0.0; a = (pa_coeff[nsens].length > 2) ? pa_coeff[nsens][2] : 0.0;
if (Double.isNaN(c)) { if (Double.isNaN(c)) {
System.out.println("calibratePhotometric2().2 c=NaN"); System.out.println("calibratePhotometric2().2 c=NaN");
return false; return false; // nothing changed?
} }
} }
double A = a; double A = a;
double C = -c/b; double C = -c/b;
if (Double.isNaN(C)) { if (Double.isNaN(C)) {
System.out.println("calibratePhotometric2().3 C=NaN"); System.out.println("calibratePhotometric2().3 C=NaN");
return false; return false; // nothing changed?
} }
if (Math.abs(a) >= min_abs_a) { if (Math.abs(a) >= min_abs_a) {
double d2 = b*b - 4*a*c; double d2 = b*b - 4*a*c;
if (d2 < 0) { if (d2 < 0) {
System.out.println("calibratePhotometric2() 1: Failed quadratic: a = "+a+", b = "+b+", c="+c); System.out.println("calibratePhotometric2() 1: Failed quadratic: a = "+a+", b = "+b+", c="+c);
return false; return false; // nothing changed?
} }
C = (-b + Math.sqrt(d2))/(2 * a); C = (-b + Math.sqrt(d2))/(2 * a);
if (Double.isNaN(C)) { if (Double.isNaN(C)) {
System.out.println("calibratePhotometric2().4 C=NaN"); System.out.println("calibratePhotometric2().4 C=NaN");
return false; return false; // nothing changed?
} }
} }
double B = 2 * C * a + b; double B = 2 * C * a + b;
...@@ -1124,7 +1128,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -1124,7 +1128,7 @@ public class QuadCLT extends QuadCLTCPU {
offs_new[nsens] = -c/b; offs_new[nsens] = -c/b;
if (Double.isNaN(offs_new[nsens])) { if (Double.isNaN(offs_new[nsens])) {
System.out.println("calibratePhotometric2().5 offs_new[nsens]=NaN"); System.out.println("calibratePhotometric2().5 offs_new[nsens]=NaN");
return false; return false; // nothing changed?
} }
} }
......
...@@ -212,9 +212,9 @@ public class QuadCLTCPU { ...@@ -212,9 +212,9 @@ public class QuadCLTCPU {
} }
} }
} }
return -2; return -2; // timestamp_reference defined
} }
return -1; return -1; // timestamp_reference is not defined
} }
/** /**
...@@ -260,7 +260,7 @@ public class QuadCLTCPU { ...@@ -260,7 +260,7 @@ public class QuadCLTCPU {
* Set reference scene pointer by a reference scene instance. * Set reference scene pointer by a reference scene instance.
* @param scene reference scene instance * @param scene reference scene instance
*/ */
public void setRefPointer(QuadCLTCPU scene) { public void setRefPointer(QuadCLTCPU scene) { // not used!
setRefPointer(scene.getImageName()); setRefPointer(scene.getImageName());
} }
...@@ -324,14 +324,20 @@ public class QuadCLTCPU { ...@@ -324,14 +324,20 @@ public class QuadCLTCPU {
public double getAverageZ(boolean use_lma) { public double getAverageZ(boolean use_lma) {
double [][] dls = getDLS(); double [][] dls = getDLS();
int min_defined = 100;
if (dls==null) { if (dls==null) {
return Double.NaN; return Double.NaN;
} }
double [][] ds = new double [][] {dls[use_lma?1:0], dls[2]}; double [][] ds = new double [][] {dls[use_lma?1:0], dls[2]};
double sw=0, swd=0; double sw=0, swd=0;
for (int i = 0; i < ds[0].length; i++) if (!Double.isNaN(ds[0][i])){ int num_defined = 0;
for (int i = 0; i < ds[0].length; i++) if (!Double.isNaN(ds[0][i])){ // java.lang.NullPointerException
sw += ds[1][i]; sw += ds[1][i];
swd += ds[0][i] * ds[1][i]; swd += ds[0][i] * ds[1][i];
num_defined++;
}
if ((num_defined < min_defined) && use_lma) {
return getAverageZ(false);
} }
double disp_avg = swd/sw; double disp_avg = swd/sw;
double z_avg = getGeometryCorrection().getZFromDisparity(disp_avg); double z_avg = getGeometryCorrection().getZFromDisparity(disp_avg);
...@@ -2041,6 +2047,7 @@ public class QuadCLTCPU { ...@@ -2041,6 +2047,7 @@ public class QuadCLTCPU {
double min_strength, double min_strength,
double min_ref_frac, double min_ref_frac,
boolean needs_lma, boolean needs_lma,
boolean needs_lma_combo,
double [] reduced_strength // if not null will return >0 if had to reduce strength (no change if did not reduce) double [] reduced_strength // if not null will return >0 if had to reduce strength (no change if did not reduce)
) { ) {
int NUM_BINS = 1024; int NUM_BINS = 1024;
...@@ -2051,6 +2058,7 @@ public class QuadCLTCPU { ...@@ -2051,6 +2058,7 @@ public class QuadCLTCPU {
if (use_combo) { if (use_combo) {
readComboDSI (silent); readComboDSI (silent);
main_dsi = this.dsi; main_dsi = this.dsi;
needs_lma = needs_lma_combo;
} else { } else {
main_dsi = readDsiMain(); main_dsi = readDsiMain();
} }
...@@ -3418,6 +3426,11 @@ public class QuadCLTCPU { ...@@ -3418,6 +3426,11 @@ public class QuadCLTCPU {
public boolean isLwirCalibrated() { public boolean isLwirCalibrated() {
return lwir_offsets != null; return lwir_offsets != null;
} }
public void resetLwirCalibration() {
lwir_offsets = null;
lwir_scales = null;
lwir_scales2 = null;
}
public double [] getLwirOffsets() { public double [] getLwirOffsets() {
if (lwir_offsets == null) { if (lwir_offsets == null) {
lwir_offsets = new double [getNumSensors()]; lwir_offsets = new double [getNumSensors()];
...@@ -6642,7 +6655,7 @@ public class QuadCLTCPU { ...@@ -6642,7 +6655,7 @@ public class QuadCLTCPU {
if (is_lwir && (lwir_subtract_dc || lwir_eq_chn)) { if (is_lwir && (lwir_subtract_dc || lwir_eq_chn)) {
if (recalc_lwir_offsets || !isLwirCalibrated()) { if (recalc_lwir_offsets || !isLwirCalibrated()) {
// this.lwir_offsets = // this.lwir_offsets =
setLwirOffsets( setLwirOffsets( // may have 4096 offset
channelLwirEqualize( // now only calculates offsets, does not apply channelLwirEqualize( // now only calculates offsets, does not apply
channelFiles, channelFiles,
imp_srcs, imp_srcs,
...@@ -6680,12 +6693,12 @@ public class QuadCLTCPU { ...@@ -6680,12 +6693,12 @@ public class QuadCLTCPU {
set_name, // just for debug messages == setNames.get(nSet) set_name, // just for debug messages == setNames.get(nSet)
threadsMax, threadsMax,
debugLevel); debugLevel);
double avg_offs = 0.0; double avg_foffs = 0.0;
for (int i = 0; i < fix_offsets.length; i++) if (i != needs_fix) { for (int i = 0; i < fix_offsets.length; i++) if (i != needs_fix) {
avg_offs += fix_offsets[i]; avg_foffs += fix_offsets[i];
} }
avg_offs /= (fix_offsets.length - 1); avg_foffs /= (fix_offsets.length - 1);
int icorr = (int) Math.round((avg_offs - fix_offsets[needs_fix])/4096); int icorr = (int) Math.round((avg_foffs - fix_offsets[needs_fix])/4096);
if (icorr != 0) { if (icorr != 0) {
float fcorr = icorr*4096; float fcorr = icorr*4096;
System.out.println("Correcting "+imp_srcs[needs_fix].getTitle()+" by "+fcorr); System.out.println("Correcting "+imp_srcs[needs_fix].getTitle()+" by "+fcorr);
...@@ -6694,6 +6707,20 @@ public class QuadCLTCPU { ...@@ -6694,6 +6707,20 @@ public class QuadCLTCPU {
pixels[i] += fcorr; pixels[i] += fcorr;
} }
} }
// There was a bug (11/25/2003) that offsets[6] was 4096 lower
double avg_offs = 0.0;
for (int i = 0; i < fix_offsets.length; i++) if (i != needs_fix) {
avg_offs += fix_offsets[i];
}
avg_offs /= (fix_offsets.length - 1);
int icorr_bug = (int) Math.round((avg_offs - offsets[needs_fix])/4096);
if (icorr_bug != 0) {
System.out.println("conditionImageSet()): Fixing correction bug for "+imp_srcs[needs_fix].getTitle());
offsets[needs_fix]+=icorr_bug*4096;
setLwirOffsets(offsets);
}
} else { } else {
for (int i = 0; i < imp_srcs.length; i++) { for (int i = 0; i < imp_srcs.length; i++) {
if (ImagejJp4Tiff.needsFix000E6410C435(imp_srcs[i])) { if (ImagejJp4Tiff.needsFix000E6410C435(imp_srcs[i])) {
...@@ -16063,7 +16090,7 @@ public class QuadCLTCPU { ...@@ -16063,7 +16090,7 @@ public class QuadCLTCPU {
ts, // double timestamp, ts, // double timestamp,
gps_lla); // double [] lla) gps_lla); // double [] lla)
} else { } else {
if (debugLevel > -2) { if (debugLevel > -1) {
System.out.println("GPS data not available, skipping KML file generation (TODO: maybe make some default LLA?)"); System.out.println("GPS data not available, skipping KML file generation (TODO: maybe make some default LLA?)");
} }
} }
......
...@@ -2998,7 +2998,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -2998,7 +2998,7 @@ if (debugLevel > -100) return true; // temporarily !
boolean search_KML, boolean search_KML,
final int debugLevel) // throws Exception final int debugLevel) // throws Exception
{ {
int min_dbg = 0;
String [] sourceFiles_main=quadCLT_main.correctionsParameters.getSourcePaths(); String [] sourceFiles_main=quadCLT_main.correctionsParameters.getSourcePaths();
// //
// String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths(); // String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths();
...@@ -3044,7 +3044,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3044,7 +3044,7 @@ if (debugLevel > -100) return true; // temporarily !
boolean already_copied = false; boolean already_copied = false;
if (!dir.exists()){ if (!dir.exists()){
dir.mkdirs(); dir.mkdirs();
System.out.println("Created "+dir); if (debugLevel >= min_dbg) System.out.println("Created "+dir);
} else if (skip_existing) { } else if (skip_existing) {
if (dir.list().length > 0) { if (dir.list().length > 0) {
already_copied = true; already_copied = true;
...@@ -3071,7 +3071,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3071,7 +3071,7 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel ); // also generated with x3d model debugLevel ); // also generated with x3d model
} }
if (already_copied) { if (already_copied) {
System.out.println("Skipping existing directory "+dir); if (debugLevel >= min_dbg) System.out.println("Skipping existing directory "+dir);
return; return;
} }
for (String fname:path_list) { for (String fname:path_list) {
...@@ -3082,14 +3082,14 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -3082,14 +3082,14 @@ if (debugLevel > -100) return true; // temporarily !
(file).toPath(), (file).toPath(),
(new File(jp4_copy_path + Prefs.getFileSeparator()+file.getName())).toPath(), (new File(jp4_copy_path + Prefs.getFileSeparator()+file.getName())).toPath(),
StandardCopyOption.REPLACE_EXISTING); StandardCopyOption.REPLACE_EXISTING);
System.out.println("Copied "+fname+" -> "+dir); if (debugLevel >= min_dbg) System.out.println("Copied "+fname+" -> "+dir);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
System.out.println("Failed to copy "+fname+" -> "+dir); System.out.println("Failed to copy "+fname+" -> "+dir);
} }
} }
} }
System.out.println("jp4_copy_path = "+jp4_copy_path); if (debugLevel >= min_dbg) System.out.println("jp4_copy_path = "+jp4_copy_path);
// System.out.println("Do something useful here"); // System.out.println("Do something useful here");
} }
...@@ -8582,7 +8582,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8582,7 +8582,7 @@ if (debugLevel > -100) return true; // temporarily !
for (int nseq = 0; nseq < num_seq; nseq++) { for (int nseq = 0; nseq < num_seq; nseq++) {
long start_time_seq = System.nanoTime(); long start_time_seq = System.nanoTime();
System.out.println("\nSTARTED PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+")"); System.out.println("\nSTARTED PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+")\n");
if (pathFirstLast != null) { if (pathFirstLast != null) {
File [] scene_dirs = (new File(pathFirstLast[nseq].path)).listFiles(); // may contain non-directories, will be filtered by filterScenes File [] scene_dirs = (new File(pathFirstLast[nseq].path)).listFiles(); // may contain non-directories, will be filtered by filterScenes
quadCLT_main.correctionsParameters.filterScenes( quadCLT_main.correctionsParameters.filterScenes(
...@@ -8609,9 +8609,11 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8609,9 +8609,11 @@ if (debugLevel > -100) return true; // temporarily !
int [][] widths_list = new int [1][]; int [][] widths_list = new int [1][];
int ref_index = -1; // -1 - last int ref_index = -1; // -1 - last
int [] start_ref_pointers = new int[2]; int [] start_ref_pointers = new int[2];
boolean first_in_series = true;
while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) { while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) {
String model_directory = opticalFlow.buildSeries( String model_directory = opticalFlow.buildSeries(
(pathFirstLast != null), //boolean batch_mode, (pathFirstLast != null), //boolean batch_mode,
first_in_series, // boolean first_in_series,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
ref_index, // int ref_index, // -1 - last ref_index, // int ref_index, // -1 - last
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
...@@ -8629,8 +8631,19 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8629,8 +8631,19 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel+2); // final int debugLevel) debugLevel+2); // final int debugLevel)
if (model_directory == null) { if (model_directory == null) {
// TODO: Save continueation after failure not to retry each run
System.out.println("Failed to build sequence for series "+ref_index); System.out.println("Failed to build sequence for series "+ref_index);
break; // and go to the to next scene sequence from the list if (start_ref_pointers[0] < (min_num_scenes-1)) {
break;
}
ref_index = start_ref_pointers[0]; // continue from the same attached to the previous reference
System.out.println("Continue from index "+ref_index);
continue; // and go to the to next scene sequence from the list
}
first_in_series = false; // at least once success in this series
System.out.println("adding to video_sets_list start="+start_ref_pointers[0]+", end="+start_ref_pointers[1]);
for (int i= 0; i < video_list[0].length; i++) {
System.out.println(i+": "+video_list[0][i]+", "+widths_list[0][i]);
} }
video_sets_list.add(new VideoSet( video_sets_list.add(new VideoSet(
video_list[0], // String [] paths, video_list[0], // String [] paths,
...@@ -8639,9 +8652,9 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8639,9 +8652,9 @@ if (debugLevel > -100) return true; // temporarily !
start_ref_pointers[1])); // int reference_scene); start_ref_pointers[1])); // int reference_scene);
String series_action = (start_ref_pointers[0] < (min_num_scenes-1))?"is FINISHED ":("will continue down from scene "+(start_ref_pointers[0])); String series_action = (start_ref_pointers[0] < (min_num_scenes-1))?"is FINISHED ":("will continue down from scene "+(start_ref_pointers[0]));
System.out.println("PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+") "+series_action+" in "+ System.out.println("\n ----- PROCESSING SCENE SEQUENCE "+nseq+" (last is "+(num_seq-1)+") "+series_action+" in "+
IJ.d2s(0.000000001*(System.nanoTime()-start_time_seq),3)+" sec ("+ IJ.d2s(0.000000001*(System.nanoTime()-start_time_seq),3)+" sec ("+
IJ.d2s(0.000000001*(System.nanoTime()-start_time_all),3)+" sec from the overall start"); IJ.d2s(0.000000001*(System.nanoTime()-start_time_all),3)+" sec from the overall start\n");
// will open dialog if does not exist // will open dialog if does not exist
String linkedModelsDirectory = quadCLT_main.correctionsParameters.selectLinkedModelsDirectory(true,true); String linkedModelsDirectory = quadCLT_main.correctionsParameters.selectLinkedModelsDirectory(true,true);
if ((linkedModelsDirectory != null) && (linkedModelsDirectory.length() > 0)) { if ((linkedModelsDirectory != null) && (linkedModelsDirectory.length() > 0)) {
...@@ -8694,6 +8707,8 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8694,6 +8707,8 @@ if (debugLevel > -100) return true; // temporarily !
// String spath0 = video_lists[0][nvideo]; // String spath0 = video_lists[0][nvideo];
String name0 = Paths.get(video_sets_list.get(0).getVideoPaths()[nvideo]).getFileName().toString(); String name0 = Paths.get(video_sets_list.get(0).getVideoPaths()[nvideo]).getFileName().toString();
String name1 = Paths.get(video_sets_list.get(video_sets_list.size()-1).getVideoPaths()[nvideo]).getFileName().toString(); String name1 = Paths.get(video_sets_list.get(video_sets_list.size()-1).getVideoPaths()[nvideo]).getFileName().toString();
System.out.println("name0= "+name0);
System.out.println(" name1="+name1);
String ts_sec0=name0.substring(0,name0.indexOf("_")); // seconds of the first timestamp String ts_sec0=name0.substring(0,name0.indexOf("_")); // seconds of the first timestamp
String ts_sec1=name1.substring(0,name1.indexOf("_")); // seconds of the last timestamp String ts_sec1=name1.substring(0,name1.indexOf("_")); // seconds of the last timestamp
String suffix0 = name0.substring(name0.indexOf("-")); // Skip timestamp String suffix0 = name0.substring(name0.indexOf("-")); // Skip timestamp
...@@ -8709,7 +8724,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8709,7 +8724,7 @@ if (debugLevel > -100) return true; // temporarily !
int this_stereo_width = 0; int this_stereo_width = 0;
int num_segments=0; int num_segments=0;
for (int i = 0; i <video_sets_list.size(); i++) { for (int i = 0; i <video_sets_list.size(); i++) {
if (video_sets_list.size() > nvideo) { if (video_sets_list.size() >= nvideo) {
if ((new File(video_sets_list.get(i).getVideoPaths()[nvideo])).exists()) { if ((new File(video_sets_list.get(i).getVideoPaths()[nvideo])).exists()) {
writer.println("file '"+video_sets_list.get(i).getVideoPaths()[nvideo]+"'"); writer.println("file '"+video_sets_list.get(i).getVideoPaths()[nvideo]+"'");
if (stereo_pad) { if (stereo_pad) {
...@@ -8780,7 +8795,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8780,7 +8795,7 @@ if (debugLevel > -100) return true; // temporarily !
} }
} }
} else { } else {
System.out.println("No combined videos are generated"); System.out.println("No combined videos are generated (<2 videos).");
} }
......
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