Commit 748d396b authored by Andrey Filippov's avatar Andrey Filippov

bug fixing for chained segments

parent 9616573c
...@@ -220,15 +220,15 @@ public class Interscene { ...@@ -220,15 +220,15 @@ public class Interscene {
adjusted_scene_index++; adjusted_scene_index++;
if ((ref_index - adjusted_scene_index) >= min_num_scenes_half) { if ((ref_index - adjusted_scene_index) >= min_num_scenes_half) {
if (adjusted_scene_index > cent_index) { if (adjusted_scene_index > cent_index) {
cent_index = adjusted_scene_index;
if (debugLevel > -3) { if (debugLevel > -3) {
System.out.println("Overlap mode, reusing previous scenes adjustment scenes, number of scenes = "+ System.out.println("Overlap mode 1, reusing previous scenes adjustment scenes, number of scenes = "+
(ref_index - adjusted_scene_index)); (ref_index - adjusted_scene_index)+", cent_index = "+cent_index+", ref_index="+ref_index);
} }
cent_index = adjusted_scene_index;
} else { } else {
if (debugLevel > -3) { if (debugLevel > -3) {
System.out.println("Overlap mode, partially reusing previous scenes adjustment scenes, number of scenes = "+ System.out.println("Overlap mode 2, partially reusing previous scenes adjustment scenes, number of scenes = "+
(ref_index - cent_index)+ " of "+(ref_index - adjusted_scene_index)); (ref_index - cent_index)+ " of "+(ref_index - adjusted_scene_index)+", cent_index = "+cent_index+", ref_index="+ref_index);
} }
} }
reused_overlap = true; reused_overlap = true;
...@@ -283,6 +283,10 @@ public class Interscene { ...@@ -283,6 +283,10 @@ public class Interscene {
} }
} }
if (debugLevel > -3) {
System.out.println("setInitialOrientationsCenterIms(): Running OpticalFlow.buildRefDSI() for center scene # "+cent_index+", : "+quadCLTs[cent_index].getImageName());
}
// create new dsi for quadCLTs[earliest_scene1] // create new dsi for quadCLTs[earliest_scene1]
OpticalFlow.buildRefDSI( // returned is a different instance than input -FIXED OpticalFlow.buildRefDSI( // returned is a different instance than input -FIXED
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
......
...@@ -4077,8 +4077,8 @@ public class OpticalFlow { ...@@ -4077,8 +4077,8 @@ public class OpticalFlow {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) { final int debugLevel) {
final int debugLevelInner= clt_parameters.batch_run? -2: debugLevel; // copied from TQ final int debugLevelInner= clt_parameters.batch_run? -2: debugLevel; // copied from TQ
if (debugLevelInner > -2) { if (debugLevelInner > -3) {
System.out.println("buildRefDSI(): clt_parameters.batch_run="+clt_parameters.batch_run+", debugLevel="+debugLevel+", debugLevelInner="+debugLevelInner); System.out.println("buildRefDSI(): clt_parameters.batch_run="+clt_parameters.batch_run+", debugLevel="+debugLevel+", debugLevelInner="+debugLevelInner+", fast="+fast);
} }
boolean photo_each = clt_parameters.photo_each; // true; // perform photogrammetric calibration to equalize pixel values boolean photo_each = clt_parameters.photo_each; // true; // perform photogrammetric calibration to equalize pixel values
boolean sky_extract = clt_parameters.imp.sky_extract; boolean sky_extract = clt_parameters.imp.sky_extract;
...@@ -4158,6 +4158,25 @@ public class OpticalFlow { ...@@ -4158,6 +4158,25 @@ public class OpticalFlow {
photo_each = false; photo_each = false;
sky_extract = false; sky_extract = false;
} }
if (debugLevel > -3) {
System.out.println("buildRefDSI(): Running preExpandCLTQuad3d() for scene "+quadCLT_ref.getImageName());
System.out.println("buildRefDSI(): quadCLT_ref.hasNewImageData() -> "+quadCLT_ref.hasNewImageData());
}
quadCLT_ref.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU). Spend several days to find this bug!
if (debugLevel > -3) {
//quadCLT_main
System.out.println("buildRefDSI():quadCLT_ref.tp.clt_3d_passes.size()="+quadCLT_ref.tp.clt_3d_passes.size());
System.out.println("buildRefDSI(): suspecting processing *-DSI_MAIN.tiff without loading new images to the GPU, running quadCLT_ref.saveQuadClt(). 12/07/2025");
boolean show_sources = debugLevel > 1000;
if (show_sources) {
quadCLT_ref.showImageData();
}
}
quadCLT_ref.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown quadCLT_ref.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters, clt_parameters,
...@@ -5179,7 +5198,10 @@ public class OpticalFlow { ...@@ -5179,7 +5198,10 @@ public class OpticalFlow {
if (center_reference) { // invalidate pointer to recalculate if (center_reference) { // invalidate pointer to recalculate
quadCLTs[last_index].setRefPointer((String) null); quadCLTs[last_index].setRefPointer((String) null);
} }
// quadCLTs[ref_index] = if (debugLevel > -3) {
System.out.println("buildSeries(): Running OpticalFlow.buildRefDSI() for last_index scene # "+last_index+", : "+quadCLTs[last_index].getImageName());
}
buildRefDSI( // returned is a different instance than input -FIXED buildRefDSI( // returned is a different instance than input -FIXED
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
fast, // boolean fast, fast, // boolean fast,
...@@ -5241,25 +5263,27 @@ public class OpticalFlow { ...@@ -5241,25 +5263,27 @@ public class OpticalFlow {
} }
} // while (blue_sky == null) } // while (blue_sky == null)
boolean early_try_back = false; // true; boolean early_try_back = false; // true;
// if (!force_initial_orientations) { // moved here as setDSRBG fails with .dsi={null, null,...,null}; // if (!force_initial_orientations) { // moved here as setDSRBG fails with .dsi={null, null,...,null};
// by now if it was center_reference the last ref_dsi is restored with optional blue sky. // by now if it was center_reference the last ref_dsi is restored with optional blue sky.
boolean bypass_last_index = (debugLevel > 1000); // && (quadCLTs[last_index] != null); // always. DEbugging 12/06/2025
if (center_CLT == null) { // does not work in CUAS mode if (center_CLT == null) { // does not work in CUAS mode
ref_blue_sky = quadCLTs[last_index].getDoubleBlueSky(); ref_blue_sky = quadCLTs[last_index].getDoubleBlueSky(); // new
quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN" if (!bypass_last_index) {
set_channels[last_index].set_name, quadCLTs[last_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
clt_parameters, set_channels[last_index].set_name,
colorProcParameters, // clt_parameters,
threadsMax, colorProcParameters, //
debugLevel); threadsMax,
debugLevel);
}
quadCLTs[last_index].setQuadClt(); // just in case ? quadCLTs[last_index].setQuadClt(); // just in case ?
quadCLTs[last_index].setBlueSky(ref_blue_sky); //quadCLTs[ref_index].dsi has it quadCLTs[last_index].setBlueSky(ref_blue_sky); //quadCLTs[ref_index].dsi has it
quadCLTs[last_index].setDSRBG( // null quadCLTs[last_index].setDSRBG( // DSI is needed in I244: cent_index = setInitialOrientationsIms(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus, updateStatus, // boolean updateStatus,
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
} }
if (!force_initial_orientations) { if (!force_initial_orientations) {
// use master_clt? - where to look for stage. in CUAS mode build directory name and look there // use master_clt? - where to look for stage. in CUAS mode build directory name and look there
...@@ -6439,7 +6463,7 @@ public class OpticalFlow { ...@@ -6439,7 +6463,7 @@ public class OpticalFlow {
} }
} }
final boolean toRGB = col_mode > 0; final boolean toRGB = col_mode > 0;
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+ String scenes_suffix = master_CLT.getImageName()+ // uadCLTs[quadCLTs.length-1].getImageName()+
"-SEQ-" + IntersceneMatchParameters.MODES3D[mode3d+1] + "-"+(toRGB?"COLOR":"MONO"); "-SEQ-" + IntersceneMatchParameters.MODES3D[mode3d+1] + "-"+(toRGB?"COLOR":"MONO");
String um_suffix = ""; String um_suffix = "";
if (!toRGB && um_mono) { if (!toRGB && um_mono) {
...@@ -7027,14 +7051,14 @@ public class OpticalFlow { ...@@ -7027,14 +7051,14 @@ public class OpticalFlow {
} }
} }
boolean export_terrain_sequence = true; boolean export_terrain_sequence = true; // check master_CLT
if (export_terrain_sequence && !clt_parameters.imp.lock_position) { if (export_terrain_sequence && !clt_parameters.imp.lock_position) {
combo_dsn_final =master_CLT.restoreComboDSI(true); combo_dsn_final =master_CLT.restoreComboDSI(true);
if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) { if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) {
System.out.println ("No terrain data available"); System.out.println ("No terrain data available");
} else { } else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN]; double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-TERRAIN"; String scenes_suffix = master_CLT.getImageName()+"-TERRAIN"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain = renderSceneSequence( ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas, master_CLT.hasCenterClt(), // boolean mode_cuas,
...@@ -7063,7 +7087,7 @@ public class OpticalFlow { ...@@ -7063,7 +7087,7 @@ public class OpticalFlow {
System.out.println ("No terrain data available"); System.out.println ("No terrain data available");
} else { } else {
double [] elevation_disparity = combo_dsn_final[COMBO_DSN_INDX_DISP]; double [] elevation_disparity = combo_dsn_final[COMBO_DSN_INDX_DISP];
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-ELEVATION"; String scenes_suffix = master_CLT.getImageName()+"-ELEVATION"; // quadCLTs[quadCLTs.length-1].getImageName()+"-ELEVATION";
ImagePlus imp_elevation = renderSceneSequence( ImagePlus imp_elevation = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas, master_CLT.hasCenterClt(), // boolean mode_cuas,
......
...@@ -96,7 +96,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -96,7 +96,7 @@ public class QuadCLT extends QuadCLTCPU {
} }
public QuadCLT saveQuadClt() { public QuadCLT saveQuadClt() { // used a lot!
if (gpuQuad == null) { if (gpuQuad == null) {
return null; return null;
} }
...@@ -108,7 +108,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -108,7 +108,7 @@ public class QuadCLT extends QuadCLTCPU {
} }
return savedQuadClt; return savedQuadClt;
} }
void restoreQuadClt(QuadCLT savedQuadClt) { void restoreQuadClt(QuadCLT savedQuadClt) { // only used in QCC5185: getTileRBG()
if (savedQuadClt != null) { if (savedQuadClt != null) {
gpuQuad.updateQuadCLT(savedQuadClt); gpuQuad.updateQuadCLT(savedQuadClt);
} }
...@@ -5028,7 +5028,7 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -5028,7 +5028,7 @@ public class QuadCLT extends QuadCLTCPU {
} }
/** /**
* Get GPU-calculated tiles centers coordinates for each sesnor * Get GPU-calculated tiles centers coordinates for each sensor
* @return per-tile null 2*num_sesnors array of alternating X and Y * @return per-tile null 2*num_sesnors array of alternating X and Y
*/ */
public double [][] getPortsXY() // run after GPU public double [][] getPortsXY() // run after GPU
...@@ -5153,7 +5153,37 @@ public class QuadCLT extends QuadCLTCPU { ...@@ -5153,7 +5153,37 @@ public class QuadCLT extends QuadCLTCPU {
title, title,
titles); titles);
} }
public void showImageData() {
showImageData(null, null);
}
public void showImageData(
double [][][] data,
String title) {
if (data == null) {
data = this.image_data;
}
if (title == null) {
title = this.getImageName()+"-IMAGE_DATA";
}
String [] sports = new String [data.length];
String [] scolors = new String [data[0].length];
for (int i = 0; i < sports.length; i++) sports[i]="port-"+i;
for (int i = 0; i < scolors.length; i++) scolors[i]="col-"+i;
int width = tp.getTilesX()*tp.getTileSize();
// int height = tp.getTilesY()*tp.getTileSize();
ShowDoubleFloatArrays.showArraysHyperstack(
data, // double[][][] pixels,
width, // int width,
title, // String title,
scolors, // String [] titles, // all slices*frames titles or just slice titles or null
sports, // String [] frame_titles, // frame titles or null
true); // boolean show)
return;
}
......
...@@ -14249,7 +14249,7 @@ public class QuadCLTCPU { ...@@ -14249,7 +14249,7 @@ public class QuadCLTCPU {
tp.clt_3d_passes.get(tp.clt_3d_passes.size()-1).setAvgVal(tp.clt_3d_passes.get(bg_pass).getAvgVal()); tp.clt_3d_passes.get(tp.clt_3d_passes.size()-1).setAvgVal(tp.clt_3d_passes.get(bg_pass).getAvgVal());
///// Refining after all added - end ///// Refining after all added - end
Runtime.getRuntime().gc(); Runtime.getRuntime().gc();
System.out.println("preExpandCLTQuad3d(): processing finished at "+ System.out.println("preExpandCLTQuad3d(): processing scene "+getImageName()+" finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory23="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory23="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true; return true;
} }
...@@ -17918,6 +17918,7 @@ public class QuadCLTCPU { ...@@ -17918,6 +17918,7 @@ public class QuadCLTCPU {
final boolean updateStatus, final boolean updateStatus,
final int debugLevel) final int debugLevel)
{ {
saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU). Spend several days to find this bug!
boolean float_center = true; // false - center around provided value TODO: Move to clt_parameters? boolean float_center = true; // false - center around provided value TODO: Move to clt_parameters?
boolean show_2d_correlations = (debugLevel>100); // true; // debug feature boolean show_2d_correlations = (debugLevel>100); // true; // debug feature
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
...@@ -18053,6 +18054,21 @@ public class QuadCLTCPU { ...@@ -18053,6 +18054,21 @@ public class QuadCLTCPU {
mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert mcorr_sel, // final int mcorr_sel, // Which pairs to correlate // +1 - all, +2 - dia, +4 - sq, +8 - neibs, +16 - hor + 32 - vert
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
debugLevel); debugLevel);
boolean show_dbg_img = debugLevel > 1000;
if (show_dbg_img) {
int tile_size = getTileSize();
int [] wh_dbg = {tilesX*tile_size,tilesY*tile_size};
double [][] dbg = ((QuadCLT) this).renderDoubleFromTDMono (
-1, // final int sensor_mask,
wh_dbg, // null, // int [] wh,
false); // boolean use_reference
ShowDoubleFloatArrays.showArrays(
dbg,
wh_dbg[0],
wh_dbg[1],
true,
getImageName()+"-test_CLTMeas");
}
} else { } else {
clt_data = image_dtt.quadCorrTD( // clt_data [task][sensor][color][][]; clt_data = image_dtt.quadCorrTD( // clt_data [task][sensor][color][][];
......
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