Commit a38fdb10 authored by Andrey Filippov's avatar Andrey Filippov

Fixed races in IMS-related code, debugged fresh start of multi-sequence

processing
parent 684b347d
......@@ -227,7 +227,7 @@ public class EyesisCorrectionParameters {
public String linkedCenters=""; // linked models with centers scene in CUAS mode
public String x3dDirectory="";
public String videoDirectory=""; // combined (with MPEG) from multiple scene sequences video files
public String cuasSeed ="";
/// public String cuasSeed ="";
public String mlDirectory="ml";
......@@ -349,7 +349,7 @@ public class EyesisCorrectionParameters {
cp.swapSubchannels01= this.swapSubchannels01;
cp.linkedModels= this.linkedModels;
cp.linkedCenters= this.linkedCenters;
cp.cuasSeed= this.cuasSeed;
/// cp.cuasSeed= this.cuasSeed;
cp.videoDirectory= this.videoDirectory;
cp.x3dDirectory= this.x3dDirectory;
cp.mlDirectory= this.mlDirectory;
......@@ -570,7 +570,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"linkedModels", this.linkedModels);
properties.setProperty(prefix+"linkedCenters", this.linkedCenters);
properties.setProperty(prefix+"cuasSeed", this.cuasSeed);
/// properties.setProperty(prefix+"cuasSeed", this.cuasSeed);
properties.setProperty(prefix+"videoDirectory", this.videoDirectory);
properties.setProperty(prefix+"x3dDirectory", this.x3dDirectory);
properties.setProperty(prefix+"use_x3d_subdirs", this.use_x3d_subdirs+"");
......@@ -773,7 +773,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"linkedModels")!= null) this.linkedModels=properties.getProperty(prefix+"linkedModels");
if (properties.getProperty(prefix+"linkedCenters")!= null) this.linkedCenters=properties.getProperty(prefix+"linkedCenters");
if (properties.getProperty(prefix+"cuasSeed")!= null) this.cuasSeed=properties.getProperty(prefix+"cuasSeed");
/// if (properties.getProperty(prefix+"cuasSeed")!= null) this.cuasSeed=properties.getProperty(prefix+"cuasSeed");
if (properties.getProperty(prefix+"videoDirectory")!= null) this.videoDirectory=properties.getProperty(prefix+"videoDirectory");
if (properties.getProperty(prefix+"x3dDirectory")!= null) this.x3dDirectory=properties.getProperty(prefix+"x3dDirectory");
......@@ -1665,7 +1665,10 @@ public class EyesisCorrectionParameters {
for (String line:lines){
if (line.split("#").length > 0) {
String[] tokens = line.split("#")[0].trim().split("[\\s,;=]+");
if ((tokens.length > 2) && (tokens[0].toUpperCase().equals("SET"))) {
if ((tokens.length >= 2) && (tokens[0].toUpperCase().equals("SET"))) {
if (tokens.length == 2) {
tokens = new String[] {tokens[0], tokens[1], ""};
}
parse_set:
{
for (String dir_name:KEY_DIRS) if (dir_name.equals(tokens[1])) {
......@@ -1700,43 +1703,50 @@ public class EyesisCorrectionParameters {
if (!source_dir.exists()) {
source_dir.mkdirs();
}
if (dir_map.containsKey("cuasSeed")) {
this.cuasSeed=(base_path.resolve(Paths.get(dir_map.get("cuasSeed")))).toString();
}
/// if (dir_map.containsKey("cuasSeed")) {
/// this.cuasSeed=(base_path.resolve(Paths.get(dir_map.get("cuasSeed")))).toString();
/// }
useCuasSeedDir = false;
// Set other directories (possibly relative to base_path)
for (int i = 2; i < KEY_DIRS.length; i++) { // skip "rootDirectory" and "sourceDirectory"
if (dir_map.containsKey(KEY_DIRS[i])) {
// Path dir_path=null;
// File dir_file = null;
String dir_string = "";
if (dir_map.get(KEY_DIRS[i]).length() > 0){
Path dir_path=base_path.resolve(Paths.get(dir_map.get(KEY_DIRS[i])));
File dir_file = new File(dir_path.toString());
if (!dir_file.exists()) {
dir_file.mkdirs();
}
dir_string = dir_path.toString();
}
switch (i) {
case 2:
this.linkedModels = dir_path.toString();
this.linkedModels = dir_string; // dir_path.toString();
System.out.println("this.linkedModels="+this.linkedModels);
break;
case 3:
this.linkedCenters = dir_path.toString();
this.linkedCenters = dir_string; // dir_path.toString();
System.out.println("this.linkedCenters="+this.linkedCenters);
break;
case 4:
this.videoDirectory = dir_path.toString();
this.videoDirectory = dir_string; // dir_path.toString();
System.out.println("this.videoDirectory="+this.videoDirectory);
break;
case 5:
this.x3dDirectory = dir_path.toString();
this.x3dDirectory = dir_string; // dir_path.toString();
System.out.println("this.x3dDirectory="+this.x3dDirectory);
break;
case 6:
this.resultsDirectory = dir_path.toString();
this.resultsDirectory = dir_string; // dir_path.toString();
System.out.println("this.resultsDirectory="+this.resultsDirectory);
break;
case 7:
this.resultsDirectory = dir_path.toString();
System.out.println("this.cuasSeed="+this.cuasSeed);
case 7: // cuasSeed
this.cuasSeedDir = dir_string; // dir_path.toString();
System.out.println("this.cuasSeedDir=" + this.cuasSeedDir);
useCuasSeedDir = true;
break;
}
}
......@@ -2363,14 +2373,17 @@ public class EyesisCorrectionParameters {
return this.imsRootDirectory + Prefs.getFileSeparator() + this.imsPrintSubdirectory;
}
/**
* Get directory with the CUAS seed (from previous sequences)
* @return : null if this.useCuasSeedDir==false (disabled), "" if empty, or absolute path ending with "/"
*/
public String getCuasDir() {
if ((this.cuasSeedDir == null) || (this.cuasSeedDir.length() == 0)|| !this.useCuasSeedDir) {
if ((this.cuasSeedDir == null) || !this.useCuasSeedDir) {
return null;
}
// while (this.cuasSeedDir.startsWith(Prefs.getFileSeparator())) {
// this.cuasSeedDir=this.cuasSeedDir.substring(1);
// }
if (this.cuasSeedDir.length() == 0) {
return "";
}
while (this.cuasSeedDir.endsWith(Prefs.getFileSeparator())) {
this.cuasSeedDir=this.cuasSeedDir.substring(0, this.cuasSeedDir.length()-1);
}
......
......@@ -442,7 +442,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
public static EyesisCorrections EYESIS_CORRECTIONS = null;
public static EyesisCorrections EYESIS_CORRECTIONS_AUX = null;
public static EyesisCorrectionParameters.EquirectangularParameters EQUIRECTANGULAR_PARAMETERS = new EyesisCorrectionParameters.EquirectangularParameters();
public static EventLogger EVENT_LOGGER = null;
/// public static EventLogger EVENT_LOGGER = null;
public static int CONVOLVE_FFT_SIZE = 128; // FFT size for sliding convolution with kernel
public static int THREADS_MAX = 100; // testing multi-threading, limit maximal number of threads
......@@ -5686,6 +5686,24 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
CLT_PARAMETERS.batch_run = true;
String imx_logs = CORRECTION_PARAMETERS.getImsSourceDirectory(); // sourceImsDirectory;
String debug_path = null; // CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"debug_local_master";
if ((imx_logs == null) || imx_logs.equals("")) {
System.out.println("sourceImsDirectory is not set. Use Setup CLT Batch parameters to define it.");
return;
}
EventLogger eventLogger = EventLogger.getEventLogger(
imx_logs,
debug_path);
if (eventLogger == null) {
System.out.println("Failed to create eventLogger instance.");
return;
}
eventLogger.print2Pps(CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"rec_1pps");
eventLogger.printStrobeInTime(CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"did_strobe_in_time");
eventLogger.printPimu(CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"did_pimu");
eventLogger.printGps(CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"did_gps", 7);
eventLogger.printDidIns1(CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"did_ins1");
eventLogger.printDidIns2(CORRECTION_PARAMETERS.getImsPrintDirectory()+Prefs.getFileSeparator()+"did_ins2");
/*
if (EVENT_LOGGER == null) {
if ((imx_logs != null) && !imx_logs.equals("")) {
EVENT_LOGGER = new EventLogger (
......@@ -5706,6 +5724,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} else {
System.out.println("EVENT_LOGGEER is null.");
}
*/
return;
//JTabbedTest
// End of buttons code
......@@ -8459,6 +8478,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
null, // String set_name
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
......
......@@ -320,6 +320,7 @@ public class CuasData implements Serializable {
indx_best = i;
}
}
if (tile_list.get(indx_best).clt_data != null) {
CuasTile tile = tile_list.get(indx_best).clone();
if ((num_vars > 1) && !single_variant){
for (int i = 0; i < num_vars; i++) if ((i != indx_best) && !tile_list.get(i).isEmpty()) {
......@@ -332,6 +333,9 @@ public class CuasData implements Serializable {
fclt, // float [] fclt
nTile); // int ntile)
fclt_weights[nTile] = (float) tile.getWeight(decay, ts_now);
} else {
System.out.println("collapse(): tile_list.get("+indx_best+")==null, num_vars= "+num_vars+", nTile="+nTile+", dts="+tile_list.get(indx_best).dts+", weight="+tile_list.get(indx_best).weight);
}
}
}
}
......
......@@ -96,7 +96,8 @@ public class CuasTile implements Comparable<CuasTile>, Serializable {
public CuasTile cloneEmpty() {
int num_colors = clt_data.length/CLT_TILE_LENGTH;
return new CuasTile(num_colors, dts, 0, null);
// return new CuasTile(num_colors, dts, 0, null);
return new CuasTile(num_colors, dts, 0, new float[clt_data.length]);
}
public double merge (CuasTile tile, double decay) {
......
......@@ -1289,7 +1289,7 @@ public class GpuQuad{ // quad camera description
if (!force && this.gpuTileProcessor.bayer_set && !quadCLT.hasNewImageData()) {
return;
}
double [][] bayer_center = quadCLT.getImageCenter();
double [][] bayer_center = quadCLT.getImageCenter(); // null
// if (bayer_center != null) {
if (center) {
quadCLT.getResetImageCenter();
......
......@@ -14,7 +14,24 @@ import ij.Prefs;
public class EventLogger {
public EventLoggerFileInfo [] logger_files;
public EventLogger (String dir, String debug_prefix) { // dir should contain only event logger files
private static EventLogger eventLogger = null;
// public static synchronized boolean hasEventLogger() { //
// return eventLogger != null;
// }
public static synchronized EventLogger getEventLogger() {
return eventLogger;
}
public static synchronized EventLogger getEventLogger(
String dir,
String debug_prefix) {
if (eventLogger == null) {
eventLogger = new EventLogger (dir, debug_prefix);
System.out.println("Created eventLogger");
}
return eventLogger;
}
private EventLogger (String dir, String debug_prefix) { // dir should contain only event logger files
if (!dir.endsWith(Prefs.getFileSeparator())) {
dir+=Prefs.getFileSeparator();
}
......@@ -34,10 +51,6 @@ public class EventLogger {
}
}
Arrays.sort(logger_files); // increasing start time stamps
// testInterpolateDidIns1();
// testInterpolateDidIns1();
// testInterpolateDidIns1();
System.out.println("Processed "+logger_files.length+" event log files");
}
......
......@@ -1019,6 +1019,15 @@ public class Interscene {
quat_corr, // double [] quat_corr, // only applies to rotations - verify!
debugLevel) ; // int debugLevel)
}
boolean debug_ims_xyzatr = true;
if (debug_ims_xyzatr) {
System.out.println("lock_position(set x,y,z = 0)="+lock_position);
System.out.println(String.format("%6s, %20s, %15s, %15s, %15s, %15s, %15s, %15s", "index","timestamp", "X", "Y", "Z", "Azimuth", "Tilt", "Roll"));
for (int i = 0; i < quadCLTs.length; i++) {
System.out.println(String.format("%6d, %20s, %15.12f, %15.12f, %15.12f, %15.12f, %15.12f, %15.12f", i,quadCLTs[i].getImageName(),
ims_xyzatr[i][0][0],ims_xyzatr[i][0][1],ims_xyzatr[i][0][2],ims_xyzatr[i][1][0],ims_xyzatr[i][1][1],ims_xyzatr[i][1][2]));
}
}
if (lock_position) { // zero linear offsets
for (int i = 0; i < quadCLTs.length; i++) for (int j = 0; j < 3; j++){
ims_xyzatr[i][0][j]=0.0;
......
......@@ -167,13 +167,17 @@ public class QuadCLT extends QuadCLTCPU {
}
return imp_virtual;
}
/**
* Convert centerCLT image from transform domain
* @param fclt float transform-domain image representation. First index - sensor
* @return
*/
public double [][] convertCenterClt(
float [][] fclt){ // may be null
if (getCenterClt() == null) {
System.out.println("convertCenterClt(): not a center CLT");
return null;
}
// if (getCenterClt() == null) {
// System.out.println("convertCenterClt(): not a center CLT");
// return null;
// }
int sensor_mask_clt = 1; // just one
setQuadClt();
int tilesX = getTilesX();
......@@ -1985,7 +1989,7 @@ public class QuadCLT extends QuadCLTCPU {
}
}
if (has_inv) { // if there is at least one (significant) inversion - keep only longest
for (int i = max_len_indx +1; i < tilesX; i++) {
for (int i = max_len_indx +1; i < tilesY; i++) {
pXpYD[nTileX + i * tilesX] = null;
}
int start_i = max_len_indx - num_mono[max_len_indx];
......
......@@ -3848,7 +3848,7 @@ public class TexturedModel {
System.out.println("**** output3d(): likely a bug (not copied?), temporary fix ***");
correctionsParameters.use_set_dirs = true;
}
ref_scene.writeKml (null, debugLevel);
ref_scene.writeKml (debugLevel);
/// ref_scene.writeRatingFile (debugLevel); broke
Runtime.getRuntime().gc();
System.out.println("output3d(): generating 3d output files finished at "+
......
......@@ -3011,6 +3011,7 @@ if (debugLevel > -100) return true; // temporarily !
set_channels[nScene].set_name, // String set_name
quadCLT_main, // QuadCLT quadCLT_main,
null, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this, // Does not setup IMS !!!
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
......@@ -3020,8 +3021,6 @@ if (debugLevel > -100) return true; // temporarily !
};
}
ImageDtt.startAndJoin(threads);
}
......@@ -3030,6 +3029,7 @@ if (debugLevel > -100) return true; // temporarily !
* @param set_name set name (timestamp)
* @param quadCLT_main RGB QuadCLT instance
* @param quadCLT_aux secondary RGB or LWIR QuadCLT instance
* @param quadCLT_ims only used for IMS
* @param clt_parameters CLT parameters
* @param skip_existing do not copy if destination files exist
* @param search_KML search for geo data and extract it to KML file if found
......@@ -3039,6 +3039,7 @@ if (debugLevel > -100) return true; // temporarily !
String set_name,
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
QuadCLT quadCLT_this,
CLTParameters clt_parameters,
boolean skip_existing,
boolean search_KML,
......@@ -3077,9 +3078,6 @@ if (debugLevel > -100) return true; // temporarily !
path_list.add(sourceFiles_main[fn]);
}
}
// if (set_channels_main !=null) {
// quadCLT_main.writeKml(debugLevel ); // also generated with x3d model
// }
String jp4_copy_path= quadCLT_main.correctionsParameters.selectX3dDirectory(
set_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
......@@ -3096,26 +3094,25 @@ if (debugLevel > -100) return true; // temporarily !
already_copied = true;
}
}
if (clt_parameters.imp.ims_use) {
String ims_path = dir.getParent() + Prefs.getFileSeparator()+set_name+quadCLT_main.correctionsParameters.imsSuffix;
double [] saved_offset = quadCLT_main.readImsOffset(
ims_path, // String ims_path,
debugLevel); // int debugLevel)
if ((saved_offset == null) || (saved_offset[0] != clt_parameters.imp.ims_offset) || (saved_offset[1] != clt_parameters.imp.gmt_plus)) {
quadCLT_main.saveIms(
clt_parameters.imp.ims_offset,
clt_parameters.imp.gmt_plus, // double gmt_plus,
ims_path,
debugLevel);
}
// not needed, restoreNoModel() and restoreFromModel call restoreIMS
/*
if (clt_parameters.imp.ims_use && (quadCLT_this != null)) {
quadCLT_this.setupIMS(
clt_parameters, // CLTParameters clt_parameters,
skip_existing, // boolean skip_existing,
debugLevel); // int debugLevel);
}
*/
if (search_KML && (set_channels_main !=null)) { // TODO: make it look in both MAIN and AUX. Look in only the same scene?
if (quadCLT_this != null) {
quadCLT_main.writeKml(
debugLevel ); // also generated with x3d model
} else {
quadCLT_main.writeKml(
set_name,
debugLevel ); // also generated with x3d model
}
}
if (already_copied) {
if (debugLevel >= min_dbg) System.out.println("Skipping existing directory "+dir);
return;
......@@ -8086,6 +8083,7 @@ if (debugLevel > -100) return true; // temporarily !
null, // String set_name
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
......@@ -8597,6 +8595,7 @@ if (debugLevel > -100) return true; // temporarily !
EyesisCorrectionParameters.CorrectionParameters.PathFirstLast[] pathFirstLast = null;
int num_seq = 1;
clt_parameters.batch_run = false;// 07.08.2025
if (quadCLT_main.correctionsParameters.useSourceList) {
System.out.println("\nReading source list from file: "+quadCLT_main.correctionsParameters.sourceSequencesList);
pathFirstLast = quadCLT_main.correctionsParameters.getSourceSets(
......@@ -8605,6 +8604,7 @@ if (debugLevel > -100) return true; // temporarily !
num_seq = pathFirstLast.length;
}
clt_parameters.multiseq_run = true; // running from the source list - disable debug images
clt_parameters.batch_run = true; // 07.08.2025
}
class VideoSet {
......@@ -8629,11 +8629,19 @@ if (debugLevel > -100) return true; // temporarily !
ArrayList<VideoSet> video_sets_list = new ArrayList<VideoSet>();
String [] cuas_centers = null; // [0] - cumulative input, [1] - cumulative output
if (quadCLT_main.correctionsParameters.useCuasSeedDir) {
cuas_centers = new String [] {quadCLT_main.correctionsParameters.cuasSeedDir,""};
}
if (debugLevel > -4) {
System.out.println("cuas_centers="+((cuas_centers != null)?("[\""+cuas_centers[0]+"\",\""+cuas_centers[1]+"\"]"):"null"));
}
/*
if ((quadCLT_main.correctionsParameters.cuasSeed != null) && (quadCLT_main.correctionsParameters.cuasSeed.length()>0)) {
cuas_centers = new String [] {quadCLT_main.correctionsParameters.cuasSeed,""};
} else if (quadCLT_main.correctionsParameters.getCuasDir() != null) {
cuas_centers = new String [] {quadCLT_main.correctionsParameters.getCuasDir(),""};
}
*/
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)+")\n");
......@@ -12181,6 +12189,7 @@ if (debugLevel > -100) return true; // temporarily !
set_name, // String set_name
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
......@@ -12314,6 +12323,7 @@ if (debugLevel > -100) return true; // temporarily !
set_name, // String set_name
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
......@@ -12623,6 +12633,7 @@ if (debugLevel > -100) return true; // temporarily !
set_name, // String set_name
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // boolean skip_existing,
true, // boolean search_KML,
......
......@@ -328,6 +328,7 @@ public class LwirWorld {
set_channels[ref_index].set_name, // String set_name
quadCLT_main, // QuadCLT quadCLT_main,
null, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
true, // boolean skip_existing,
true, // false, // boolean search_KML,
......@@ -520,6 +521,7 @@ public class LwirWorld {
set_channels[scene_index].set_name, // String set_name
quadCLT_main, // QuadCLT quadCLT_main,
null, // QuadCLT quadCLT_aux,
null, // QuadCLT quadCLT_this,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
true, // boolean skip_existing,
true, // false, // boolean search_KML,
......
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