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

Debugging, IMU-ERS

parent bc3b706a
......@@ -763,7 +763,7 @@ public class CalibrationIllustration {
try {
Files.createSymbolicLink(newLink, target);
} catch (IOException x) {
System.err.println(x);
System.out.println(x);
} catch (UnsupportedOperationException x) {
// Some file systems do not support symbolic links.
System.err.println(x);
......@@ -775,7 +775,7 @@ public class CalibrationIllustration {
return true;
}
public int [] getStartEndTS(String p) {
public static int [] getStartEndTS(String p) {
int istart = p.lastIndexOf(Prefs.getFileSeparator());
if (istart < 0) {
istart = 0;
......
......@@ -267,6 +267,7 @@ public class EventLogger {
byte [][] payload,
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
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
......@@ -327,6 +328,10 @@ public class EventLogger {
double ts_below = logger_files[file_index_below].getMasterTS(nrec_below);
double ts_above = logger_files[file_index_above].getMasterTS(nrec_above);
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
EventLoggerFileInfo fileinfo_next_below =
......
......@@ -130,7 +130,12 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
for (; (nrec > first_last_index[0]) && (nrec < first_last_index[1]); nrec += drec) {
double ts_master_indx = getMasterTS(bb, nrec);
if (after?(ts_master_indx <= ts_master):(ts_master_indx > ts_master)) {
break search_opposite; // return nrec;
// 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;
}
}
}
System.out.println("getLastBeforeIndex(): could not find oppposite, ts_master="+ts_master+", after="+after);
......
......@@ -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_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_watr_center_dt; // camera rotaions (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_dt; // camera rotations (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
public double [] camera_xyz = new double[3]; // camera center in world coordinates
......
......@@ -200,7 +200,20 @@ public class Interscene {
debugLevel); // final int debugLevel);
// TODO: add {start,end} pointers to quadCLTs[cent_index]
// TODO: add pointer to center to ref_index
// check quadCLTs[cent_index].dsi here
quadCLTs[cent_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_channels[cent_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel);
quadCLTs[cent_index].setQuadClt(); // just in case ?
// NOt needed?
// quadCLTs[cent_index].setDSRBG(
// clt_parameters, // CLTParameters clt_parameters,
// threadsMax, // int threadsMax, // maximal number of threads to launch
// updateStatus, // boolean updateStatus,
// debugLevel); // int debugLevel)
int [] start_ref_pointers2 = new int[2];
......@@ -220,7 +233,7 @@ public class Interscene {
if (earliest_scene2 < 0) {
System.out.println("setInitialOrientationsIms() second half failed. Consider more graceful bail out.");
start_ref_pointers[0] = start_ref_pointers1[0];
return cent_index;
return earliest_scene2; // cent_index;
}
// invert first half, reference to the cent_index, add to cent_index map, generate ref_index ponter and cent_index,
// write config for both ref_index and cent_index scenes
......@@ -278,7 +291,9 @@ public class Interscene {
final boolean updateStatus,
final int debugLevel) {
double maximal_series_rms = 0.0;
double min_ref_str = clt_parameters.imp.min_ref_str;
double min_ref_str = clt_parameters.imp.min_ref_str;
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_frac= clt_parameters.imp.min_ref_frac;
// int min_num_scenes = clt_parameters.imp.min_num_scenes; // abandon series if there are less than this number of scenes in it
int max_num_scenes = clt_parameters.imp.max_num_scenes; // cut longer series
......@@ -329,9 +344,10 @@ public class Interscene {
if (min_ref_str > 0.0) {
reliable_ref = quadCLTs[ref_index].getReliableTiles( // will be null if does not exist.
false, // boolean use_combo,
min_ref_str, // double min_strength,
min_ref_frac, // double min_ref_frac,
true, // boolean needs_lma);
min_ref_str, // double min_strength,
min_ref_frac, // double min_ref_frac,
ref_need_lma, // boolean needs_lma);
true, // ref_need_lma_combo, // boolean needs_lma_combo);
reduced_strength); // if not null will return >0 if had to reduce strength (no change if did not reduce)
if (reduced_strength[0] > 0) {
use_lma_dsi = false; // too few points
......@@ -630,6 +646,7 @@ public class Interscene {
int avg_len = clt_parameters.imp.avg_len;
double maximal_series_rms = 0.0;
double min_ref_str = clt_parameters.imp.min_ref_str;
boolean ref_need_lma = clt_parameters.imp.ref_need_lma;
double min_ref_frac= clt_parameters.imp.min_ref_frac;
// int min_num_scenes = clt_parameters.imp.min_num_scenes; // abandon series if there are less than this number of scenes in it
int max_num_scenes = clt_parameters.imp.max_num_scenes; // cut longer series
......@@ -672,8 +689,9 @@ public class Interscene {
reliable_ref = quadCLTs[ref_index].getReliableTiles( // will be null if does not exist.
false, // boolean use_combo,
min_ref_str, // double min_strength,
min_ref_frac, // double min_ref_frac,
true, // boolean needs_lma);
min_ref_frac, // double min_ref_frac,
ref_need_lma, // boolean needs_lma);
true, // boolean needs_lma_combo);
reduced_strength); // if not null will return >0 if had to reduce strength (no change if did not reduce)
if (reduced_strength[0] > 0) {
use_lma_dsi = false; // too few points
......@@ -976,6 +994,7 @@ public class Interscene {
QuadCLT [] quadCLTs,
int ref_index,
int [] range,
int ers_mode, // 0 - keep, 1 - set from velocity, 2 - set from IMS
boolean test_motion_blur,
int debugLevel)
{
......@@ -1120,14 +1139,26 @@ public class Interscene {
scenes_xyzatr[nscene][1][0], scenes_xyzatr[nscene][1][1], scenes_xyzatr[nscene][1][2]));
}
}
double [][][] dxyzatr_dt = OpticalFlow.getVelocitiesFromScenes(
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ref_index,
earliest_scene, // int start_scene,
last_scene, // int end1_scene,
scenes_xyzatr, // double [][][] scenes_xyzatr,
half_run_range); // double half_run_range
double [][][] dxyzatr_dt;
switch (ers_mode) {
case 1 :
dxyzatr_dt = OpticalFlow.getVelocitiesFromScenes(
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ref_index,
earliest_scene, // int start_scene,
last_scene, // int end1_scene,
scenes_xyzatr, // double [][][] scenes_xyzatr,
half_run_range); // double half_run_range
break;
case 2: // read from ims
default:
dxyzatr_dt = new double [quadCLTs.length][][];
for (int nscene = last_scene; nscene >= earliest_scene; nscene--) {
// read from map (ts)
// divide by dbg_scale_dt, so saved in map will match ERS, not *_dt (currently they are the same)
}
}
if (debug_ers) {
System.out.println();
for (int nscene = last_scene; nscene >= earliest_scene; nscene--) {
......@@ -1190,6 +1221,8 @@ public class Interscene {
scaled_dxyzatr_dt[i][j] = dxyzatr_dt[nscene][i][j]* dbg_scale_dt[i][j];
}
}
// **** Here *_dt is set!
quadCLTs[nscene].getErsCorrection().setErsDt( // set for ref also (should be set before non-ref!)
scaled_dxyzatr_dt[0], // (ers_use_xyz? dxyzatr_dt[nscene][0]: ZERO3), //, // dxyzatr_dt[nscene][0], // double [] ers_xyz_dt,
scaled_dxyzatr_dt[1]); // dxyzatr_dt[nscene][1]); // double [] ers_atr_dt)(ers_scene_original_xyz_dt);
......@@ -1615,6 +1648,8 @@ public class Interscene {
boolean show_corr_fpn = (!clt_parameters.multiseq_run) && (debug_level > -1); // -3; *********** Change to debug FPN correleation ***
int nlma = 0;
// TODO: save ers_scene.ers_watr_center_dt and ers_scene.ers_wxyz_center_dt before first run lma, restore on failure
// it is saved to backup parameters when first lma run (nlma == 0), // boolean first_run,
for (; nlma < clt_parameters.imp.max_cycles; nlma ++) {
boolean near_important = nlma > 0;
// FIXME: not re-calculating motion blur. Maybe do that after each parameter update?
......@@ -1674,6 +1709,9 @@ public class Interscene {
}
}
}
// update setting ers_scene
if (disable_ers) {
param_select_mod = param_select.clone();
for (int i:ErsCorrection.DP_ERS_INDICES) {
......@@ -1682,9 +1720,11 @@ public class Interscene {
// now just copy ers from the reference
ErsCorrection ers_ref = reference_QuadClt.getErsCorrection();
ErsCorrection ers_scene = scene_QuadClt.getErsCorrection();
// when disabled - scene ers from the same as reference one
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();
}
// TODO: save ers_scene.ers_watr_center_dt and ers_scene.ers_wxyz_center_dt
intersceneLma.prepareLMA(
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)
......@@ -1713,6 +1753,10 @@ public class Interscene {
if (fail_reason != null) {
fail_reason[0]=FAIL_REASON_LMA;
}
// TODO: Restore *_dt from backup_parameters_full
scene_QuadClt.getErsCorrection().setErsDt( // set for ref also (should be set before non-ref!)
intersceneLma.getSceneERSXYZ(true), // true for initial values
intersceneLma.getSceneERSATR(true)); // true for initial values
return null;
}
camera_xyz0 = intersceneLma.getSceneXYZ(false); // true for initial values
......@@ -1723,6 +1767,14 @@ public class Interscene {
(diffs_xyz[0] < clt_parameters.imp.exit_change_xyz)) {
break;
}
// TODO: Is ers_scene.ers_wxyz_center_dt updated after running LMA?
// No, update it here !
scene_QuadClt.getErsCorrection().setErsDt( // set for ref also (should be set before non-ref!)
intersceneLma.getSceneERSXYZ(false), // true for initial values
intersceneLma.getSceneERSATR(false)); // true for initial values
// scaled_dxyzatr_dt[0], // (ers_use_xyz? dxyzatr_dt[nscene][0]: ZERO3), //, // dxyzatr_dt[nscene][0], // double [] ers_xyz_dt,
// scaled_dxyzatr_dt[1]); // dxyzatr_dt[nscene][1]); // double [] ers_atr_dt)(ers_scene_original_xyz_dt);
}
if (show_corr_fpn && (debug_level > -1)) { // now not needed, restore if needed
// int num_components = intersceneLma.getNumComponents();
......@@ -3676,8 +3728,8 @@ public class Interscene {
ref_scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
return tp_tasks_ref;
}
public static void generateEgomotionTable0(
@Deprecated
public static void generateEgomotionTable0(
CLTParameters clt_parameters,
QuadCLT [] quadCLTs,
int ref_index,
......@@ -4019,9 +4071,33 @@ public class Interscene {
String comment) {
double [] ims_ortho = clt_parameters.imp.ims_ortho;
double [] ims_mount_atr = clt_parameters.imp.getImsMountATR(); // converts to radians
QuadCLT ref_scene = quadCLTs[ref_index];
ErsCorrection ers_reference = ref_scene.getErsCorrection();
int num_processed = 0;
double [][][] scenes_xyzatr = new double [quadCLTs.length][][];
double [][][] scenes_xyzatr_dt = new double [quadCLTs.length][][];
for (int nscene = earliest_scene; nscene < quadCLTs.length; nscene++) {
QuadCLT scene = quadCLTs[nscene];
if (nscene == ref_index) {
scenes_xyzatr[nscene] = new double[2][3];
scenes_xyzatr_dt[nscene] = new double[2][3];
} else {
String ts = scene.getImageName();
scenes_xyzatr[nscene] = new double [][] {ers_reference.getSceneXYZ(ts),ers_reference.getSceneATR(ts)};
scenes_xyzatr_dt[nscene] = ers_reference.getSceneErsXYZATR_dt(ts);
if (scenes_xyzatr[nscene] != null) {
num_processed++;
}
}
}
boolean use_processed = num_processed > 1;
// double [] quat_ortho = {0.5, 0.5, -0.5, 0.5}; // approximate IMU orientation
String header_img="#\ttimestamp\tx(m)\ty(m)\tz(m)\ta(rad)\ttilt(rad)\troll(rad)"+
"\tVx(m/s)\tVy(m/s)\tVz(m/s)\tVa(rad/s)\tVt(rad/s)\tVr(rad/s)";
String header_ts="#\ttimestamp";
String header_img="\tx(m)\ty(m)\tz(m)\ta(rad)\ttilt(rad)\troll(rad)"+
"\tVx(m/s)\tVy(m/s)\tVz(m/s)\tVa(rad/s)\tVt(rad/s)\tVr(rad/s)"+
"\tEVx(m/s)\tEVy(m/s)\tEVz(m/s)\tEVa(rad/s)\tEVt(rad/s)\tEVr(rad/s)";
String header_ins1="\ttow\ttheta0\ttheta1\ttheta2\tu(m/s)\tv(m/s)\tw(m/s)"+
"\tlat\tlong\talt\tned0\tned1\tned2";
String header_ins2="\ttow\tqn2b0\tqn2b1\tqn2b2\tqn2b3\tu(m/s)\tv(m/s)\tw(m/s)\tlat\tlong\talt";
......@@ -4035,27 +4111,19 @@ public class Interscene {
String header_pimu="\to0\to1\to2\ta0\ta1\ta2";
String header = header_img+header_ins1+header_ins2+header_ins2_extra+header_pimu;
String header = header_ts+(use_processed?header_img:"")+header_ins1+header_ins2+header_ins2_extra+header_pimu;
StringBuffer sb = new StringBuffer();
QuadCLT ref_scene = quadCLTs[ref_index];
ErsCorrection ers_reference = ref_scene.getErsCorrection();
double [][][] scenes_xyzatr = new double [quadCLTs.length][][];
for (int nscene = earliest_scene; nscene < quadCLTs.length; nscene++) {
QuadCLT scene = quadCLTs[nscene];
if (nscene == ref_index) {
scenes_xyzatr[nscene] = new double[2][3];
} else {
String ts = scene.getImageName();
scenes_xyzatr[nscene] = new double [][] {ers_reference.getSceneXYZ(ts),ers_reference.getSceneATR(ts)};
}
double [][][] dxyzatr_dt = null;
if (use_processed) {
dxyzatr_dt = OpticalFlow.getVelocitiesFromScenes(
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ref_index,
earliest_scene, // int start_scene,
quadCLTs.length-1, // int end1_scene,
scenes_xyzatr, // double [][][] scenes_xyzatr,
clt_parameters.ofp.lpf_series); // half_run_range); // double half_run_range
}
double [][][] dxyzatr_dt = OpticalFlow.getVelocitiesFromScenes(
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ref_index,
earliest_scene, // int start_scene,
quadCLTs.length-1, // int end1_scene,
scenes_xyzatr, // double [][][] scenes_xyzatr,
clt_parameters.ofp.lpf_series); // half_run_range); // double half_run_range
Did_ins_2 d2_ref = quadCLTs[ref_index].did_ins_2;
double [] cam_quat_ref =Imx5.quaternionImsToCam(d2_ref.getQn2b() ,
ims_mount_atr, // new double[] {0, 0.13, 0},
......@@ -4086,15 +4154,22 @@ public class Interscene {
Did_pimu d3 = scene.did_pimu;
sb.append(nscene+"\t"+timestamp);
// TODO: try saved, not calculated velocities!
sb.append("\t"+scenes_xyzatr[nscene][0][0]+"\t"+scenes_xyzatr[nscene][0][1]+"\t"+scenes_xyzatr[nscene][0][2]);
sb.append("\t"+scenes_xyzatr[nscene][1][0]+"\t"+scenes_xyzatr[nscene][1][1]+"\t"+scenes_xyzatr[nscene][1][2]);
sb.append("\t"+dxyzatr_dt[nscene][0][0]+"\t"+dxyzatr_dt[nscene][0][1]+"\t"+dxyzatr_dt[nscene][0][2]);
sb.append("\t"+dxyzatr_dt[nscene][1][0]+"\t"+dxyzatr_dt[nscene][1][1]+"\t"+dxyzatr_dt[nscene][1][2]);
// String header_ins1="\ttow\ttheta0\ttheta1\ttheta2\tu(m/s)\tv(m/s)\tw(m/s)"+
// "\tlong\tlat\talt\tned0\tned1\tned2";
if (use_processed) {
if (scenes_xyzatr[nscene] != null) {
sb.append("\t"+scenes_xyzatr[nscene][0][0]+"\t"+scenes_xyzatr[nscene][0][1]+"\t"+scenes_xyzatr[nscene][0][2]);
sb.append("\t"+scenes_xyzatr[nscene][1][0]+"\t"+scenes_xyzatr[nscene][1][1]+"\t"+scenes_xyzatr[nscene][1][2]);
// TODO: try saved, not calculated velocities!
sb.append("\t"+dxyzatr_dt[nscene][0][0]+"\t"+dxyzatr_dt[nscene][0][1]+"\t"+dxyzatr_dt[nscene][0][2]);
sb.append("\t"+dxyzatr_dt[nscene][1][0]+"\t"+dxyzatr_dt[nscene][1][1]+"\t"+dxyzatr_dt[nscene][1][2]);
// TODO: try saved, not calculated velocities - here they are:
sb.append("\t"+scenes_xyzatr_dt[nscene][0][0]+"\t"+scenes_xyzatr_dt[nscene][0][1]+"\t"+scenes_xyzatr_dt[nscene][0][2]);
sb.append("\t"+scenes_xyzatr_dt[nscene][1][0]+"\t"+scenes_xyzatr_dt[nscene][1][1]+"\t"+scenes_xyzatr_dt[nscene][1][2]);
} else {
for (int i = 0; i < 12; i++) {
sb.append("\t---");
}
}
}
sb.append("\t"+d1.timeOfWeek);
sb.append("\t"+d1.theta[0]+"\t"+d1.theta[1]+"\t"+d1.theta[2]);
sb.append("\t"+d1.uvw[0]+ "\t"+d1.uvw[1]+ "\t"+d1.uvw[2]);
......
......@@ -91,12 +91,12 @@ public class IntersceneLma {
public double [] getReferenceERSXYZ(boolean initial) { // never used
double [] full_vector = initial? backup_parameters_full: getFullVector(parameters_vector);
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
double [] full_vector = initial? backup_parameters_full: getFullVector(parameters_vector);
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) {
......
......@@ -75,6 +75,7 @@ public class IntersceneMatchParameters {
ims_mount_atr[2] * Math.PI/180};
}
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_orientations = false;
public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation
......@@ -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
// 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_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
......@@ -513,6 +516,8 @@ public class IntersceneMatchParameters {
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).");
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,
"Calculate reference scene DSI even if the file exists.");
gd.addCheckbox ("Force egomotion calculation", this.force_orientations,
......@@ -926,6 +931,10 @@ public class IntersceneMatchParameters {
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");
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,"",
"Match only tiles where DSI_MAIN is stronger than that (and has LMA).");
......@@ -1202,6 +1211,7 @@ public class IntersceneMatchParameters {
this.sfm_extrapolate = gd.getNextBoolean();
this.center_reference = gd.getNextBoolean();
this.reset_photometric = gd.getNextBoolean();
this.force_ref_dsi = gd.getNextBoolean();
this.force_orientations = gd.getNextBoolean();
this.run_ly = gd.getNextBoolean();
......@@ -1391,6 +1401,8 @@ public class IntersceneMatchParameters {
this.half_disparity = gd.getNextNumber();
this.half_avg_diff = gd.getNextNumber();
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_frac = gd.getNextNumber();
this.pix_step = (int) gd.getNextNumber();
......@@ -1579,6 +1591,7 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"sfm_extrapolate", this.sfm_extrapolate + ""); // 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_orientations", this.force_orientations + ""); // boolean
properties.setProperty(prefix+"run_ly", this.run_ly + ""); // boolean
......@@ -1777,7 +1790,9 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"weight_zero_neibs", this.weight_zero_neibs+""); // double
properties.setProperty(prefix+"half_disparity", this.half_disparity+""); // 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+"search_rad", this.search_rad+""); // int
properties.setProperty(prefix+"maybe_sum", this.maybe_sum+""); // double
......@@ -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+"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_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"));
......@@ -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_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+"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+"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"));
......@@ -2280,6 +2298,7 @@ public class IntersceneMatchParameters {
imp.sfm_extrapolate = this.sfm_extrapolate;
imp.center_reference = this.center_reference;
imp.reset_photometric = this.reset_photometric;
imp.force_ref_dsi = this.force_ref_dsi;
imp.force_orientations = this.force_orientations;
imp.run_ly = this.run_ly;
......@@ -2477,6 +2496,8 @@ public class IntersceneMatchParameters {
imp.half_disparity = this.half_disparity;
imp.half_avg_diff = this.half_avg_diff;
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.search_rad = this.search_rad;
imp.maybe_sum = this.maybe_sum;
......
......@@ -3830,6 +3830,11 @@ public class OpticalFlow {
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;
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?
int poly_order = photo_order;
if ((poly_order > 1) && (nrecalib == 0)) {
......@@ -3852,10 +3857,10 @@ public class OpticalFlow {
photo_each_debug); //final boolean debug)
if (!ok) {
System.out.println("************** Failed calibratePhotometric2, restoring original");
quadCLT_ref.setLwirOffsets(quadCLT_main.getLwirOffsets());
quadCLT_ref.setLwirScales (quadCLT_main.getLwirScales ());
quadCLT_ref.setLwirScales2(quadCLT_main.getLwirScales2());
quadCLT_ref.setPhotometricScene(quadCLT_main.getPhotometricScene());
// quadCLT_ref.setLwirOffsets(quadCLT_main.getLwirOffsets());
// quadCLT_ref.setLwirScales (quadCLT_main.getLwirScales ());
// quadCLT_ref.setLwirScales2(quadCLT_main.getLwirScales2());
// quadCLT_ref.setPhotometricScene(quadCLT_main.getPhotometricScene());
// Retry linear only
ok = QuadCLT.calibratePhotometric2(
clt_parameters, // CLTParameters clt_parameters,
......@@ -3874,6 +3879,10 @@ public class OpticalFlow {
photo_each_debug); //final boolean debug)
if (!ok) {
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;
}
......@@ -4586,6 +4595,7 @@ public class OpticalFlow {
*/
public String buildSeries(
boolean batch_mode,
boolean first_in_series,
QuadCLT quadCLT_main, // tiles should be set
int last_index, // -1 - last
CLTParameters clt_parameters,
......@@ -4607,6 +4617,7 @@ public class OpticalFlow {
int earliest_scene = 0; // increase on failure
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
boolean reset_photometric = clt_parameters.imp.reset_photometric;
boolean build_ref_dsi = clt_parameters.imp.force_ref_dsi;
boolean force_initial_orientations = clt_parameters.imp.force_orientations ;
boolean run_ly = clt_parameters.imp.run_ly; // run LY adjust and exit
......@@ -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
test_ers &= (test_ers0 >= 0) && (test_ers1 >= 0);
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_frac= clt_parameters.imp.min_ref_frac;
double [] ref_blue_sky = null; // turn off "lma" in the ML output
if (reuse_video) { // disable all other options
......@@ -4776,53 +4790,24 @@ public class OpticalFlow {
// 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 (reset_photometric && first_in_series && build_ref_dsi) {
if (debugLevel > -3) {
System.out.println("buildSeries(): *** resetting photometric calibration for a new series ***");
}
*/
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);
}
while ((quadCLTs[last_index] == null) || !quadCLTs[last_index].hasBlueSky()) { // null
if (build_ref_dsi) {
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing?
......@@ -4954,6 +4939,8 @@ public class OpticalFlow {
int [] first_last_index = quadCLTs[ref_index].getFirstLastIndex(quadCLTs);
earliest_scene = first_last_index[0];
last_index = first_last_index[1];
} else {
earliest_scene = start_ref_pointers[0];
}
} else if (ims_use) {
earliest_scene = Interscene.setInitialOrientationsIms(
......@@ -5094,11 +5081,15 @@ public class OpticalFlow {
" 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];
// 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][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[1][i][0] = quadCLTs[last_index - i];
......@@ -5171,7 +5162,8 @@ public class OpticalFlow {
use_combo_relaible, // boolean use_combo,
min_ref_str, // double min_strength,
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)
if (show_reliable_ref) {
......@@ -5195,6 +5187,9 @@ public class OpticalFlow {
mb_max_gain = clt_parameters.imp.mb_max_gain_inter;
}
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
clt_parameters, // CLTParameters clt_parameters,
mb_max_gain, // double mb_max_gain,
......@@ -5203,6 +5198,7 @@ public class OpticalFlow {
quadCLTs, // QuadCLT [] quadCLTs,
ref_index, // int ref_index,
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,
debugLevel) ; // int debugLevel)
// should update earliest_scene
......
......@@ -850,7 +850,11 @@ public class QuadCLT extends QuadCLTCPU {
int threadsMax,
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
double [] disparity_ref= combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_DISP].clone();
for (int i = 0; i < disparity_ref.length; i++) {
......@@ -928,7 +932,7 @@ public class QuadCLT extends QuadCLTCPU {
if (num_good < min_good) {
System.out.println("calibratePhotometric2(): Too few good pixels for calibration: "+
num_good+" < "+min_good+", abandoning photometric calibration.");
return false;
return false; // nothing changed?
}
avg_img /= num_good;
double wavg_offs = photo_offs;
......@@ -965,7 +969,7 @@ public class QuadCLT extends QuadCLTCPU {
double d2 = b*b - 4 * a * c;
if (d2 < 0) {
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);
}
......@@ -1034,7 +1038,7 @@ public class QuadCLT extends QuadCLTCPU {
c = -s/num_good*b;
if (Double.isNaN(c)) {
System.out.println("calibratePhotometric2().1 c=NaN");
return false;
return false; // nothing changed?
}
} else {
// need to balance quadratic so their average is 0
......@@ -1045,26 +1049,26 @@ public class QuadCLT extends QuadCLTCPU {
a = (pa_coeff[nsens].length > 2) ? pa_coeff[nsens][2] : 0.0;
if (Double.isNaN(c)) {
System.out.println("calibratePhotometric2().2 c=NaN");
return false;
return false; // nothing changed?
}
}
double A = a;
double C = -c/b;
if (Double.isNaN(C)) {
System.out.println("calibratePhotometric2().3 C=NaN");
return false;
return false; // nothing changed?
}
if (Math.abs(a) >= min_abs_a) {
double d2 = b*b - 4*a*c;
if (d2 < 0) {
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);
if (Double.isNaN(C)) {
System.out.println("calibratePhotometric2().4 C=NaN");
return false;
return false; // nothing changed?
}
}
double B = 2 * C * a + b;
......@@ -1124,7 +1128,7 @@ public class QuadCLT extends QuadCLTCPU {
offs_new[nsens] = -c/b;
if (Double.isNaN(offs_new[nsens])) {
System.out.println("calibratePhotometric2().5 offs_new[nsens]=NaN");
return false;
return false; // nothing changed?
}
}
......
......@@ -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 {
* Set reference scene pointer by a reference scene instance.
* @param scene reference scene instance
*/
public void setRefPointer(QuadCLTCPU scene) {
public void setRefPointer(QuadCLTCPU scene) { // not used!
setRefPointer(scene.getImageName());
}
......@@ -324,14 +324,20 @@ public class QuadCLTCPU {
public double getAverageZ(boolean use_lma) {
double [][] dls = getDLS();
int min_defined = 100;
if (dls==null) {
return Double.NaN;
}
double [][] ds = new double [][] {dls[use_lma?1:0], dls[2]};
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];
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 z_avg = getGeometryCorrection().getZFromDisparity(disp_avg);
......@@ -2041,6 +2047,7 @@ public class QuadCLTCPU {
double min_strength,
double min_ref_frac,
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)
) {
int NUM_BINS = 1024;
......@@ -2051,6 +2058,7 @@ public class QuadCLTCPU {
if (use_combo) {
readComboDSI (silent);
main_dsi = this.dsi;
needs_lma = needs_lma_combo;
} else {
main_dsi = readDsiMain();
}
......@@ -3418,6 +3426,11 @@ public class QuadCLTCPU {
public boolean isLwirCalibrated() {
return lwir_offsets != null;
}
public void resetLwirCalibration() {
lwir_offsets = null;
lwir_scales = null;
lwir_scales2 = null;
}
public double [] getLwirOffsets() {
if (lwir_offsets == null) {
lwir_offsets = new double [getNumSensors()];
......@@ -6642,7 +6655,7 @@ public class QuadCLTCPU {
if (is_lwir && (lwir_subtract_dc || lwir_eq_chn)) {
if (recalc_lwir_offsets || !isLwirCalibrated()) {
// this.lwir_offsets =
setLwirOffsets(
setLwirOffsets( // may have 4096 offset
channelLwirEqualize( // now only calculates offsets, does not apply
channelFiles,
imp_srcs,
......@@ -6680,12 +6693,12 @@ public class QuadCLTCPU {
set_name, // just for debug messages == setNames.get(nSet)
threadsMax,
debugLevel);
double avg_offs = 0.0;
double avg_foffs = 0.0;
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);
int icorr = (int) Math.round((avg_offs - fix_offsets[needs_fix])/4096);
avg_foffs /= (fix_offsets.length - 1);
int icorr = (int) Math.round((avg_foffs - fix_offsets[needs_fix])/4096);
if (icorr != 0) {
float fcorr = icorr*4096;
System.out.println("Correcting "+imp_srcs[needs_fix].getTitle()+" by "+fcorr);
......@@ -6694,6 +6707,20 @@ public class QuadCLTCPU {
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 {
for (int i = 0; i < imp_srcs.length; i++) {
if (ImagejJp4Tiff.needsFix000E6410C435(imp_srcs[i])) {
......@@ -16063,7 +16090,7 @@ public class QuadCLTCPU {
ts, // double timestamp,
gps_lla); // double [] lla)
} else {
if (debugLevel > -2) {
if (debugLevel > -1) {
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 !
boolean search_KML,
final int debugLevel) // throws Exception
{
int min_dbg = 0;
String [] sourceFiles_main=quadCLT_main.correctionsParameters.getSourcePaths();
//
// String [] sourceFiles_aux=quadCLT_main.correctionsParameters.getSourcePaths();
......@@ -3044,7 +3044,7 @@ if (debugLevel > -100) return true; // temporarily !
boolean already_copied = false;
if (!dir.exists()){
dir.mkdirs();
System.out.println("Created "+dir);
if (debugLevel >= min_dbg) System.out.println("Created "+dir);
} else if (skip_existing) {
if (dir.list().length > 0) {
already_copied = true;
......@@ -3071,7 +3071,7 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel ); // also generated with x3d model
}
if (already_copied) {
System.out.println("Skipping existing directory "+dir);
if (debugLevel >= min_dbg) System.out.println("Skipping existing directory "+dir);
return;
}
for (String fname:path_list) {
......@@ -3082,14 +3082,14 @@ if (debugLevel > -100) return true; // temporarily !
(file).toPath(),
(new File(jp4_copy_path + Prefs.getFileSeparator()+file.getName())).toPath(),
StandardCopyOption.REPLACE_EXISTING);
System.out.println("Copied "+fname+" -> "+dir);
if (debugLevel >= min_dbg) System.out.println("Copied "+fname+" -> "+dir);
} catch (IOException e) {
// TODO Auto-generated catch block
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");
}
......@@ -8582,7 +8582,7 @@ if (debugLevel > -100) return true; // temporarily !
for (int nseq = 0; nseq < num_seq; nseq++) {
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) {
File [] scene_dirs = (new File(pathFirstLast[nseq].path)).listFiles(); // may contain non-directories, will be filtered by filterScenes
quadCLT_main.correctionsParameters.filterScenes(
......@@ -8609,9 +8609,11 @@ if (debugLevel > -100) return true; // temporarily !
int [][] widths_list = new int [1][];
int ref_index = -1; // -1 - last
int [] start_ref_pointers = new int[2];
boolean first_in_series = true;
while ((ref_index < 0) || ((ref_index + 1) >= min_num_scenes)) {
String model_directory = opticalFlow.buildSeries(
(pathFirstLast != null), //boolean batch_mode,
first_in_series, // boolean first_in_series,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
ref_index, // int ref_index, // -1 - last
clt_parameters, // CLTParameters clt_parameters,
......@@ -8629,8 +8631,19 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus,
debugLevel+2); // final int debugLevel)
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);
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_list[0], // String [] paths,
......@@ -8639,9 +8652,9 @@ if (debugLevel > -100) return true; // temporarily !
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]));
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_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
String linkedModelsDirectory = quadCLT_main.correctionsParameters.selectLinkedModelsDirectory(true,true);
if ((linkedModelsDirectory != null) && (linkedModelsDirectory.length() > 0)) {
......@@ -8694,6 +8707,8 @@ if (debugLevel > -100) return true; // temporarily !
// String spath0 = video_lists[0][nvideo];
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();
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_sec1=name1.substring(0,name1.indexOf("_")); // seconds of the last timestamp
String suffix0 = name0.substring(name0.indexOf("-")); // Skip timestamp
......@@ -8709,7 +8724,7 @@ if (debugLevel > -100) return true; // temporarily !
int this_stereo_width = 0;
int num_segments=0;
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()) {
writer.println("file '"+video_sets_list.get(i).getVideoPaths()[nvideo]+"'");
if (stereo_pad) {
......@@ -8780,7 +8795,7 @@ if (debugLevel > -100) return true; // temporarily !
}
}
} 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