Commit 91588dc7 authored by Andrey Filippov's avatar Andrey Filippov

Updated to restore first stage of the UAS detection

parent 1a73d50c
......@@ -1724,6 +1724,7 @@ public class CalibrationIllustration {
int last_seq_size = 0;
double last_ts = 0.0;
String seq_name = "";
int num_seqs = 1;
while (true) {
boolean some_left = false;
for (int si = 0; si < scenePaths.length;si++) {
......@@ -1788,6 +1789,7 @@ public class CalibrationIllustration {
((seq_len > 0) && (last_seq_size >= seq_len)) ||
((seq_gap > 0.0) && ((cs.ts - last_ts) >= seq_gap))
) {
num_seqs++;
seq_name = cs.getName();
}
last_ts = cs.ts;
......@@ -1799,7 +1801,7 @@ public class CalibrationIllustration {
filteredScenesList.add(cs); // modified version
}
System.out.println("Selected "+(filteredScenesList.size())+" scenes");
System.out.println("Selected "+(filteredScenesList.size())+" scenes, "+num_seqs+" sequences=");
return filteredScenesList.toArray(new CapturedScene[0]);
}
......
......@@ -55,6 +55,7 @@ import ij.gui.GenericDialog;
public class EyesisCorrectionParameters {
public static class CorrectionParameters{
public static boolean MKDIRS_ALLOW = true; // make false for safer mode
public static final String [] KEY_DIRS= {
"rootDirectory", // 0
"sourceDirectory", // 1
......@@ -1832,9 +1833,14 @@ public class EyesisCorrectionParameters {
File dir_file = new File(dir_path.toString());
if ((i != KEY_INDEX_UAS_LOGS) && (i != KEY_INDEX_SKY_MASK)) { // cuasUasLogs, cuasSkyMask are files, not directories
if (!dir_file.exists()) {
System.out.println(KEY_DIRS[i]+" directory "+dir_path.toString()+" does not exist, ignoring "+seq_str);
System.out.println("Please run:\nmkdir -p "+dir_path.toString());
return null;
if (MKDIRS_ALLOW) {
dir_file.mkdirs();
System.out.println("Created data dirtectory "+dir_path.toString());
} else {
System.out.println(KEY_DIRS[i]+" directory "+dir_path.toString()+" does not exist, ignoring "+seq_str);
System.out.println("Please run:\nmkdir -p "+dir_path.toString());
return null;
}
}
}
dir_string = dir_path.toString();
......
......@@ -760,7 +760,7 @@ public class CorrectionFPN {
for (int nscene = first_index; nscene <= last_index ; nscene++) { // was reversed ***
if (debugLevel > -3) {
System.out.println ("Processing scene "+nscene+" ("+quadCLTs[nscene].getImageName()+"). Last is "+last_index);
System.out.println ("Processing scene "+nscene+" ("+quadCLTs[nscene].getImageName()+"). Last is "+last_index+ "(integer number of full rotations).");
}
double [][][] diff_src_synth_weights = backPropagate(
clt_parameters, // CLTParameters clt_parameters,
......
......@@ -1506,7 +1506,7 @@ min_str_neib_fpn 0.35
gd.addNumericField("Master timestamp", this.ims_master_ts, 6,20,"s",
"Master timestamp (used in image names) corresponding to the local timestamp above.");
gd.addNumericField("Master clock correction", 1e6*this.ims_master_scale, 6,20,"ppm",
"Relastive master clock duration (master_period-local_period)/master_period, parts per million.");
"Relative master clock duration (master_period-local_period)/master_period, parts per million.");
gd.addMessage ("Extracting vertical from the IMS data");
gd.addCheckbox ("Calculate and set vertical direction (imsv_xyz)",this.imsv_calc,
......
......@@ -3273,7 +3273,7 @@ public class OpticalFlow {
){
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
final int dbg_nTile = dbg_tileY * tilesX + dbg_tileX;
final int dbg_nTile = -(dbg_tileY * tilesX + dbg_tileX);
final int tileSize = tp.getTileSize();
// final double tileSize2 = tileSize * 2;
final Thread[] threads = ImageDtt.newThreadArray(THREADS_MAX);
......@@ -5199,6 +5199,17 @@ public class OpticalFlow {
QuadCLT center_CLT = null; // used for CUAS - rotation center
// See if build_ref_dsi is needed
if (!build_ref_dsi) {
// Added 03.25.26 - for cuas ended up w/o jp4 copy, when processing the second sequence
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing?
set_channels[last_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,
debugLevel);
// try reading full
quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnNoModelQuadCLT( // will conditionImageSet copies quat_corr from this
set_channels[last_index].set_name,
......@@ -5211,27 +5222,8 @@ public class OpticalFlow {
parent_clt_name = cuas_centers[0]; // may be ==""
}
if (use_cuas && (cuas_centers != null)) { // (parent_clt_name != null)) { // && (parent_clt_name.length() > 0)) {
if (quadCLTs[last_index] == null) {// happens if no files are copied (they were copied with build_ref_dsi, not needed now
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing?
set_channels[last_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,
debugLevel);
quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnNoModelQuadCLT( // will conditionImageSet
set_channels[last_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel-2);
quadCLTs[last_index].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
}
System.out.println("cuas mode, verifying that all scenes have files copied - optimize"); // multithreaded?
int [] scene_range = {0, last_index - 1};
int [] scene_range = {0, last_index - 1}; // all but last
TwoQuadCLT.copyJP4src(
set_channels, // final SetChannels [] set_channels,
scene_range, // final int [] range, // [earlies, latest]
......@@ -5241,15 +5233,6 @@ public class OpticalFlow {
true, // boolean skip_existing,
true, // false, // boolean search_KML,
debugLevel);
/*
QuadCLT.copyJP4src(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT [] quadCLTs,
scene_range, // final int [] range, // [earlies, latest]
true, // boolean skip_existing,
true, // boolean search_KML,
debugLevel); // final int debugLevel) { // throws Exception
*/
double [] dbg_weights = cuas_debug ? new double [quadCLTs[last_index].getTilesX() * quadCLTs[last_index].getTilesY()] : null;
String parent_or_null = ((parent_clt_name != null) && (parent_clt_name.length()>0)) ? parent_clt_name : null;
boolean ignore_this = (parent_or_null != null) ? clt_parameters.imp.cuas_reset_first : false;
......@@ -5269,8 +5252,8 @@ public class OpticalFlow {
if (cuas_debug) { // show_clt && !clt_parameters.batch_run) {
ImagePlus imp_weights = ShowDoubleFloatArrays.makeArrays( // all 0-s
dbg_weights,
quadCLTs[last_index].getTileProcessor().getTilesX(),
quadCLTs[last_index].getTileProcessor().getTilesY(),
quadCLTs[last_index].getTilesX(),
quadCLTs[last_index].getTilesY(),
quadCLTs[last_index].getImageName()+"-restoreCenterClt-weights");
if (imp_weights != null) {
String suffix ="-RESTORE_CENTER_CLT-WEIGHTHS";
......
......@@ -181,10 +181,6 @@ public class QuadCLT extends QuadCLTCPU {
*/
public double [][] convertCenterClt(
float [][] fclt){ // may be 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();
......@@ -208,28 +204,21 @@ public class QuadCLT extends QuadCLTCPU {
sensor_mask_clt, // final int sensor_mask,
wh, // null, // int [] wh,
false); // boolean use_reference
/*
float [][] fpix = getComboFromTD(
-1, // final int sensor_mask, // only if merge_channels
false, // final boolean merge_channels,
null, // final int [] whc, // if int[2], will return width, height
false); // final boolean use_reference){
*/
double [][] dbg = renderDoubleFromTDMono (
-1, // final int sensor_mask,
wh, // null, // int [] wh,
false); // boolean use_reference
System.out.println("### convertCenterClt(): result={"+result[0][0]+","+result[0][1]+","+result[0][2]+","+result[0][3]+", dbg.length="+dbg.length);
ShowDoubleFloatArrays.showArrays(
dbg,
wh[0],
wh[1],
true,
"convertCenterClt_test");
boolean debug_convertCenterClt_test = false;
if (debug_convertCenterClt_test) {
double [][] dbg = renderDoubleFromTDMono (
-1, // final int sensor_mask,
wh, // null, // int [] wh,
false); // boolean use_reference
System.out.println("### convertCenterClt(): result={"+result[0][0]+","+result[0][1]+","+result[0][2]+","+result[0][3]+", dbg.length="+dbg.length);
ShowDoubleFloatArrays.showArrays(
dbg,
wh[0],
wh[1],
true,
"convertCenterClt_test");
}
return result;
}
......
......@@ -551,7 +551,11 @@ public class QuadCLTCPU {
}
// Read parent (cumulative if possible) data if full_path is provided
CuasData parentCuasData = null;
if (center_CLT == null) {
System.out.println("Gave up trying to read this CenterCLT, saved earlier");
}
if (full_path != null) { // if full path provided, but something went wrong with cuasData or dsi_parent - return null
System.out.println("Trying to read parent CenterCLT");
parentCuasData = CuasData.getCuasData( // need cumulative here!
true, // boolean try_cumul, // and save as such if only old style existed
full_path, // String full_path, // ends with /vxx
......@@ -1745,7 +1749,8 @@ public class QuadCLTCPU {
quat_ims_cam=Imx5.applyQuaternionToQuaternion(quat_corr, quat_ims_cam, false);
}
if (did_ins_2 == null) {
System.out.println("getDxyzatrIms(): did_ins_2=null");
System.out.println("getDxyzatrIms(): did_ins_2=null for "+getImageName());
return null;
}
double [] double_uvw = did_ins_2.getUvw();
if ((double_uvw[0] == 0.0) && (double_uvw[1] == 0.0) && (double_uvw[2] == 0.0)) {
......@@ -1985,6 +1990,9 @@ public class QuadCLTCPU {
return scenes_xyzatr;
}
public boolean hasIns() {
return (did_ins_2 != null);
}
public double [] getLla() {
return did_ins_2.lla;
......@@ -6292,6 +6300,16 @@ LogTee.clearSceneLog(); // stop per‑scene logging
return this; // can only be QuadCLT instance
}
public boolean hasSrcFiles() {
String jp4_copy_path= correctionsParameters.selectX3dDirectory(
this.image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters.jp4SubDir,
true, // smart,
true); // false); // true); //newAllowed, // save
int num_src_files=correctionsParameters.selectSourceFileInSet(jp4_copy_path, -5).length;
return (num_src_files >= getNumSensors());
}
public QuadCLTCPU restoreNoModel(
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......
......@@ -2883,7 +2883,7 @@ if (debugLevel > -100) return true; // temporarily !
public static void copyJP4src(
final SetChannels [] set_channels,
final int [] range, // [earlies, latest]
final int [] range, // [earliest, latest]
final QuadCLT quadCLT_main, // tiles should be set
final QuadCLT quadCLT_aux,
final CLTParameters clt_parameters,
......@@ -8833,7 +8833,7 @@ if (debugLevel > -100) return true; // temporarily !
// trying re-using reference scenes list
int [] next_first_last_index = null;
if (keep_segments) {
if (keep_segments && !use_cuas) { // no segments for suas
if( (scene_names != null) && (index_scenes[0] != null)) {
if (ref_scene_names == null) { // proceesed first (latest by ts) segment
ref_scene_names = index_scenes[0].getRefScenes();
......@@ -8864,7 +8864,7 @@ if (debugLevel > -100) return true; // temporarily !
}
}
}
if (next_first_last_index == null) {
if ((next_first_last_index == null) && !use_cuas) {
// testing half-step
System.out.println("Calculating next segment's indices.");
if (start_ref_pointers[0] >= (min_num_scenes-1)) { // maybe just >=0 here?
......
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