Commit f2f461fb authored by Andrey Filippov's avatar Andrey Filippov

fixing model directories after LY

parent fe4c41e5
...@@ -18,6 +18,7 @@ public final class LogTee { ...@@ -18,6 +18,7 @@ public final class LogTee {
private static final PrintStream ORIGINAL_OUT = System.out; private static final PrintStream ORIGINAL_OUT = System.out;
private static final PrintStream ORIGINAL_ERR = System.err; private static final PrintStream ORIGINAL_ERR = System.err;
private static volatile PrintStream fileStream = null; private static volatile PrintStream fileStream = null;
private static volatile Path sceneLogPath = null;
private static volatile boolean installed = false; private static volatile boolean installed = false;
private LogTee() { private LogTee() {
...@@ -40,6 +41,7 @@ public final class LogTee { ...@@ -40,6 +41,7 @@ public final class LogTee {
synchronized (LOCK) { synchronized (LOCK) {
closeFileStream(); closeFileStream();
fileStream = new PrintStream(new FileOutputStream(path.toFile(), true), true); fileStream = new PrintStream(new FileOutputStream(path.toFile(), true), true);
sceneLogPath = path;
} }
} }
...@@ -47,9 +49,14 @@ public final class LogTee { ...@@ -47,9 +49,14 @@ public final class LogTee {
synchronized (LOCK) { synchronized (LOCK) {
closeFileStream(); closeFileStream();
fileStream = null; fileStream = null;
sceneLogPath = null;
} }
} }
public static Path getSceneLog() {
return sceneLogPath;
}
private static void closeFileStream() { private static void closeFileStream() {
if (fileStream != null) { if (fileStream != null) {
fileStream.flush(); fileStream.flush();
......
...@@ -108,6 +108,7 @@ import com.elphel.imagej.common.CholeskyLDLTMulti; ...@@ -108,6 +108,7 @@ import com.elphel.imagej.common.CholeskyLDLTMulti;
import com.elphel.imagej.common.DoubleFHT; import com.elphel.imagej.common.DoubleFHT;
import com.elphel.imagej.common.DoubleGaussianBlur; import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.LogTee;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools; import com.elphel.imagej.common.WindowTools;
import com.elphel.imagej.cuas.CuasMotion; import com.elphel.imagej.cuas.CuasMotion;
...@@ -519,6 +520,13 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -519,6 +520,13 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return; return;
} }
*/ */
/*
LogTee.install(); // once, early
LogTee.setSceneLog(path); // when you want to start per‑scene logging
LogTee.clearSceneLog(); // stop per‑scene logging
*/
LogTee.install(); // once, early
try { try {
loadPrefs(); loadPrefs();
} catch (IOException e1) { } catch (IOException e1) {
......
...@@ -2759,13 +2759,16 @@ public class Correlation2d { ...@@ -2759,13 +2759,16 @@ public class Correlation2d {
boolean eig_fast2x2, // use fast eigenvectors for 2x2 matrices boolean eig_fast2x2, // use fast eigenvectors for 2x2 matrices
boolean debug) boolean debug)
{ {
boolean verbose = false;
int data_height = data.length/data_width; int data_height = data.length/data_width;
int center_xy = (data_width - 1)/2; // = transform_size - 1; int center_xy = (data_width - 1)/2; // = transform_size - 1;
double x0 = center_xy, y0 = center_xy; double x0 = center_xy, y0 = center_xy;
int imax= 0; int imax= 0;
for (int i= 1; i < data.length;i++) { for (int i= 1; i < data.length;i++) {
if (Double.isNaN(data[i])) { if (Double.isNaN(data[i])) {
if (verbose) {
System.out.println("NaN in getMaxXYCmEig() 2"); System.out.println("NaN in getMaxXYCmEig() 2");
}
return null; return null;
} }
if (data[i] > data[imax]) { if (data[i] > data[imax]) {
......
...@@ -51,6 +51,7 @@ import com.elphel.imagej.cameras.CLTParameters; ...@@ -51,6 +51,7 @@ import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.cameras.ColorProcParameters; import com.elphel.imagej.cameras.ColorProcParameters;
import com.elphel.imagej.cameras.EyesisCorrectionParameters; import com.elphel.imagej.cameras.EyesisCorrectionParameters;
import com.elphel.imagej.common.DoubleGaussianBlur; import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.LogTee;
import com.elphel.imagej.common.PolynomialApproximation; import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.correction.CorrectionColorProc; import com.elphel.imagej.correction.CorrectionColorProc;
...@@ -4865,6 +4866,10 @@ public class OpticalFlow { ...@@ -4865,6 +4866,10 @@ public class OpticalFlow {
boolean [] annotate_mono_color = {clt_parameters.imp.annotate_mono,clt_parameters.imp.annotate_color}; boolean [] annotate_mono_color = {clt_parameters.imp.annotate_mono,clt_parameters.imp.annotate_color};
boolean annotate_transparent_mono = clt_parameters.imp.annotate_transparent_mono; boolean annotate_transparent_mono = clt_parameters.imp.annotate_transparent_mono;
if ((index_scenes[0] != null) && (LogTee.getSceneLog()==null)) {
index_scenes[0].startLogging();
}
boolean [] generate_modes3d = { boolean [] generate_modes3d = {
clt_parameters.imp.generate_raw, clt_parameters.imp.generate_raw,
...@@ -5431,7 +5436,18 @@ public class OpticalFlow { ...@@ -5431,7 +5436,18 @@ public class OpticalFlow {
if (index_scenes[1] == null) { // not yet implemented, to create an index of all sequences indices ) if (index_scenes[1] == null) { // not yet implemented, to create an index of all sequences indices )
index_scenes[1] = quadCLTs[last_index]; index_scenes[1] = quadCLTs[last_index];
} }
if ((index_scenes[0] != null) && (LogTee.getSceneLog() == null)) {
index_scenes[0].startLogging();
}
} }
/*
LogTee.install(); // once, early
LogTee.setSceneLog(path); // when you want to start per‑scene logging
LogTee.clearSceneLog(); // stop per‑scene logging
LogTee.getSceneLog()
*/
// reduce some conditions as they are implied by (operation_mode == RESULTS_BUILD_SEQ_LY) // reduce some conditions as they are implied by (operation_mode == RESULTS_BUILD_SEQ_LY)
// && run_ly && (run_ly_mode > 0) && (run_ly_mode <= 3) && is_first_scene // && run_ly && (run_ly_mode > 0) && (run_ly_mode <= 3) && is_first_scene
boolean exec_ly_correction = (operation_mode == RESULTS_BUILD_SEQ_LY) && force_initial_orientations; boolean exec_ly_correction = (operation_mode == RESULTS_BUILD_SEQ_LY) && force_initial_orientations;
...@@ -6275,7 +6291,19 @@ public class OpticalFlow { ...@@ -6275,7 +6291,19 @@ public class OpticalFlow {
threadsMax, // final int threadsMax, // maximal number of threads to launch threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel) throws Exception debugLevel); // final int debugLevel) throws Exception
oriented_scenes[oriented_ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
// oriented_scenes[oriented_ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
// temporary fix save/restore linkedModels, sourceDirectory, sourcePaths
// that are copied main-> aux in EyesisCorrectionParameters.updateAuxFromMain()
// quadCLT_main.correctionsParameters
wrappedSaveConfInModelDirectory(
quadCLTs, // QuadCLT [] quadCLTs,
quadCLT_main, // QuadCLT quadCLT_main,
master_CLT, // QuadCLT master_CLT,
ref_index); // int ref_index)
// Copy LY calibration to the index scene (last in the sequence) // Copy LY calibration to the index scene (last in the sequence)
CorrVector corr_vector = oriented_scenes[oriented_ref_index].getGeometryCorrection().getCorrVector(); CorrVector corr_vector = oriented_scenes[oriented_ref_index].getGeometryCorrection().getCorrVector();
index_scenes[0].getGeometryCorrection().setCorrVector(corr_vector); // updated system corr vector with the current updated one index_scenes[0].getGeometryCorrection().setCorrVector(corr_vector); // updated system corr vector with the current updated one
...@@ -8037,6 +8065,14 @@ public class OpticalFlow { ...@@ -8037,6 +8065,14 @@ public class OpticalFlow {
// temporary fix save/restore linkedModels, sourceDirectory, sourcePaths // temporary fix save/restore linkedModels, sourceDirectory, sourcePaths
// that are copied main-> aux in EyesisCorrectionParameters.updateAuxFromMain() // that are copied main-> aux in EyesisCorrectionParameters.updateAuxFromMain()
// quadCLT_main.correctionsParameters // quadCLT_main.correctionsParameters
wrappedSaveConfInModelDirectory(
quadCLTs, // QuadCLT [] quadCLTs,
quadCLT_main, // QuadCLT quadCLT_main,
master_CLT, // QuadCLT master_CLT,
ref_index); // int ref_index)
/*
String bkp_linkedModels = quadCLT_main.correctionsParameters.linkedModels; String bkp_linkedModels = quadCLT_main.correctionsParameters.linkedModels;
String bkp_linkedCenters = quadCLT_main.correctionsParameters.linkedCenters; String bkp_linkedCenters = quadCLT_main.correctionsParameters.linkedCenters;
/// String bkp_cuasSeed = quadCLT_main.correctionsParameters.cuasSeed; /// String bkp_cuasSeed = quadCLT_main.correctionsParameters.cuasSeed;
...@@ -8054,9 +8090,6 @@ public class OpticalFlow { ...@@ -8054,9 +8090,6 @@ public class OpticalFlow {
double [] bkp_cuasCameraATR = quadCLT_main.correctionsParameters.cuasCameraATR; //{0, 0, 0}; double [] bkp_cuasCameraATR = quadCLT_main.correctionsParameters.cuasCameraATR; //{0, 0, 0};
double [] bkp_cuasUASHome = quadCLT_main.correctionsParameters.cuasUASHome; //{0, 0, 0}; double [] bkp_cuasUASHome = quadCLT_main.correctionsParameters.cuasUASHome; //{0, 0, 0};
boolean bkp_cuasSetHome = quadCLT_main.correctionsParameters.cuasSetHome; boolean bkp_cuasSetHome = quadCLT_main.correctionsParameters.cuasSetHome;
master_CLT.saveConfInModelDirectory(); // save all (global) configurations in model/version directory master_CLT.saveConfInModelDirectory(); // save all (global) configurations in model/version directory
if (master_CLT != quadCLTs[ref_index]) { if (master_CLT != quadCLTs[ref_index]) {
quadCLTs[ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory quadCLTs[ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
...@@ -8077,12 +8110,62 @@ public class OpticalFlow { ...@@ -8077,12 +8110,62 @@ public class OpticalFlow {
quadCLT_main.correctionsParameters.cuasUASHome = bkp_cuasUASHome; quadCLT_main.correctionsParameters.cuasUASHome = bkp_cuasUASHome;
quadCLT_main.correctionsParameters.cuasSetHome = bkp_cuasSetHome; quadCLT_main.correctionsParameters.cuasSetHome = bkp_cuasSetHome;
quadCLT_main.correctionsParameters.cuasSkyMask = bkp_cuasSkyMask; quadCLT_main.correctionsParameters.cuasSkyMask = bkp_cuasSkyMask;
*/
System.out.println("buildSeries(): DONE"); // System.out.println("buildSeries(): DONE"); //
// String top_dir0=quadCLTs[ref_index].getX3dTopDirectory(); // String top_dir0=quadCLTs[ref_index].getX3dTopDirectory();
return quadCLTs[ref_index].getX3dTopDirectory(); // top_dir; // keep? return quadCLTs[ref_index].getX3dTopDirectory(); // top_dir; // keep?
} }
public void wrappedSaveConfInModelDirectory(
QuadCLT [] quadCLTs,
QuadCLT quadCLT_main,
QuadCLT master_CLT,
int ref_index
) {
// temporary fix save/restore linkedModels, sourceDirectory, sourcePaths
// that are copied main-> aux in EyesisCorrectionParameters.updateAuxFromMain()
// quadCLT_main.correctionsParameters
String bkp_linkedModels = quadCLT_main.correctionsParameters.linkedModels;
String bkp_linkedCenters = quadCLT_main.correctionsParameters.linkedCenters;
/// String bkp_cuasSeed = quadCLT_main.correctionsParameters.cuasSeed;
String bkp_cuasSeedDir = quadCLT_main.correctionsParameters.cuasSeedDir;
String bkp_videoDirectory = quadCLT_main.correctionsParameters.videoDirectory;
String bkp_x3dDirectory = quadCLT_main.correctionsParameters.x3dDirectory;
String bkp_mlDirectory = quadCLT_main.correctionsParameters.mlDirectory;
String bkp_sourceDirectory = quadCLT_main.correctionsParameters.sourceDirectory;
String [] bkp_sourcePaths = quadCLT_main.correctionsParameters.sourcePaths;
boolean bkp_use_set_dirs = quadCLT_main.correctionsParameters.use_set_dirs;
String bkp_cuasUasLogs = quadCLT_main.correctionsParameters.cuasUasLogs; // TIFF image 640x512 where 1.0 - sky, 0.0 - ground, blurred with GB (now sigma==2.0)
String bkp_cuasSkyMask = quadCLT_main.correctionsParameters.cuasSkyMask; // json file path containing UAS logs
double bkp_cuasUasTimeStamp = quadCLT_main.correctionsParameters.cuasUasTimeStamp; // 0.0; // timestamp corresponding to the UAS time 0.0
double [] bkp_cuasCameraATR = quadCLT_main.correctionsParameters.cuasCameraATR; //{0, 0, 0};
double [] bkp_cuasUASHome = quadCLT_main.correctionsParameters.cuasUASHome; //{0, 0, 0};
boolean bkp_cuasSetHome = quadCLT_main.correctionsParameters.cuasSetHome;
master_CLT.saveConfInModelDirectory(); // save all (global) configurations in model/version directory
if (master_CLT != quadCLTs[ref_index]) {
quadCLTs[ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
}
quadCLT_main.correctionsParameters.linkedModels = bkp_linkedModels;
quadCLT_main.correctionsParameters.linkedCenters = bkp_linkedCenters;
quadCLT_main.correctionsParameters.cuasSeedDir = bkp_cuasSeedDir;
quadCLT_main.correctionsParameters.videoDirectory = bkp_videoDirectory;
quadCLT_main.correctionsParameters.x3dDirectory = bkp_x3dDirectory;
quadCLT_main.correctionsParameters.mlDirectory = bkp_mlDirectory;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourcePaths = bkp_sourcePaths;
quadCLT_main.correctionsParameters.use_set_dirs = bkp_use_set_dirs;
quadCLT_main.correctionsParameters.cuasUasLogs = bkp_cuasUasLogs;
quadCLT_main.correctionsParameters.cuasUasTimeStamp = bkp_cuasUasTimeStamp;
quadCLT_main.correctionsParameters.cuasCameraATR = bkp_cuasCameraATR;
quadCLT_main.correctionsParameters.cuasUASHome = bkp_cuasUASHome;
quadCLT_main.correctionsParameters.cuasSetHome = bkp_cuasSetHome;
quadCLT_main.correctionsParameters.cuasSkyMask = bkp_cuasSkyMask;
return;
}
public static double getImsDisparityCorrection( public static double getImsDisparityCorrection(
QuadCLT [] quadCLTs, QuadCLT [] quadCLTs,
QuadCLT master_CLT, QuadCLT master_CLT,
......
...@@ -67,6 +67,7 @@ import com.elphel.imagej.cameras.EyesisCorrectionParameters; ...@@ -67,6 +67,7 @@ import com.elphel.imagej.cameras.EyesisCorrectionParameters;
import com.elphel.imagej.cameras.ThermalColor; import com.elphel.imagej.cameras.ThermalColor;
import com.elphel.imagej.common.DoubleGaussianBlur; import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.LogTee;
import com.elphel.imagej.common.PolynomialApproximation; import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.correction.CorrectionColorProc; import com.elphel.imagej.correction.CorrectionColorProc;
...@@ -111,6 +112,7 @@ public class QuadCLTCPU { ...@@ -111,6 +112,7 @@ public class QuadCLTCPU {
public static final String ORIENTATION_LOGS_SUFFIX = "-ORIENTATION.log"; public static final String ORIENTATION_LOGS_SUFFIX = "-ORIENTATION.log";
public static final String INTERFRAME_SUFFIX = "-INTERFRAME"; public static final String INTERFRAME_SUFFIX = "-INTERFRAME";
public static final String FIELD_CALIBRATION_SUFFIX = "-FIELD_CALIBRATION"; public static final String FIELD_CALIBRATION_SUFFIX = "-FIELD_CALIBRATION";
public static final String SYSTEM_OUT_LOG_SUFFIX = "-SYSTEM_OUT.log";
public static final String CONFIGURATION_EXTENSION = ".corr-xml"; public static final String CONFIGURATION_EXTENSION = ".corr-xml";
public static final String [] DSI_SUFFIXES = {"-INTER-INTRA-LMA","-INTER-INTRA","-DSI_MAIN"}; public static final String [] DSI_SUFFIXES = {"-INTER-INTRA-LMA","-INTER-INTRA","-DSI_MAIN"};
...@@ -5417,6 +5419,24 @@ public class QuadCLTCPU { ...@@ -5417,6 +5419,24 @@ public class QuadCLTCPU {
} }
} }
/*
LogTee.install(); // once, early
LogTee.setSceneLog(path); // when you want to start per‑scene logging
LogTee.clearSceneLog(); // stop per‑scene logging
*/
public void startLogging() {
String x3d_path = getX3dTopDirectory();
Path log_path = Paths.get(x3d_path).resolve(getImageName()+SYSTEM_OUT_LOG_SUFFIX);
try {
LogTee.setSceneLog(log_path);
} catch (IOException e) {
System.err.println("startLogging(): failed to start logging to "+x3d_path);
} // when you want to start per‑scene logging
}
public void stopLogging() {
LogTee.clearSceneLog(); // stop per‑scene logging
}
/** /**
......
...@@ -52,6 +52,7 @@ import com.elphel.imagej.cameras.CLTParameters; ...@@ -52,6 +52,7 @@ import com.elphel.imagej.cameras.CLTParameters;
import com.elphel.imagej.cameras.ColorProcParameters; import com.elphel.imagej.cameras.ColorProcParameters;
import com.elphel.imagej.cameras.EyesisCorrectionParameters; import com.elphel.imagej.cameras.EyesisCorrectionParameters;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.LogTee;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.correction.CorrectionColorProc; import com.elphel.imagej.correction.CorrectionColorProc;
import com.elphel.imagej.correction.EyesisCorrections; import com.elphel.imagej.correction.EyesisCorrections;
...@@ -8614,6 +8615,7 @@ if (debugLevel > -100) return true; // temporarily ! ...@@ -8614,6 +8615,7 @@ if (debugLevel > -100) return true; // temporarily !
threadsMax, // final int threadsMax, // maximal number of threads to launch threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel+2); // final int debugLevel) debugLevel+2); // final int debugLevel)
LogTee.clearSceneLog(); // stop per‑scene logging
if (debugLevel > -4){ if (debugLevel > -4){
System.out.println("3. cuas_centers="+((cuas_centers != null)?("[\""+cuas_centers[0]+"\",\""+cuas_centers[1]+"\"]"):"null")); System.out.println("3. cuas_centers="+((cuas_centers != null)?("[\""+cuas_centers[0]+"\",\""+cuas_centers[1]+"\"]"):"null"));
} }
......
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