Commit eeacc90a authored by Andrey Filippov's avatar Andrey Filippov

temporarily hard-wired half-step in scene sequence traversing.

parent 8a35a76a
...@@ -220,7 +220,7 @@ import ij.process.ImageProcessor; ...@@ -220,7 +220,7 @@ import ij.process.ImageProcessor;
dpixels, // double[][] pixels, dpixels, // double[][] pixels,
width, // int width, width, // int width,
height, // int height, height, // int height,
num_slices, // int slices, num_slices, // int slices,
title, // String title, title, // String title,
combo_titles, // String [] titles); combo_titles, // String [] titles);
show); // boolean show show); // boolean show
......
...@@ -1104,7 +1104,7 @@ public class GroundPlane { ...@@ -1104,7 +1104,7 @@ public class GroundPlane {
return null; return null;
} }
double [][] ground_xyzatr = ErsCorrection.invertXYZATR(to_ground_xyzatr); // straight down from the camera, then rotated double [][] ground_xyzatr = ErsCorrection.invertXYZATR(to_ground_xyzatr); // straight down from the camera, then rotated
double altitude = ground_xyzatr[0][2] - offset; // offset to the ground level (negative) double altitude = ground_xyzatr[0][2] + offset; // offset to the ground level (negative)
double true_disparity = ref_Clt.getGeometryCorrection().getDisparityFromZ(-altitude); double true_disparity = ref_Clt.getGeometryCorrection().getDisparityFromZ(-altitude);
double corrected_disparity = true_disparity+ref_Clt.getDispInfinityRef(); double corrected_disparity = true_disparity+ref_Clt.getDispInfinityRef();
int tilesX = ref_Clt.getTilesX(); int tilesX = ref_Clt.getTilesX();
......
...@@ -6189,8 +6189,11 @@ public class OpticalFlow { ...@@ -6189,8 +6189,11 @@ public class OpticalFlow {
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel) throws Exception debugLevel); // final int debugLevel) throws Exception
if (debugLevel > -3) { if (debugLevel > -3) {
oriented_scenes[oriented_ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
System.out.println("Saving configuration with adjusted intrinsics");
System.out.println("**** Exiting without output files generation after running LY adjustments *****"); System.out.println("**** Exiting without output files generation after running LY adjustments *****");
} }
return null; return null;
} }
...@@ -7351,6 +7354,9 @@ public class OpticalFlow { ...@@ -7351,6 +7354,9 @@ public class OpticalFlow {
if (clt_parameters.imp.fgnd_gen_tilted){ if (clt_parameters.imp.fgnd_gen_tilted){
// No rotations orthogonal to ground, using tilted disparity // No rotations orthogonal to ground, using tilted disparity
if (clt_parameters.imp.fgnd_gen_scan){ if (clt_parameters.imp.fgnd_gen_scan){
/*
for (double gnd_offset = clt_parameters.imp.fgnd_ct_low; for (double gnd_offset = clt_parameters.imp.fgnd_ct_low;
gnd_offset <= clt_parameters.imp.fgnd_ct_high; gnd_offset <= clt_parameters.imp.fgnd_ct_high;
gnd_offset+=clt_parameters.imp.fgnd_ct_step) { gnd_offset+=clt_parameters.imp.fgnd_ct_step) {
...@@ -7389,34 +7395,33 @@ public class OpticalFlow { ...@@ -7389,34 +7395,33 @@ public class OpticalFlow {
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // QuadCLT ref_scene, // int ref_index, master_CLT, // QuadCLT ref_scene, // int ref_index,
debugLevel); // int debugLevel) { debugLevel); // int debugLevel) {
/*
ImagePlus imp_terrain_disp = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
false, // master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
new int[0], // int [] average_range,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_disp, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
*/
master_CLT.saveImagePlusInModelDirectory( master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix, null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_disp); // imp_scenes); // ImagePlus imp) imp_terrain_disp); // imp_scenes); // ImagePlus imp)
} }
} }
*/
ImagePlus imp_terrain_hyper_tilted = renderSceneSequenceHyper(
clt_parameters, // CLTParameters clt_parameters,
true, // boolean use_tilted_disparity, // tilted disparity: anisotropic distortions but full image fill
false, // boolean um_mono,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
false, // boolean toRGB,
"-TERRAIN-DISP_CT", // String suffix_in, // "-TERRAIN_CT"
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // QuadCLT ref_scene,
debugLevel); //int debugLevel)
if (imp_terrain_hyper_tilted == null) {
System.out.println("!!! Failed to create a hyper-stack terrain image for "+master_CLT.getImageName());
} else {
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_hyper_tilted); // imp_scenes); // ImagePlus imp)
}
} else { } else {
GroundPlane.prepareTerrainRender( GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
...@@ -7449,29 +7454,6 @@ public class OpticalFlow { ...@@ -7449,29 +7454,6 @@ public class OpticalFlow {
master_CLT, // QuadCLT ref_scene, // int ref_index, master_CLT, // QuadCLT ref_scene, // int ref_index,
debugLevel); // int debugLevel) { debugLevel); // int debugLevel) {
/*
ImagePlus imp_terrain_disp = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
false, // master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
new int[0], // int [] average_range,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_disp, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
*/
master_CLT.saveImagePlusInModelDirectory( master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix, null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_disp); // imp_scenes); // ImagePlus imp) imp_terrain_disp); // imp_scenes); // ImagePlus imp)
...@@ -7482,6 +7464,27 @@ public class OpticalFlow { ...@@ -7482,6 +7464,27 @@ public class OpticalFlow {
if (clt_parameters.imp.fgnd_gen_optho){ if (clt_parameters.imp.fgnd_gen_optho){
// rotating orthogonal to ground, using constant disparity // rotating orthogonal to ground, using constant disparity
if (clt_parameters.imp.fgnd_gen_scan){ if (clt_parameters.imp.fgnd_gen_scan){
ImagePlus imp_terrain_hyper = renderSceneSequenceHyper(
clt_parameters, // CLTParameters clt_parameters,
false, // boolean use_tilted_disparity, // tilted disparity: anisotropic distortions but full image fill
false, // boolean um_mono,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
false, // boolean toRGB,
"-TERRAIN_CT", // String suffix_in, // "-TERRAIN_CT"
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // QuadCLT ref_scene,
debugLevel); //int debugLevel)
if (imp_terrain_hyper == null) {
System.out.println("!!! Failed to create a hyper-stack terrain image for "+master_CLT.getImageName());
} else {
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_hyper); // imp_scenes); // ImagePlus imp)
}
/*
for (double gnd_offset = clt_parameters.imp.fgnd_ct_low; for (double gnd_offset = clt_parameters.imp.fgnd_ct_low;
gnd_offset <= clt_parameters.imp.fgnd_ct_high; gnd_offset <= clt_parameters.imp.fgnd_ct_high;
gnd_offset+=clt_parameters.imp.fgnd_ct_step) { gnd_offset+=clt_parameters.imp.fgnd_ct_step) {
...@@ -7536,10 +7539,9 @@ public class OpticalFlow { ...@@ -7536,10 +7539,9 @@ public class OpticalFlow {
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix, null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain); // imp_scenes); // ImagePlus imp) imp_terrain); // imp_scenes); // ImagePlus imp)
} }
} // for (double gnd_offset } // for (double gnd_offset
*/
} else { // if (clt_parameters.imp.fgnd_gen_scan){ } else { // if (clt_parameters.imp.fgnd_gen_scan){
double [][] gnp = GroundPlane.prepareTerrainRender( double [][] gnp = GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
...@@ -9065,12 +9067,96 @@ public class OpticalFlow { ...@@ -9065,12 +9067,96 @@ public class OpticalFlow {
return min_max_xyzatr; return min_max_xyzatr;
} }
public static ImagePlus renderSceneSequenceHyper(
CLTParameters clt_parameters,
boolean use_tilted_disparity, // tilted disparity: anisotropic distortions but full image fill
boolean um_mono,
boolean subtract_average,
int running_average,
boolean toRGB,
String suffix_in, // "-TERRAIN_CT"
QuadCLT [] quadCLTs,
QuadCLT ref_scene,
int debugLevel) {
suffix_in += clt_parameters.imp.fgnd_ct_low +":"+clt_parameters.imp.fgnd_ct_high+":"+clt_parameters.imp.fgnd_ct_step;
int width=0;
double [][] combo_dsn_final = null;
int num_ct_samples =(int) Math.round((clt_parameters.imp.fgnd_ct_high - clt_parameters.imp.fgnd_ct_low)/clt_parameters.imp.fgnd_ct_step);
float [][][] hyper_fpixels = new float [num_ct_samples][][];
String [] hyper_titles = new String [num_ct_samples];
String [] slice_titles = null; // will get from the first image, they all should be the same
ImagePlus imp_terrain_hyper = null;
String title = null;
for (int nct = 0; nct < num_ct_samples; nct++) {
double gnd_offset = clt_parameters.imp.fgnd_ct_low + nct* clt_parameters.imp.fgnd_ct_step;
hyper_titles[nct] = "GND"+((gnd_offset >0)? "+":"")+String.format("%.3fm", gnd_offset);
double [][] gnp = GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
ref_scene, // final QuadCLT ref_Clt,
use_tilted_disparity, // final boolean tilted_plane,
gnd_offset, // final double offset,
0.0, // final double test_bottom,
debugLevel-2); // final int debugLevel)
double [][] ignp = null;
if (gnp != null) {
ignp = ErsCorrection.invertXYZATR(gnp); // not used with tilted disparity
if (debugLevel > -1) {
System.out.println("Using airplane mode terrane as a single horizontal plane");
System.out.println(" ignp = [["+gnp[0][0]+", "+gnp[0][1]+", "+gnp[0][2]+"]["+gnp[1][0]+", "+gnp[1][1]+", "+gnp[1][2]+"]]");
System.out.println("ignp = [["+ignp[0][0]+", "+ignp[0][1]+", "+ignp[0][2]+"],["+ignp[1][0]+", "+ignp[1][1]+", "+ignp[1][2]+"]]");
}
combo_dsn_final =ref_scene.restoreComboDSI(true);
if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) {
System.out.println ("No terrain data available");
} else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
String scenes_suffix = ref_scene.getImageName()+suffix_in;
ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
um_mono, // boolean um_mono,
null, // float [][] average_slice, // [channel][pixel]
subtract_average, // boolean subtract_average,
running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG
false, // boolean toRGB,
(use_tilted_disparity? null: ignp), // double [][] ground_xyzatr,
1, // int sensor_mask,
scenes_suffix, // String suffix_in,
terrain_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
ref_scene, // QuadCLT ref_scene, // int ref_index,
debugLevel-2); // int debugLevel) {
int num_slices = imp_terrain.getStack().getSize();
hyper_fpixels[nct] = new float [num_slices][];
if (nct == 0) {
slice_titles = new String [num_slices];
for (int i = 0; i < num_slices; i++) {
slice_titles[i] = imp_terrain.getStack().getSliceLabel(i+1);
}
width = imp_terrain.getWidth();
title = imp_terrain.getTitle();
}
for (int i = 0; i < num_slices; i++) {
hyper_fpixels[nct][i] = (float[]) imp_terrain.getStack().getPixels(i+1);
}
}
} // if (gnp != null) {
} // for (double gnd_offset
imp_terrain_hyper = ShowDoubleFloatArrays.showArraysHyperstack(
hyper_fpixels, // float[][][] pixels,
width, // int width,
title, // String title,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
hyper_titles, // String [] frame_titles, // frame titles or null
false); // boolean show)
return imp_terrain_hyper;
}
public static ImagePlus renderSceneSequence( public static ImagePlus renderSceneSequence(
CLTParameters clt_parameters, CLTParameters clt_parameters,
// boolean mode_cuas,
boolean um_mono, boolean um_mono,
// boolean calculate_average, // now only with float pixels
// int [] average_range,
float [][] average_slice, // [channel][pixel] float [][] average_slice, // [channel][pixel]
boolean subtract_average, boolean subtract_average,
int running_average, int running_average,
...@@ -9078,14 +9164,11 @@ public class OpticalFlow { ...@@ -9078,14 +9164,11 @@ public class OpticalFlow {
int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG
boolean toRGB, boolean toRGB,
double [][] ground_xyzatr, double [][] ground_xyzatr,
// double [] stereo_xyz, // offset reference camera {x,y,z}
// double [] stereo_atr_in, // offset reference orientation (cuas)
int sensor_mask, int sensor_mask,
String suffix_in, String suffix_in,
double [] ref_disparity, double [] ref_disparity,
QuadCLT [] quadCLTs, QuadCLT [] quadCLTs,
QuadCLT ref_scene, // int ref_index, QuadCLT ref_scene, // int ref_index,
// int threadsMax,
int debugLevel) { int debugLevel) {
QuadCLT[] selected_scenes = selectScenes(quadCLTs, ref_scene); QuadCLT[] selected_scenes = selectScenes(quadCLTs, ref_scene);
int num_scenes = selected_scenes.length; int num_scenes = selected_scenes.length;
...@@ -9305,7 +9388,9 @@ public class OpticalFlow { ...@@ -9305,7 +9388,9 @@ public class OpticalFlow {
ref_pXpYD_or_null = ref_pXpYD; ref_pXpYD_or_null = ref_pXpYD;
ref_scene.getErsCorrection().setupERS(); ref_scene.getErsCorrection().setupERS();
System.out.println("Calculated reference ref_pXpYD from virtual_PxPyD"); if (debugLevel > -3) {
System.out.println("Calculated reference ref_pXpYD from virtual_PxPyD");
}
boolean debug_virtual_PxPyD = (debugLevel > 1000); boolean debug_virtual_PxPyD = (debugLevel > 1000);
if (debug_virtual_PxPyD) { if (debug_virtual_PxPyD) {
String [] dbg_titles = {"gnd-pX", "gnd-pY", "gnd-D","ref-pX", "ref-pY", "ref-D"}; String [] dbg_titles = {"gnd-pX", "gnd-pY", "gnd-D","ref-pX", "ref-pY", "ref-D"};
......
...@@ -2261,7 +2261,7 @@ public class QuadCLTCPU { ...@@ -2261,7 +2261,7 @@ public class QuadCLTCPU {
rslt_suffix += (clt_parameters.correlate_lma?"-LMA":"-NOLMA"); rslt_suffix += (clt_parameters.correlate_lma?"-LMA":"-NOLMA");
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY(); final int tilesY = tp.getTilesY();
saveDoubleArrayInModelDirectory( // error saveDoubleArrayInModelDirectory( // prints "saveDoubleArrayInModelDirectory(): saved ..."
rslt_suffix, // String suffix, rslt_suffix, // String suffix,
OpticalFlow.COMBO_DSN_TITLES, // combo_dsn_titles_full, // null, // String [] labels, // or null OpticalFlow.COMBO_DSN_TITLES, // combo_dsn_titles_full, // null, // String [] labels, // or null
combo_dsn_final, // dbg_data, // double [][] data, combo_dsn_final, // dbg_data, // double [][] data,
...@@ -4803,7 +4803,9 @@ public class QuadCLTCPU { ...@@ -4803,7 +4803,9 @@ public class QuadCLTCPU {
combo_dsi, // double [][] dsi, // if null - just check file exists combo_dsi, // double [][] dsi, // if null - just check file exists
silent); // boolean silent); silent); // boolean silent);
if (num_slices >= 0) { if (num_slices >= 0) {
System.out.println ("restoreComboDSI(): used "+getX3dDirectory()+ Prefs.getFileSeparator() + image_name + extra_suffix + DSI_SUFFIXES[indx] + ".tiff"); if (!silent) {
System.out.println ("restoreComboDSI(): used "+getX3dDirectory()+ Prefs.getFileSeparator() + image_name + extra_suffix + DSI_SUFFIXES[indx] + ".tiff");
}
setDSIFromCombo(combo_dsi); // reformat setDSIFromCombo(combo_dsi); // reformat
return combo_dsi; return combo_dsi;
} }
...@@ -5218,10 +5220,12 @@ public class QuadCLTCPU { ...@@ -5218,10 +5220,12 @@ public class QuadCLTCPU {
} }
return -1; return -1;
} }
if (dsi == null) { if (!silent) {
System.out.println("restoreDSI(): has "+imp.getStackSize()+" slices in file: "+file_path); if (dsi == null) {
} else { System.out.println("restoreDSI(): has "+imp.getStackSize()+" slices in file: "+file_path);
System.out.println("restoreDSI(): got "+imp.getStackSize()+" slices from file: "+file_path); } else {
System.out.println("restoreDSI(): got "+imp.getStackSize()+" slices from file: "+file_path);
}
} }
if (imp.getStackSize() < 2) { if (imp.getStackSize() < 2) {
if (!silent) { if (!silent) {
...@@ -6534,7 +6538,7 @@ public class QuadCLTCPU { ...@@ -6534,7 +6538,7 @@ public class QuadCLTCPU {
ImagePlus imp = new ImagePlus( file_name, imageStack); ImagePlus imp = new ImagePlus( file_name, imageStack);
FileSaver fs=new FileSaver(imp); FileSaver fs=new FileSaver(imp);
fs.saveAsTiff(file_path); fs.saveAsTiff(file_path);
System.out.println("saveDoubleArrayInModelDirectory(): saved "+file_path); System.out.println("saveDoubleArrayInTopModelDirectory(): saved "+file_path);
return imp; return imp;
} }
...@@ -6582,7 +6586,7 @@ public class QuadCLTCPU { ...@@ -6582,7 +6586,7 @@ public class QuadCLTCPU {
FileSaver fs=new FileSaver(imp); FileSaver fs=new FileSaver(imp);
fs.saveAsTiff(file_path); // image processor null? fs.saveAsTiff(file_path); // image processor null?
System.out.println("saveDoubleArrayInModelDirectory(): saved "+file_path); System.out.println("saveImagePlusInModelDirectory(): saved "+file_path);
return file_path; return file_path;
} }
......
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