Commit 388be26d authored by Andrey Filippov's avatar Andrey Filippov

Implemented saving parameters with the model version, fixed bugs

parent a8fe8f68
...@@ -504,7 +504,7 @@ public class CLTParameters { ...@@ -504,7 +504,7 @@ public class CLTParameters {
public double gmap_discard_rdisp = 0.02; // discard above/below this fraction of average height public double gmap_discard_rdisp = 0.02; // discard above/below this fraction of average height
public double gmap_pix_size = 0.005; // hdr_x0y0, // in meters public double gmap_pix_size = 0.005; // hdr_x0y0, // in meters
public int gmap_max_image_width = 4000; // 3200; // increase pixel size as a power of 2 until image fits public int gmap_max_image_width = 4000; // 3200; // increase pixel size as a power of 2 until image fits
public double gmap_min_sfm = 10.0; // minimal SfM gain to keep ground map public double gmap_min_sfm = 2.0; //10.0; // minimal SfM gain to keep ground map
public double gmap_frac_sfm = 0.25; // Disregard SfM mask if lower good SfM area public double gmap_frac_sfm = 0.25; // Disregard SfM mask if lower good SfM area
public boolean gmap_crop_empty = true; public boolean gmap_crop_empty = true;
public int gmap_crop_extra = 20; public int gmap_crop_extra = 20;
......
...@@ -436,7 +436,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -436,7 +436,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
public static int CONVOLVE_FFT_SIZE = 128; // FFT size for sliding convolution with kernel public static int CONVOLVE_FFT_SIZE = 128; // FFT size for sliding convolution with kernel
public static int THREADS_MAX = 100; // testing multi-threading, limit maximal number of threads public static int THREADS_MAX = 100; // testing multi-threading, limit maximal number of threads
public double GAUSS_WIDTH = 0.4; // 0 - use Hamming window /// public double GAUSS_WIDTH = 0.4; // 0 - use Hamming window
public static double GAUSS_WIDTH = 0.4; // 0 - use Hamming window
/* replace */ /* replace */
public static int PSF_SUBPIXEL_SHOULD_BE_4 = 4; // sub-pixel decimation public static int PSF_SUBPIXEL_SHOULD_BE_4 = 4; // sub-pixel decimation
...@@ -1595,7 +1596,12 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -1595,7 +1596,12 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
if (label.equals("Save Clean")) { if (label.equals("Save Clean")) {
PROPERTIES = new Properties(); PROPERTIES = new Properties();
} }
saveProperties(null, CORRECTION_PARAMETERS.resultsDirectory, true, PROPERTIES, DEBUG_LEVEL); saveProperties(
null,
CORRECTION_PARAMETERS.resultsDirectory,
true,
PROPERTIES,
DEBUG_LEVEL);
return; return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("Save offset")) { } else if (label.equals("Save offset")) {
...@@ -9273,15 +9279,26 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9273,15 +9279,26 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return selectDirectoryOrFile(save, false, title, button, filter, defaultPath); return selectDirectoryOrFile(save, false, title, button, filter, defaultPath);
} }
public String selectFile(boolean save, String title, String button, FileFilter filter, String defaultPath) { public static String selectFile(
return selectDirectoryOrFile(save, false, title, button, filter, defaultPath); boolean save,
String title,
String button,
FileFilter filter,
String defaultPath) {
return selectDirectoryOrFile(
save,
false,
title,
button,
filter,
defaultPath);
} }
public String[] selectFiles(boolean save, String title, String button, FileFilter filter, String[] defaultPaths) { public static String[] selectFiles(boolean save, String title, String button, FileFilter filter, String[] defaultPaths) {
return selectDirectoriesOrFiles(save, false, title, button, filter, defaultPaths); return selectDirectoriesOrFiles(save, false, title, button, filter, defaultPaths);
} }
public String[] selectDirectoriesOrFiles(boolean save, boolean directory, String title, String button, public static String[] selectDirectoriesOrFiles(boolean save, boolean directory, String title, String button,
FileFilter filter, String[] defaultPaths) { FileFilter filter, String[] defaultPaths) {
File dir = null; File dir = null;
String defaultPath = null; String defaultPath = null;
...@@ -9352,7 +9369,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9352,7 +9369,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return filenames; return filenames;
} }
public String selectDirectoryOrFile(boolean save, boolean directory, String title, String button, FileFilter filter, public static String selectDirectoryOrFile(boolean save, boolean directory, String title, String button, FileFilter filter,
String defaultPath) { String defaultPath) {
File dir = null; File dir = null;
if ((defaultPath != null) && (!defaultPath.equals(""))) { if ((defaultPath != null) && (!defaultPath.equals(""))) {
...@@ -9392,7 +9409,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9392,7 +9409,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
DEFAULT_DIRECTORY = fc.getCurrentDirectory().getPath(); DEFAULT_DIRECTORY = fc.getCurrentDirectory().getPath();
return fc.getSelectedFile().getPath(); return fc.getSelectedFile().getPath();
} }
/*
class MultipleExtensionsFileFilter extends FileFilter { class MultipleExtensionsFileFilter extends FileFilter {
protected String[] patterns; protected String[] patterns;
protected String description = "JP4 files"; protected String description = "JP4 files";
...@@ -9424,10 +9441,10 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9424,10 +9441,10 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return description; return description;
} }
} }
*/
/* ======================================================================== */ /* ======================================================================== */
private boolean fixSliceSequence(ImageStack stack) { private static boolean fixSliceSequence(ImageStack stack) {
int i, j; int i, j;
int[] rgbNumbers = { 0, 0, 0 }; int[] rgbNumbers = { 0, 0, 0 };
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
...@@ -9474,7 +9491,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9474,7 +9491,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public void swapStackSlices(ImageStack stack, int slice1, int slice2) { public static void swapStackSlices(ImageStack stack, int slice1, int slice2) {
String label = stack.getSliceLabel(slice1); String label = stack.getSliceLabel(slice1);
stack.setSliceLabel(stack.getSliceLabel(slice2), slice1); stack.setSliceLabel(stack.getSliceLabel(slice2), slice1);
stack.setSliceLabel(label, slice2); stack.setSliceLabel(label, slice2);
...@@ -9484,7 +9501,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9484,7 +9501,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public ImageStack cropStack32(ImageStack stack, EyesisCorrectionParameters.SplitParameters splitParameters) { public static ImageStack cropStack32(ImageStack stack, EyesisCorrectionParameters.SplitParameters splitParameters) {
int size = stack.getSize(); int size = stack.getSize();
int iWidth = stack.getWidth(); int iWidth = stack.getWidth();
int height = stack.getHeight() - splitParameters.addTop - splitParameters.addBottom; int height = stack.getHeight() - splitParameters.addTop - splitParameters.addBottom;
...@@ -9509,7 +9526,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9509,7 +9526,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public ImageStack rotateStack32CW(ImageStack stack) { public static ImageStack rotateStack32CW(ImageStack stack) {
int size = stack.getSize(); int size = stack.getSize();
int height = stack.getHeight(); int height = stack.getHeight();
int width = stack.getWidth(); int width = stack.getWidth();
...@@ -9532,7 +9549,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9532,7 +9549,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public ImagePlus cropImage32(ImagePlus imp, EyesisCorrectionParameters.SplitParameters splitParameters) { public static ImagePlus cropImage32(ImagePlus imp, EyesisCorrectionParameters.SplitParameters splitParameters) {
int iWidth = imp.getWidth(); int iWidth = imp.getWidth();
int height = imp.getHeight() - splitParameters.addTop - splitParameters.addBottom; int height = imp.getHeight() - splitParameters.addTop - splitParameters.addBottom;
int width = imp.getWidth() - splitParameters.addLeft - splitParameters.addRight; int width = imp.getWidth() - splitParameters.addLeft - splitParameters.addRight;
...@@ -9552,7 +9569,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9552,7 +9569,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public ImagePlus rotateImage32CW(ImagePlus imp) { public static ImagePlus rotateImage32CW(ImagePlus imp) {
int width = imp.getWidth(); int width = imp.getWidth();
int height = imp.getHeight(); int height = imp.getHeight();
int length = width * height; int length = width * height;
...@@ -9569,7 +9586,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9569,7 +9586,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public CompositeImage convertToComposite(ImagePlus imp) { public static CompositeImage convertToComposite(ImagePlus imp) {
// if (imp.isComposite()) return imp; // if (imp.isComposite()) return imp;
if (imp.isComposite()) if (imp.isComposite())
return null; return null;
...@@ -9585,7 +9602,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9585,7 +9602,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public ImageStack convertRGB32toRGB16Stack(ImageStack stack32, public static ImageStack convertRGB32toRGB16Stack(ImageStack stack32,
EyesisCorrectionParameters.RGBParameters rgbParameters) { EyesisCorrectionParameters.RGBParameters rgbParameters) {
ImageStack stack16 = new ImageStack(stack32.getWidth(), stack32.getHeight()); ImageStack stack16 = new ImageStack(stack32.getWidth(), stack32.getHeight());
int length = stack32.getWidth() * stack32.getHeight(); int length = stack32.getWidth() * stack32.getHeight();
...@@ -9619,7 +9636,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9619,7 +9636,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
public ImagePlus convertRGB48toRGB24(ImageStack stack16, String title, int r_min, int r_max, int g_min, int g_max, public static ImagePlus convertRGB48toRGB24(ImageStack stack16, String title, int r_min, int r_max, int g_min, int g_max,
int b_min, int b_max, int alpha_min, int alpha_max) { int b_min, int b_max, int alpha_min, int alpha_max) {
int[] mins = { r_min, g_min, b_min, alpha_min }; int[] mins = { r_min, g_min, b_min, alpha_min };
int[] maxs = { r_max, g_max, b_max, alpha_max }; int[] maxs = { r_max, g_max, b_max, alpha_max };
...@@ -9655,7 +9672,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9655,7 +9672,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public ImagePlus Image32toGreyRGB24(ImagePlus imp) { public static ImagePlus Image32toGreyRGB24(ImagePlus imp) {
int width = imp.getWidth(); int width = imp.getWidth();
int height = imp.getHeight(); int height = imp.getHeight();
int length = width * height; int length = width * height;
...@@ -9684,7 +9701,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9684,7 +9701,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public void saveTimestampedProperties(String path, // full path or null public static void saveTimestampedProperties(String path, // full path or null
String directory, // use as default directory if path==null String directory, // use as default directory if path==null
boolean useXML, Properties properties) { boolean useXML, Properties properties) {
if (path == null) { if (path == null) {
...@@ -9701,7 +9718,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9701,7 +9718,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
public void saveProperties(String path, // full path or null public static void saveProperties(
String path, // full path or null
String directory, // use as default directory if path==null String directory, // use as default directory if path==null
boolean useXML, boolean useXML,
Properties properties, Properties properties,
...@@ -9709,13 +9727,15 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9709,13 +9727,15 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
String[] XMLPatterns = { ".corr-xml", ".xml" }; String[] XMLPatterns = { ".corr-xml", ".xml" };
String[] confPatterns = { ".conf" }; String[] confPatterns = { ".conf" };
String[] patterns = useXML ? XMLPatterns : confPatterns; String[] patterns = useXML ? XMLPatterns : confPatterns;
String ext = (useXML ? "XML " : "") + "Configuration files (" + (useXML ? "*.corr-xml" : "*.conf")
+ ")";
MultipleExtensionsFileFilter filter = new MultipleExtensionsFileFilter(patterns, ext); // filter
if (path == null) { if (path == null) {
path = selectFile(true, // save path = selectFile(true, // save
"Save configuration selection", // title "Save configuration selection", // title
"Select configuration file", // button "Select configuration file", // button
new MultipleExtensionsFileFilter(patterns, filter, // filter
(useXML ? "XML " : "") + "Configuration files (" + (useXML ? "*.corr-xml" : "*.conf")
+ ")"), // filter
directory); // may be "" directory); // may be ""
} else } else
path += patterns[0]; path += patterns[0];
...@@ -9898,7 +9918,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9898,7 +9918,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
/* ======================================================================== */ /* ======================================================================== */
public void setAllProperties(Properties properties) { public static void setAllProperties(Properties properties) {
properties.setProperty("MASTER_DEBUG_LEVEL", MASTER_DEBUG_LEVEL + ""); properties.setProperty("MASTER_DEBUG_LEVEL", MASTER_DEBUG_LEVEL + "");
properties.setProperty("UPDATE_STATUS", UPDATE_STATUS + ""); properties.setProperty("UPDATE_STATUS", UPDATE_STATUS + "");
SPLIT_PARAMETERS.setProperties("SPLIT_PARAMETERS.", properties); SPLIT_PARAMETERS.setProperties("SPLIT_PARAMETERS.", properties);
...@@ -9937,7 +9957,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -9937,7 +9957,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
/* ======================================================================== */ /* ======================================================================== */
public void getAllProperties(Properties properties) { public static void getAllProperties(Properties properties) {
MASTER_DEBUG_LEVEL = Integer.parseInt(properties.getProperty("MASTER_DEBUG_LEVEL")); MASTER_DEBUG_LEVEL = Integer.parseInt(properties.getProperty("MASTER_DEBUG_LEVEL"));
UPDATE_STATUS = Boolean.parseBoolean(properties.getProperty("UPDATE_STATUS")); UPDATE_STATUS = Boolean.parseBoolean(properties.getProperty("UPDATE_STATUS"));
SPLIT_PARAMETERS.getProperties("SPLIT_PARAMETERS.", properties); SPLIT_PARAMETERS.getProperties("SPLIT_PARAMETERS.", properties);
......
package com.elphel.imagej.correction;
import java.io.File;
import javax.swing.filechooser.FileFilter;
public class MultipleExtensionsFileFilter extends FileFilter {
protected String[] patterns;
protected String description = "JP4 files";
public MultipleExtensionsFileFilter(String[] patterns, String description) {
this.description = description;
this.patterns = patterns.clone();
}
public MultipleExtensionsFileFilter(String[] patterns) {
this.patterns = patterns.clone();
}
@Override
public boolean accept(File file) {
int i;
String name = file.getName();
if (file.isDirectory())
return true;
for (i = 0; i < patterns.length; i++) {
if (name.toLowerCase().endsWith(patterns[i].toLowerCase()))
return true;
}
return false;
}
@Override
public String getDescription() {
return description;
}
}
...@@ -1075,7 +1075,7 @@ public class ErsCorrection extends GeometryCorrection { ...@@ -1075,7 +1075,7 @@ public class ErsCorrection extends GeometryCorrection {
System.arraycopy(deltas0, 0, deltas, 0, deltas0.length); System.arraycopy(deltas0, 0, deltas, 0, deltas0.length);
System.arraycopy(deltas0, 3, deltas, deltas0.length, deltas0.length - 3); System.arraycopy(deltas0, 3, deltas, deltas0.length, deltas0.length - 3);
for (int i = 0; i < deltas.length; i++) deltas[i] *= scale_delta; for (int i = 0; i < deltas.length; i++) deltas[i] *= scale_delta;
int dbg_tile = 7508; // 56:23 // 16629; int dbg_tile = -7508; // 56:23 // 16629;
ErsCorrection scene_ers = scene_QuadClt.getErsCorrection(); ErsCorrection scene_ers = scene_QuadClt.getErsCorrection();
TileProcessor tp = reference_QuadClt.getTileProcessor(); TileProcessor tp = reference_QuadClt.getTileProcessor();
int tilesX = tp.getTilesX(); int tilesX = tp.getTilesX();
......
...@@ -65,7 +65,7 @@ public class IntersceneMatchParameters { ...@@ -65,7 +65,7 @@ public class IntersceneMatchParameters {
public boolean sfm_use = true; // use SfM to improve depth map public boolean sfm_use = true; // use SfM to improve depth map
public double sfm_min_base = 0.6; // 2.0; // use SfM if baseline exceeds this public double sfm_min_base = 0.6; // 2.0; // use SfM if baseline exceeds this
public double sfm_min_gain = 3.0; // 5.0; // Minimal SfM gain to apply SfM to the depth map public double sfm_min_gain = 2.0; // 5.0; // Minimal SfM gain to apply SfM to the depth map
public double sfm_min_frac = 0.5; // Minimal fraction of defined tiles to have SfM correction public double sfm_min_frac = 0.5; // Minimal fraction of defined tiles to have SfM correction
public int sfm_num_pairs = 32; // desired number of SfM pairs to average public int sfm_num_pairs = 32; // desired number of SfM pairs to average
......
...@@ -6492,6 +6492,17 @@ public class OpticalFlow { ...@@ -6492,6 +6492,17 @@ public class OpticalFlow {
start_ref_pointers[0] = earliest_scene; start_ref_pointers[0] = earliest_scene;
start_ref_pointers[1] = ref_index; start_ref_pointers[1] = ref_index;
} }
// temporary fix save/restore linkedModels, sourceDirectory, sourcePaths
// that are copied main-> aux in EyesisCorrectionParameters.updateAuxFromMain()
// quadCLT_main.correctionsParameters
String bkp_linkedModels = quadCLT_main.correctionsParameters.linkedModels;
String bkp_sourceDirectory = quadCLT_main.correctionsParameters.sourceDirectory;
String [] bkp_sourcePaths = quadCLT_main.correctionsParameters.sourcePaths;
quadCLTs[ref_index].saveConfInModelDirectory(); // save all (global) configurations in model/version directory
quadCLT_main.correctionsParameters.linkedModels = bkp_linkedModels;
quadCLT_main.correctionsParameters.sourceDirectory = bkp_sourceDirectory;
quadCLT_main.correctionsParameters.sourcePaths = bkp_sourcePaths;
System.out.println("buildSeries(): DONE"); // System.out.println("buildSeries(): DONE"); //
return quadCLTs[ref_index].getX3dTopDirectory(); return quadCLTs[ref_index].getX3dTopDirectory();
} }
......
...@@ -4979,6 +4979,21 @@ public class QuadCLTCPU { ...@@ -4979,6 +4979,21 @@ public class QuadCLTCPU {
return file_path; return file_path;
} }
public String saveConfInModelDirectory()
{
String x3d_path = getX3dDirectory();
String file_name = image_name + "-SETTINGS";
String file_path = x3d_path + Prefs.getFileSeparator() + file_name;
Properties properties=new Properties();
Eyesis_Correction.saveProperties(
file_path,
null,
true,
properties,
0); // DEBUG_LEVEL >-3);
return file_path;
}
public String saveAVIInModelDirectory( public String saveAVIInModelDirectory(
boolean dry_run, boolean dry_run,
......
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