Commit 8e595c63 authored by Andrey Filippov's avatar Andrey Filippov

compare to template

parent 62655772
......@@ -168,6 +168,9 @@ public class CalibrationFileManagement {
if ((dir!=null) && (!dir.isDirectory())){
dir=dir.getParentFile();
}
if ((dir!=null) && (dir.exists()) && (dir.isDirectory() == directory)) {// 05.30.2025
return dir.getPath();
}
if (!smart) { // 05.29.2025
return null;
......
......@@ -1504,7 +1504,7 @@ public class Interscene {
// added 05.21.2024: skip if was spawn already
if (changed || (quadCLTs[scene_index] == null)) {
// quadCLTs[scene_index] = quadCLTs[last_index].spawnNoModelQuadCLT(
quadCLTs[scene_index] = center_CLT.spawnNoModelQuadCLT(
quadCLTs[scene_index] = center_CLT.spawnNoModelQuadCLT( // null
set_channels[scene_index].set_name,
clt_parameters,
colorProcParameters, //
......
......@@ -658,6 +658,9 @@ min_str_neib_fpn 0.35
public int cuas_discard_border = 8; // Discard this number of pixels from each side when merging
public double cuas_max_fold = 50;
public int cuas_min_in_row_col = 4; // Minimal number of defined tiles in a row/column
public double cuas_clt_threshold = 20; // threshold for CLT tile difference from a template
public double cuas_clt_decrease = 0.01; // Scale CLT outliers weight
// TODO: move next parameters elsewhere - they are not the motion blur ones.
public int mb_gain_index_pose = 5; // pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter
public int mb_gain_index_depth = 5; // depth map refine pass (SfM) to switch to full mb_max_gain from mb_max_gain_inter
......@@ -1972,6 +1975,11 @@ min_str_neib_fpn 0.35
"Maximal non-monotonic Px, Py in PxPyD (usually near image edges).");
gd.addNumericField("Minimal tiles in a row/column", this.cuas_min_in_row_col, 0,3,"tiles",
"Discards rows then columns that have less defined tiles (noticed in a diagonal after folds removal).");
gd.addNumericField("CLT tile diff thershold", this.cuas_clt_threshold, 5,7,"pix",
"Threshold to the CLT tile difference to a template (RMS).");
gd.addNumericField("CLT outliers scale", this.cuas_clt_decrease, 5,7,"pix",
"Scale CLT outliers tiles weight when averaging.");
gd.addTab("LMA sequence","Interscene LMA sequence control");
gd.addMessage("Parameters for control of the LMA pose adjustment sequence");
gd.addNumericField("Pose readjust number for full mb_gain", this.mb_gain_index_pose, 0,3,"",
......@@ -2858,6 +2866,8 @@ min_str_neib_fpn 0.35
this.cuas_discard_border= (int) gd.getNextNumber();
this.cuas_max_fold = gd.getNextNumber();
this.cuas_min_in_row_col= (int) gd.getNextNumber();
this.cuas_clt_threshold = gd.getNextNumber();
this.cuas_clt_decrease = gd.getNextNumber();
this.mb_gain_index_pose = (int) gd.getNextNumber();
this.mb_gain_index_depth =(int) gd.getNextNumber();
......@@ -3676,6 +3686,8 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"cuas_discard_border", this.cuas_discard_border+""); // int
properties.setProperty(prefix+"cuas_max_fold", this.cuas_max_fold+""); // double
properties.setProperty(prefix+"cuas_min_in_row_col", this.cuas_min_in_row_col+""); // int
properties.setProperty(prefix+"cuas_clt_threshold", this.cuas_clt_threshold+""); // double
properties.setProperty(prefix+"cuas_clt_decrease", this.cuas_clt_decrease+""); // double
properties.setProperty(prefix+"mb_gain_index_pose", this.mb_gain_index_pose+""); // int
properties.setProperty(prefix+"mb_gain_index_depth", this.mb_gain_index_depth+""); // int
......@@ -4469,6 +4481,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"cuas_discard_border")!=null) this.cuas_discard_border=Integer.parseInt(properties.getProperty(prefix+"cuas_discard_border"));
if (properties.getProperty(prefix+"cuas_max_fold")!=null) this.cuas_max_fold=Double.parseDouble(properties.getProperty(prefix+"cuas_max_fold"));
if (properties.getProperty(prefix+"cuas_min_in_row_col")!=null) this.cuas_min_in_row_col=Integer.parseInt(properties.getProperty(prefix+"cuas_min_in_row_col"));
if (properties.getProperty(prefix+"cuas_clt_threshold")!=null) this.cuas_clt_threshold=Double.parseDouble(properties.getProperty(prefix+"cuas_clt_threshold"));
if (properties.getProperty(prefix+"cuas_clt_decrease")!=null) this.cuas_clt_decrease=Double.parseDouble(properties.getProperty(prefix+"cuas_clt_decrease"));
if (properties.getProperty(prefix+"mb_gain_index_pose")!=null) this.mb_gain_index_pose=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_pose"));
if (properties.getProperty(prefix+"mb_gain_index_depth")!=null) this.mb_gain_index_depth=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_depth"));
......@@ -5264,6 +5278,8 @@ min_str_neib_fpn 0.35
imp.cuas_discard_border = this.cuas_discard_border;
imp.cuas_max_fold = this.cuas_max_fold;
imp.cuas_min_in_row_col = this.cuas_min_in_row_col;
imp.cuas_clt_threshold = this.cuas_clt_threshold;
imp.cuas_clt_decrease = this.cuas_clt_decrease;
imp.mb_gain_index_pose = this.mb_gain_index_pose;
imp.mb_gain_index_depth = this.mb_gain_index_depth;
......
......@@ -4896,10 +4896,12 @@ public class OpticalFlow {
}
if ((center_CLT != null) && center_CLT.hasCenterClt()) {
center_CLT.restoreInterProperties( // restore properties for interscene processing (extrinsics, ers, ...) // get relative poses (98)
Properties prop = center_CLT.restoreInterProperties( // restore properties for interscene processing (extrinsics, ers, ...) // get relative poses (98)
null, // String path, // full name with extension or null to use x3d directory
false, // boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
// TODO:
// if (prop == null) - failed to restore. Maybe OK, will need minimum (later will provide center_CLT as input)
} else {
if (center_reference && (quadCLTs[last_index] != null)) {
quadCLTs[last_index].restoreInterProperties( // restore properties for interscene processing (extrinsics, ers, ...) // get relative poses (98)
......@@ -4961,7 +4963,7 @@ public class OpticalFlow {
}
if (!build_ref_dsi && (quadCLTs[last_index] != null)) {
if (!build_ref_dsi && (quadCLTs[last_index] != null)) { // is it needed in CUAS mode?
quadCLTs[last_index].restoreInterProperties(null, false, debugLevel); //null
}
// 1. Reference scene DSI
......@@ -4985,8 +4987,9 @@ public class OpticalFlow {
//************* move loading center DSI here before building reference DSI. Or after "blue sky
while ((quadCLTs[last_index] == null) || !quadCLTs[last_index].hasBlueSky()) { // null
QuadCLT source_CLT = (center_CLT != null) ? center_CLT :quadCLTs[last_index];
/// while ((quadCLTs[last_index] == null) || !quadCLTs[last_index].hasBlueSky()) { // null
while ((quadCLTs[last_index] == null) || !source_CLT.hasBlueSky()) { // null
if (build_ref_dsi) {
TwoQuadCLT.copyJP4src( // actually there is no sense to process multiple image sets. Combine with other
// processing?
......@@ -5039,15 +5042,22 @@ public class OpticalFlow {
} else {// if (build_ref_dsi) {
// need to read photometric from reference scene -INTERFRAME.corr-xml, and if it exists - set and propagate to main?
// try to run reuseRefDSI() even for center?
reuseRefDSI(
// QuadCLT source_CLT = (center_CLT != null) ? center_CLT :quadCLTs[last_index];
reuseRefDSI( // if (dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null) System.out.println("DSI_MAIN file has old format and does not have spread data, will recalculate.");
clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters,
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLTs[last_index], // QuadCLT quadCLT_ref, // tiles should be set
source_CLT, // QuadCLT quadCLT_ref, // tiles should be set
batch_mode, // final boolean batch_mode,
threadsMax, // final int threadsMax,
updateStatus, // final boolean updateStatus,
debugLevel); // int debugLevel)
if (center_CLT != null) {
System.out.println ("In CUAS mode dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null), breaking loop");
System.out.println ("In CUAS mode dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null), breaking loop");
break;
}
if (center_reference) {
// center_ts = getReferenceTimestamp(); //??
}
......@@ -5055,23 +5065,23 @@ public class OpticalFlow {
} // while (blue_sky == null)
// by now if it was center_reference the last ref_dsi is restored with optional blue sky.
ref_blue_sky = quadCLTs[last_index].getDoubleBlueSky();
quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_channels[last_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel);
quadCLTs[last_index].setQuadClt(); // just in case ?
quadCLTs[last_index].setBlueSky(ref_blue_sky); //quadCLTs[ref_index].dsi has it
quadCLTs[last_index].setDSRBG(
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
if (center_CLT == null) { // does not work in CUAS mode
ref_blue_sky = quadCLTs[last_index].getDoubleBlueSky();
quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
set_channels[last_index].set_name,
clt_parameters,
colorProcParameters, //
threadsMax,
debugLevel);
quadCLTs[last_index].setQuadClt(); // just in case ?
quadCLTs[last_index].setBlueSky(ref_blue_sky); //quadCLTs[ref_index].dsi has it
quadCLTs[last_index].setDSRBG( // null
clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel)
}
if (!force_initial_orientations) {
// use master_clt? - where to look for stage. in CUAS mode build directory name and look there
if (center_CLT != null) {
......
......@@ -138,7 +138,7 @@ public class QuadCLT extends QuadCLTCPU {
sensor_mask_clt, // final int sensor_mask, // only if merge_channels
whc, // final int [] whc, // if int[2], will return width, height
false); // final boolean use_reference);
String suffix="-virtual";
String suffix="-virtual_threshold"+clt_parameters.imp.cuas_clt_threshold+"_decrease"+clt_parameters.imp.cuas_clt_decrease;;
ImagePlus imp_virtual = renderFromTD ( // do we need to update gpuQuad ?
sensor_mask_clt, // final int sensor_mask,
true, // merge_clt, // boolean merge_channels,
......
......@@ -368,6 +368,9 @@ public class QuadCLTCPU {
center_CLT.setCenterClt(
center_clt, // float [] clt,
center_clt_weights); // int clt_width);
} else {
System.out.println("restoreCenterClt(): No FCLT data in "+center_CLT.getImagePath());
return null;
}
center_CLT.restoreComboDSI(true);
return center_CLT;
......@@ -2925,12 +2928,13 @@ public class QuadCLTCPU {
// create from existing instance
this.properties = new Properties(); // properties will be different
// is it needed at all?
for (Enumeration<?> e = qParent.properties.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
this.properties.setProperty(key, qParent.properties.getProperty(key));
if (qParent.properties != null) { // 05.30.2025
for (Enumeration<?> e = qParent.properties.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
this.properties.setProperty(key, qParent.properties.getProperty(key));
}
this.properties.putAll(qParent.properties);
}
this.properties.putAll(qParent.properties);
this.eyesisCorrections= qParent.eyesisCorrections;
this.correctionsParameters = qParent.correctionsParameters;
this.clt_kernels = qParent.clt_kernels;
......@@ -4560,14 +4564,19 @@ public class QuadCLTCPU {
String x3d_path = getX3dDirectory();
path = x3d_path+Prefs.getFileSeparator()+path;
}
properties = loadProperties(
Properties new_properties = loadProperties(
path, // String path,
properties, // Properties properties)
true); // false); // boolean silent)
if (properties == null ) {
if (new_properties == null ) {
System.out.println("Failed to restore interframe properties from :"+path);
System.out.println("Resetting properties");
properties = new Properties();
return null;
// System.out.println("Keeping old properies");
// return null;
}
properties = new_properties;
String prefix = is_aux?PREFIX_AUX:PREFIX;
getProperties(prefix); // will set Geometry correction non-null
if (!(geometryCorrection instanceof ErsCorrection)) { // should only be for the new GeometryCorrection created in getProperties
......@@ -4684,7 +4693,7 @@ public class QuadCLTCPU {
}
return;
}
setDSRBG( // will likely not be used at all. Use getDLS() instead
setDSRBG( // will likely not be used at all. Use getDLS() instead // null
this.dsi[is_aux?TwoQuadCLT.DSI_DISPARITY_AUX:TwoQuadCLT.DSI_DISPARITY_MAIN],
this.dsi[is_aux?TwoQuadCLT.DSI_STRENGTH_AUX:TwoQuadCLT.DSI_STRENGTH_MAIN],
this.dsi[is_aux?TwoQuadCLT.DSI_DISPARITY_AUX_LMA:TwoQuadCLT.DSI_DISPARITY_MAIN_LMA],
......@@ -4714,7 +4723,7 @@ public class QuadCLTCPU {
}
double[][] rbg = getTileRBG(
double[][] rbg = getTileRBG( // null
clt_parameters,
disparity,
strength,
......@@ -4774,7 +4783,7 @@ public class QuadCLTCPU {
} else {
scan.setLMA(disparity_lma);
}
boolean [] selection = new boolean [disparity.length];
boolean [] selection = new boolean [disparity.length]; //null
for (int i = 0; i < disparity.length; i++) {
selection[i] = (!Double.isNaN(disparity[i]) && ((strength == null) || (strength[i] > 0)));
}
......
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