Commit 91f2ace8 authored by Andrey Filippov's avatar Andrey Filippov

Adding arbitrary reference frame (not just the last), debugging 'Super

batch'
parent dc3b8518
......@@ -2705,7 +2705,7 @@ public class EyesisCorrections {
png,
show,
jpegQuality,// <0 - keep current, 0 - force Tiff, >0 use for JPEG
this.debugLevel);
this.debugLevel+3);
}
......
......@@ -7141,7 +7141,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
try {
TWO_QUAD_CLT.interIntraExportML(quadCLT, // QuadCLT quadCLT_main,
TWO_QUAD_CLT.interIntraExportML(
quadCLT, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......
......@@ -1526,7 +1526,8 @@ public class OpticalFlow {
}
int iwidth = imax_tX - imin_tX + 1;
int iheight = imax_tY - imin_tY + 1;
if ((iwidth <= 0) || (iheight <= 0)) {
//// if ((iwidth <= 0) || (iheight <= 0)) {
if ((iwidth <= 1) || (iheight <= 1)) {
System.out.println ("prepareSceneTiles(): iwidth ="+iwidth+", iheight ="+iheight+", min_tX="+min_tX+", imin_tY="+imin_tY+", max_tX="+max_tX+", imax_tY="+imax_tY);
continue;
}
......@@ -3480,8 +3481,8 @@ public class OpticalFlow {
}
double [][] disparity_map = null;
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
disparity_map = correlateInterscene(
clt_parameters, // final CLTParameters clt_parameters,
......@@ -3496,8 +3497,8 @@ public class OpticalFlow {
false, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
debug_level-5); // final int debug_level)
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
(new ShowDoubleFloatArrays()).showArrays(
disparity_map,
......@@ -3699,8 +3700,8 @@ public class OpticalFlow {
}
}
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
double [][] disparity_map =
// double [][][][][] clt_corr_partial =
......@@ -3713,8 +3714,8 @@ public class OpticalFlow {
nrefine, // final int nrefine, // just for debug title
debug_level-5); // final int debug_level)
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (debug_level > 0) {
(new ShowDoubleFloatArrays()).showArrays(
disparity_map,
......@@ -3972,8 +3973,8 @@ public class OpticalFlow {
}
ImagePlus imp_stack = new ImagePlus("scene_outlines", stack);
imp_stack.getProcessor().resetMinAndMax();
imp_stack.show();
// imp_stack.getProcessor().resetMinAndMax();
// imp_stack.show();
return imp_stack;
}
......@@ -3987,6 +3988,7 @@ public class OpticalFlow {
int debug_level
)
{
boolean generate_outlines = true; // TODO: move to configs
System.out.println("intersceneExport(), scene timestamp="+ref_scene.getImageName());
int num_scenes = scenes.length;
String [] combo_dsn_titles = {"disp", "strength","disp_lma","num_valid","change"};
......@@ -4023,7 +4025,7 @@ public class OpticalFlow {
final int tilesX = ref_scene.getTileProcessor().getTilesX();
final int tilesY = ref_scene.getTileProcessor().getTilesY();
final int tiles = tilesX * tilesY;
if (debug_level > 100) { // add parameter?
if (generate_outlines) { // debug_level > 100) { // add parameter?
int extra = 10; // pixels around largest outline
int scale = 4;
......@@ -4042,8 +4044,11 @@ public class OpticalFlow {
line_width_corners, // int line_width_corners,
line_color_outline, // Color line_color_outline,
line_color_corners // Color line_color_corners
);
imp_outlines.show();
);
ref_scene.saveImagePlusInModelDirectory(
"scene_outlines", // String suffix,
imp_outlines); // ImagePlus imp)
// imp_outlines.show();
}
final double [][] combo_dsn_change = new double [combo_dsn_titles.length] [tiles];
for (int i = 0; i < combo_dsn.length; i++) { // 4 elements: "disp", "strength","disp_lma","num_valid"
......@@ -4792,8 +4797,8 @@ public class OpticalFlow {
}
}
for (int nrefine = 0; nrefine < max_refines; nrefine++) {
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
double [][] disparity_map =
correlateInterscene(
......@@ -4809,8 +4814,8 @@ public class OpticalFlow {
false, // final boolean no_map, // do not generate disparity_map (time-consuming LMA)
debug_level-5); // final int debug_level)
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (debug_level > 0) {
(new ShowDoubleFloatArrays()).showArrays(
......@@ -5228,8 +5233,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
wis_wh, // final int [] wh,
image_dtt.transform_size, // final int transform_size,
threadsMax); // final int threadsMax) // maximal number of threads to launch
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
if ((vis_corr_pd != null) || (fclt_corrs != null)) { // calculate and extract correlation
image_dtt.clt_process_tl_correlations_GPU( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
......@@ -5276,8 +5281,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
threadsMax); // final int threadsMax) // maximal number of threads to launch
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
//nscene
if (debug_dhv != null) {
debug_dhv[3 * nscene + 0] = disparity_map[ImageDtt.DISPARITY_INDEX_CM];
......@@ -5450,8 +5455,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
dbg_titles);
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
final float [][][] fclt_corr = new float [tilesX * tilesY][][];
image_dtt.clt_process_tl_correlations_GPU( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
......@@ -5914,8 +5919,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (vis_corr_td != null) { // add combined data as the last slice
vis_corr_td[num_scenes] = ImageDtt.corr_td_wnd(
......@@ -6281,8 +6286,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
// Normalize accumulated corelations
if (ref_scene.hasGPU()) {
accumulateCorrelationsAcOnly(
......@@ -6385,8 +6390,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
}
Runtime.getRuntime().gc();
System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
if (show_accumulated_correlations || (accum_2d_corr != null)){ // -1
float [][] accum_2d_img = ImageDtt.corr_partial_dbg( // not used in lwir
fclt_corr, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
......
......@@ -109,6 +109,11 @@ public class QuadCLT extends QuadCLTCPU {
}
}
void setQuadClt() {
if (gpuQuad != null) {
gpuQuad.updateQuadCLT(this); // to re-load new set of Bayer images to the GPU
}
}
public QuadCLT(QuadCLTCPU pq, String name) {
super (pq, name);
......
......@@ -222,9 +222,12 @@ public class QuadCLTCPU {
return null;
}
void restoreQuadClt(QuadCLT savedQuadClt) {
void restoreQuadClt(QuadCLT savedQuadClt) { // do nothing
}
void setQuadClt() { // do nothing
}
double [][][][][][] getCltKernels() {
return clt_kernels;
}
......@@ -937,10 +940,6 @@ public class QuadCLTCPU {
}
public ImagePlus saveDoubleArrayInModelDirectory(
String suffix,
String [] labels, // or null
......@@ -959,6 +958,20 @@ public class QuadCLTCPU {
return imp;
}
public void saveImagePlusInModelDirectory(
String suffix,
ImagePlus imp)
{
String x3d_path = getX3dDirectory();
String file_name = image_name + suffix;
String file_path = x3d_path + Prefs.getFileSeparator() + file_name + ".tiff";
FileSaver fs=new FileSaver(imp);
fs.saveAsTiff(file_path);
System.out.println("saveDoubleArrayInModelDirectory(): saved "+file_path);
}
public double [][] readDoubleArrayFromModelDirectory(
String suffix,
int num_slices, // (0 - all)
......
......@@ -8518,6 +8518,7 @@ if (debugLevel > -100) return true; // temporarily !
// FIXME: *********** update adjustSeries to use QUADCLTCPU ! **********
// (QuadCLT [])
quadCLTs, // QuadCLT [] scenes, // ordered by increasing timestamps
ref_index, // int ref_index,
clt_parameters.ofp.debug_level_optical); // 1); // -1); // int debug_level);
System.out.println("End of interSeriesLMA()");
}
......@@ -9007,6 +9008,7 @@ if (debugLevel > -100) return true; // temporarily !
public void interIntraExportML(
QuadCLT quadCLT_main, // tiles should be set
int indx_ref, // = num_scenes - 1;
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
......@@ -9062,7 +9064,10 @@ if (debugLevel > -100) return true; // temporarily !
String [] sts = ref_only ? (new String [0]) : ers_reference.getScenes();
// get list of all other scenes
int num_scenes = sts.length + 1;
int indx_ref = num_scenes - 1;
// int indx_ref = num_scenes - 1;
if (indx_ref < 0) {
indx_ref = num_scenes - 1;
}
QuadCLT [] scenes = new QuadCLT [num_scenes];
scenes[indx_ref] = ref_quadCLT;
......@@ -11175,14 +11180,16 @@ if (debugLevel > -100) return true; // temporarily !
final int debugLevel) throws Exception
{
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) {
quadCLT_main.getGPU().resetGeometryCorrection();
quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_main.resetBayer();
quadCLT_main.setQuadClt(); // ignore previous result,
// quadCLT_main.getGPU().resetGeometryCorrection();
// quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
// quadCLT_main.resetBayer();
}
if ((quadCLT_aux != null) && (quadCLT_aux.getGPU() != null)) {
quadCLT_aux.getGPU().resetGeometryCorrection();
quadCLT_aux.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_aux.resetBayer();
quadCLT_aux.setQuadClt();
// quadCLT_aux.getGPU().resetGeometryCorrection();
// quadCLT_aux.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
// quadCLT_aux.resetBayer();
}
......@@ -11222,6 +11229,7 @@ if (debugLevel > -100) return true; // temporarily !
}
for (int nSet = 0; nSet < set_channels.length; nSet++){
/*
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) { //TODO: is it needed here? WAs not needed before - verify
quadCLT_main.getGPU().resetGeometryCorrection();
quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
......@@ -11231,7 +11239,8 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux.getGPU().resetGeometryCorrection();
quadCLT_aux.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_aux.resetBayer();
}
}*/
// nset -> name - n1, n2 (in
String set_name = set_channels[nSet].set_name;
int nSet_main = -1, nSet_aux = -1;
......@@ -11846,6 +11855,7 @@ if (debugLevel > -100) return true; // temporarily !
// System.out.println("batchLwirRig(): processing "+(quadCLT_main.getTotalFiles(set_channels_main)+quadCLT_aux.getTotalFiles(set_channels_aux))+" files ("+set_channels_main.length+" file sets) finished at "+
int num_main = (quadCLT_main==null)? 0 : quadCLT_main.getTotalFiles(set_channels_main);
int num_aux = (quadCLT_aux ==null)? 0 : quadCLT_aux.getTotalFiles(set_channels_aux);
/*
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) { //TODO: is it needed here? WAs not needed before - verify
quadCLT_main.getGPU().resetGeometryCorrection();
quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
......@@ -11856,6 +11866,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_aux.resetBayer();
}
*/
// Process LWIR16 tasks applicable to scene series rather than individual scenes
if (quadCLT_main.correctionsParameters.clt_batch_pose_pairs_main) {
TestInterLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
......@@ -11891,8 +11902,29 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_scene_main) {
int ref_index = 50; // temporarily, will make evently distributed
interSeriesLMA(quadCLT_main, // QUAD_CLT, // QuadCLT quadCLT_main,
ref_index, // int ref_index,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
channelGainParameters, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
equirectangularParameters, // EyesisCorrectionParameters.EquirectangularParameters
// equirectangularParameters,
properties, // Properties properties,
true, // false, // boolean reset_from_extrinsics,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_ml_last_main) {
interIntraExportML(quadCLT_main, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -11940,8 +11972,28 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_pose_scene_aux) {
int ref_index = 50; // temporarily, will make evently distributed
interSeriesLMA(quadCLT_aux, // QUAD_CLT, // QuadCLT quadCLT_main,
ref_index, // int ref_index,
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // COLOR_PROC_PARAMETERS, //EyesisCorrectionParameters.ColorProcParameters
// colorProcParameters,
channelGainParameters, // CorrectionColorProc.ColorGainsParameters channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
equirectangularParameters, // EyesisCorrectionParameters.EquirectangularParameters
// equirectangularParameters,
properties, // Properties properties,
true, // false, // boolean reset_from_extrinsics,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel);
}
if (quadCLT_main.correctionsParameters.clt_batch_ml_last_aux) {
interIntraExportML(quadCLT_aux, // QuadCLT quadCLT_main,
-1, // use last // int indx_ref, // = num_scenes - 1;
clt_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -11954,6 +12006,7 @@ if (debugLevel > -100) return true; // temporarily !
updateStatus, // final boolean updateStatus,
debugLevel);
}
/*
if ((quadCLT_main != null) && (quadCLT_main.getGPU() != null)) { //TODO: is it needed here? WAs not needed before - verify
quadCLT_main.getGPU().resetGeometryCorrection();
quadCLT_main.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
......@@ -11964,6 +12017,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux.gpuResetCorrVector(); // .getGPU().resetGeometryCorrectionVector();
quadCLT_aux.resetBayer();
}
*/
System.out.println("batchLwirRig(): processing "+(num_main + num_aux)+" files ("+set_channels.length+" file sets) finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
......
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