Commit 52884d5b authored by Andrey Filippov's avatar Andrey Filippov

refactored, continue grid import

parent 047fdb5e
...@@ -248,5 +248,104 @@ public class CalibrationFileManagement { ...@@ -248,5 +248,104 @@ public class CalibrationFileManagement {
return description; return description;
} }
} }
// select directory that contains matching MultipleExtensionsFileFilter in specified min/max quantities
//https://stackoverflow.com/questions/22302199/java-filefilter-to-select-certain-directories
// public static class DirectoryContentsFilter extends FileFilter implements FilenameFilter {
public static class DirectoryChoser extends javax.swing.JFileChooser {
private static final long serialVersionUID = 390855361964415146L;
protected MultipleExtensionsFileFilter multipleExtensionsFileFilter;
protected int min_files;
protected int max_files;
protected String description;
public DirectoryChoser (
MultipleExtensionsFileFilter multipleExtensionsFileFilter,
int min_files,
int max_files,
String description) // may be null;
{
this.multipleExtensionsFileFilter= multipleExtensionsFileFilter;
this.min_files = min_files;
this.max_files = max_files;
this.description = description;
}
@Override
public boolean isDirectorySelectionEnabled() {
// setOpenButtonState(this, false);
File file = getSelectedFile();
// File [] files = getSelectedFiles();
if(file == null){
// setOpenButtonState(this, true);
return true; // false;
}
// setOpenButtonState(this, false);
if (!file.isDirectory()) return false;
/*
// Can not make it work correctly with multiple selection, giving up for now
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) {
return false;
}
*/
setOpenButtonState(this, true);
return true;
}
private void setOpenButtonState(java.awt.Container c, boolean flag) {
int len = c.getComponentCount();
for (int i = 0; i < len; i++) {
java.awt.Component comp = c.getComponent(i);
if (comp instanceof javax.swing.JButton) {
javax.swing.JButton b = (javax.swing.JButton)comp;
if ( b != null && b.getText() != null && b.getText().equals("Select") ) {
b.setEnabled(flag);
}
} else if (comp instanceof java.awt.Container) {
setOpenButtonState((java.awt.Container) comp, flag);
}
}
}
/*
@Override
public boolean accept (File file) {
if (!file.isDirectory()) return false;
// get a list of all matching files
int num_match = file.list(multipleExtensionsFileFilter).length;
if (num_match < min_files) return false;
if ((max_files > 0) && (num_match > max_files)) return false;
return true;
}
@Override
public boolean accept (File dir, String name) {
// No name filter, need to resolve
// Path dir_path = dir.toPath();
File target = Paths.get(dir.toString(),name).toFile();
return accept(target);
}
@Override
public String getDescription() { // if description is null - generate it
if (description == null) {
description = "Directories containing";
if (min_files > 0) description +=" not less than "+min_files;
if (max_files > 0) description +=" not more than "+max_files;
description += " "+multipleExtensionsFileFilter.description;
}
return description;
}
*/
}
} }
...@@ -4562,6 +4562,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4562,6 +4562,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
public String partialKernelDirectory=""; public String partialKernelDirectory="";
public String psfKernelDirectory=""; public String psfKernelDirectory="";
public String aberrationsKernelDirectory=""; public String aberrationsKernelDirectory="";
public String calibrationDirectory="";
public boolean autoRestore; public boolean autoRestore;
public String calibrationPath=""; public String calibrationPath="";
public String strategyPath=""; public String strategyPath="";
...@@ -4598,6 +4599,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4598,6 +4599,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
properties.setProperty(prefix+"partialKernelDirectory",this.partialKernelDirectory); properties.setProperty(prefix+"partialKernelDirectory",this.partialKernelDirectory);
properties.setProperty(prefix+"psfKernelDirectory",this.psfKernelDirectory); properties.setProperty(prefix+"psfKernelDirectory",this.psfKernelDirectory);
properties.setProperty(prefix+"aberrationsKernelDirectory",this.aberrationsKernelDirectory); properties.setProperty(prefix+"aberrationsKernelDirectory",this.aberrationsKernelDirectory);
properties.setProperty(prefix+"calibrationDirectory",this.calibrationDirectory);
properties.setProperty(prefix+"autoRestore",this.autoRestore+""); properties.setProperty(prefix+"autoRestore",this.autoRestore+"");
properties.setProperty(prefix+"calibrationPath",this.calibrationPath); properties.setProperty(prefix+"calibrationPath",this.calibrationPath);
...@@ -4642,6 +4644,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4642,6 +4644,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
if (properties.getProperty(prefix+"partialKernelDirectory")!=null) this.partialKernelDirectory=properties.getProperty(prefix+"partialKernelDirectory"); if (properties.getProperty(prefix+"partialKernelDirectory")!=null) this.partialKernelDirectory=properties.getProperty(prefix+"partialKernelDirectory");
if (properties.getProperty(prefix+"psfKernelDirectory")!=null) this.psfKernelDirectory=properties.getProperty(prefix+"psfKernelDirectory"); if (properties.getProperty(prefix+"psfKernelDirectory")!=null) this.psfKernelDirectory=properties.getProperty(prefix+"psfKernelDirectory");
if (properties.getProperty(prefix+"aberrationsKernelDirectory")!=null) this.aberrationsKernelDirectory=properties.getProperty(prefix+"aberrationsKernelDirectory"); if (properties.getProperty(prefix+"aberrationsKernelDirectory")!=null) this.aberrationsKernelDirectory=properties.getProperty(prefix+"aberrationsKernelDirectory");
if (properties.getProperty(prefix+"calibrationDirectory")!=null) this.calibrationDirectory=properties.getProperty(prefix+"calibrationDirectory");
if (properties.getProperty(prefix+"autoRestore")!=null) this.autoRestore=Boolean.parseBoolean(properties.getProperty(prefix+"autoRestore")); if (properties.getProperty(prefix+"autoRestore")!=null) this.autoRestore=Boolean.parseBoolean(properties.getProperty(prefix+"autoRestore"));
if (properties.getProperty(prefix+"calibrationPath")!=null) this.calibrationPath=properties.getProperty(prefix+"calibrationPath"); if (properties.getProperty(prefix+"calibrationPath")!=null) this.calibrationPath=properties.getProperty(prefix+"calibrationPath");
...@@ -4792,6 +4795,8 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4792,6 +4795,8 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
gd.addCheckbox("Select combined kernsls directory", false); gd.addCheckbox("Select combined kernsls directory", false);
gd.addStringField("Aberrations kernels directory", this.aberrationsKernelDirectory, 60); gd.addStringField("Aberrations kernels directory", this.aberrationsKernelDirectory, 60);
gd.addCheckbox("Select aberrations kernels directory", false); gd.addCheckbox("Select aberrations kernels directory", false);
gd.addStringField("Calibration directory (sensor, grid, strategy...)", this.calibrationDirectory, 60);
gd.addCheckbox("Select calibration directory", false);
gd.addCheckbox("Supress non-essential message boxes", this.noMessageBoxes); gd.addCheckbox("Supress non-essential message boxes", this.noMessageBoxes);
gd.addCheckbox("Overwrite result files if they exist", this.overwriteResultFiles); gd.addCheckbox("Overwrite result files if they exist", this.overwriteResultFiles);
gd.addCheckbox("Use reprojected grids for partial kernel calculation (false - extracted grids)", this.partialToReprojected); gd.addCheckbox("Use reprojected grids for partial kernel calculation (false - extracted grids)", this.partialToReprojected);
...@@ -4843,6 +4848,8 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4843,6 +4848,8 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
if (gd.getNextBoolean()) selectPSFKernelDirectory(false, this.psfKernelDirectory, false); if (gd.getNextBoolean()) selectPSFKernelDirectory(false, this.psfKernelDirectory, false);
this.aberrationsKernelDirectory=gd.getNextString(); this.aberrationsKernelDirectory=gd.getNextString();
if (gd.getNextBoolean()) selectAberrationsKernelDirectory(false, this.aberrationsKernelDirectory, false); if (gd.getNextBoolean()) selectAberrationsKernelDirectory(false, this.aberrationsKernelDirectory, false);
this.calibrationDirectory=gd.getNextString();
if (gd.getNextBoolean()) selectCalibrationDirectory(false, this.calibrationDirectory, false);
this.noMessageBoxes= gd.getNextBoolean(); this.noMessageBoxes= gd.getNextBoolean();
this.overwriteResultFiles= gd.getNextBoolean(); this.overwriteResultFiles= gd.getNextBoolean();
this.partialToReprojected= gd.getNextBoolean(); this.partialToReprojected= gd.getNextBoolean();
...@@ -4921,7 +4928,18 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4921,7 +4928,18 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
if (dir!=null) this.aberrationsKernelDirectory=dir; if (dir!=null) this.aberrationsKernelDirectory=dir;
return dir; return dir;
} }
public String selectCalibrationDirectory(boolean smart, String defaultPath, boolean newAllowed) {
String dir= CalibrationFileManagement.selectDirectory(
smart,
newAllowed, // save
"Calibration directory", // title
"Select calibration directory", // button
null, // filter
defaultPath); //this.sourceDirectory);
if (dir!=null) this.calibrationDirectory=dir;
return dir;
}
//
} }
......
...@@ -29,6 +29,8 @@ package com.elphel.imagej.calibration; ...@@ -29,6 +29,8 @@ package com.elphel.imagej.calibration;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.calibration.hardware.CamerasInterface;
import com.elphel.imagej.calibration.hardware.GoniometerMotors;
import com.elphel.imagej.cameras.EyesisCameraParameters; import com.elphel.imagej.cameras.EyesisCameraParameters;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.common.WindowTools; import com.elphel.imagej.common.WindowTools;
...@@ -50,7 +52,7 @@ horizontal axis: ...@@ -50,7 +52,7 @@ horizontal axis:
private ShowDoubleFloatArrays sdfaInstance = new ShowDoubleFloatArrays(); // just private ShowDoubleFloatArrays sdfaInstance = new ShowDoubleFloatArrays(); // just
// for // for
// debugging // debugging
public CalibrationHardwareInterface.CamerasInterface cameras = null; public CamerasInterface cameras = null;
public LwirReader lwirReader = null; public LwirReader lwirReader = null;
// public CalibrationHardwareInterface.LaserPointers lasers = null; // public CalibrationHardwareInterface.LaserPointers lasers = null;
// public static CalibrationHardwareInterface.FocusingMotors motorsS=null; // public static CalibrationHardwareInterface.FocusingMotors motorsS=null;
...@@ -67,7 +69,7 @@ horizontal axis: ...@@ -67,7 +69,7 @@ horizontal axis:
public MatchSimulatedPattern[] matchSimulatedPatterns = null; // =new public MatchSimulatedPattern[] matchSimulatedPatterns = null; // =new
// MatchSimulatedPattern(); // MatchSimulatedPattern();
public MatchSimulatedPattern.LaserPointer laserPointers = null; public LaserPointer laserPointers = null;
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters=null; MatchSimulatedPattern.PatternDetectParameters patternDetectParameters=null;
public SimulationPattern.SimulParameters simulParametersDefault=null; public SimulationPattern.SimulParameters simulParametersDefault=null;
public Goniometer.GoniometerParameters goniometerParameters = null; public Goniometer.GoniometerParameters goniometerParameters = null;
...@@ -78,11 +80,11 @@ horizontal axis: ...@@ -78,11 +80,11 @@ horizontal axis:
public double bottomRollersClearance=36.0; // angular clearance between the two bottom rollers public double bottomRollersClearance=36.0; // angular clearance between the two bottom rollers
public Goniometer(CalibrationHardwareInterface.CamerasInterface cameras, public Goniometer(CamerasInterface cameras,
MatchSimulatedPattern.DistortionParameters distortionParametersDefault, MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
EyesisCameraParameters eyesisCameraParameters, EyesisCameraParameters eyesisCameraParameters,
MatchSimulatedPattern.LaserPointer laserPointers, LaserPointer laserPointers,
SimulationPattern.SimulParameters simulParametersDefault, SimulationPattern.SimulParameters simulParametersDefault,
Goniometer.GoniometerParameters goniometerParameters, Goniometer.GoniometerParameters goniometerParameters,
DistortionProcessConfiguration distortionProcessConfiguration DistortionProcessConfiguration distortionProcessConfiguration
...@@ -104,7 +106,7 @@ horizontal axis: ...@@ -104,7 +106,7 @@ horizontal axis:
MatchSimulatedPattern.DistortionParameters distortionParametersDefault, MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
EyesisCameraParameters eyesisCameraParameters, EyesisCameraParameters eyesisCameraParameters,
MatchSimulatedPattern.LaserPointer laserPointers, LaserPointer laserPointers,
SimulationPattern.SimulParameters simulParametersDefault, SimulationPattern.SimulParameters simulParametersDefault,
Goniometer.GoniometerParameters goniometerParameters, Goniometer.GoniometerParameters goniometerParameters,
DistortionProcessConfiguration distortionProcessConfiguration DistortionProcessConfiguration distortionProcessConfiguration
...@@ -754,15 +756,10 @@ horizontal axis: ...@@ -754,15 +756,10 @@ horizontal axis:
public double[] estimateOrientation( public double[] estimateOrientation(
ImagePlus[] images, // last acquire images with number of pointers ImagePlus[] images, // last acquire images with number of pointers
// detected>0 // detected>0
// MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
// LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
// Goniometer.GoniometerParameters goniometerParameters,
// MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
// MatchSimulatedPattern.LaserPointer laserPointer, // null OK
// SimulationPattern.SimulParameters simulParametersDefault,
DistortionCalibrationData distortionCalibrationData, DistortionCalibrationData distortionCalibrationData,
PatternParameters patternParameters, // should not be null PatternParameters patternParameters, // should not be null
Distortions lensDistortions, // should not be null Distortions lensDistortions, // should not be null
LaserPointer laserPointers, // as a back up measure
boolean equalizeGreens, boolean equalizeGreens,
int threadsMax, int threadsMax,
boolean updateStatus, boolean updateStatus,
...@@ -815,8 +812,7 @@ horizontal axis: ...@@ -815,8 +812,7 @@ horizontal axis:
// used alternatively if keeping it // used alternatively if keeping it
this.matchSimulatedPatterns[numSensor].invalidateFlatFieldForGrid(); // Reset Flat Filed calibration - different image. this.matchSimulatedPatterns[numSensor].invalidateFlatFieldForGrid(); // Reset Flat Filed calibration - different image.
this.matchSimulatedPatterns[numSensor].invalidateFocusMask(); this.matchSimulatedPatterns[numSensor].invalidateFocusMask();
if (matchSimulatedPatterns[numSensor].getPointersXY(images[numSensor], if (MatchSimulatedPattern.getPointersXYUV(images[numSensor],this.laserPointers) == null) { // no pointers in this image
this.laserPointers.laserUVMap.length) == null) { // no pointers in this image
String msg = "No laser pointers detected for "+ images[numSensor].getTitle()+ " - they are needed for absolute grid positioning"; String msg = "No laser pointers detected for "+ images[numSensor].getTitle()+ " - they are needed for absolute grid positioning";
if (debug_level > 0) System.out.println("Warning: " + msg); if (debug_level > 0) System.out.println("Warning: " + msg);
IJ.showMessage("Warning", msg); IJ.showMessage("Warning", msg);
...@@ -933,8 +929,9 @@ horizontal axis: ...@@ -933,8 +929,9 @@ horizontal axis:
* //PatternParameters patternParameters, eyesisCameraParameters * //PatternParameters patternParameters, eyesisCameraParameters
* //EyesisCameraParameters eyesisCameraParameters ); * //EyesisCameraParameters eyesisCameraParameters );
*/ */
distortionCalibrationData.setImages(imp_calibrated, // ImagePlus [] images, // imagesin the memory distortionCalibrationData.setImages(imp_calibrated, // ImagePlus [] images, // images in the memory
patternParameters); // PatternParameters patternParameters); patternParameters, // PatternParameters patternParameters);
laserPointers);
distortionCalibrationData.initImageSet(eyesisCameraParameters); distortionCalibrationData.initImageSet(eyesisCameraParameters);
// Set initial azimuth and elevation // Set initial azimuth and elevation
...@@ -1075,7 +1072,7 @@ horizontal axis: ...@@ -1075,7 +1072,7 @@ horizontal axis:
5682.48889 per degree 5682.48889 per degree
*/ */
// motors rotate positive - look down, positive - CCW // motors rotate positive - look down, positive - CCW
CalibrationHardwareInterface.GoniometerMotors goniometerMotors=null; GoniometerMotors goniometerMotors=null;
// public double stepsPerDegreeTilt=-5682.48889; // minus that positive steps make negative elevation // public double stepsPerDegreeTilt=-5682.48889; // minus that positive steps make negative elevation
// public double stepsPerDegreeAxial=-36.0; // minus that positive steps make rotate CCW when looking from Eyesis top // public double stepsPerDegreeAxial=-36.0; // minus that positive steps make rotate CCW when looking from Eyesis top
// public double scanStepTilt=20.0; // degrees (equal steps not larger than // public double scanStepTilt=20.0; // degrees (equal steps not larger than
...@@ -1098,11 +1095,11 @@ horizontal axis: ...@@ -1098,11 +1095,11 @@ horizontal axis:
public GoniometerParameters(CalibrationHardwareInterface.GoniometerMotors goniometerMotors){ public GoniometerParameters(GoniometerMotors goniometerMotors){
this.goniometerMotors=goniometerMotors; this.goniometerMotors=goniometerMotors;
} }
public GoniometerParameters( public GoniometerParameters(
CalibrationHardwareInterface.GoniometerMotors goniometerMotors, GoniometerMotors goniometerMotors,
String gridGeometryFile, String gridGeometryFile,
String initialCalibrationFile, // not needed String initialCalibrationFile, // not needed
String strategyFile, String strategyFile,
......
This diff is collapsed.
...@@ -45,7 +45,7 @@ public class LensAdjustment { ...@@ -45,7 +45,7 @@ public class LensAdjustment {
MatchSimulatedPattern.DistortionParameters distortionParametersDefault, MatchSimulatedPattern.DistortionParameters distortionParametersDefault,
LensAdjustment.FocusMeasurementParameters focusMeasurementParameters, LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
MatchSimulatedPattern.LaserPointer laserPointer, // null OK LaserPointer laserPointer, // null OK
SimulationPattern.SimulParameters simulParametersDefault, SimulationPattern.SimulParameters simulParametersDefault,
boolean maskNonPSF, // mask out areas not needed for focusing PSF measurements boolean maskNonPSF, // mask out areas not needed for focusing PSF measurements
boolean equalizeGreens, boolean equalizeGreens,
......
/**
*
*/
/**
* @author eyesis
*
*/
package com.elphel.imagej.calibration.hardware;
\ No newline at end of file
...@@ -56,7 +56,6 @@ public class LwirReaderParameters { ...@@ -56,7 +56,6 @@ public class LwirReaderParameters {
protected double vnir_gain_bg = 2.401; // 1.476; protected double vnir_gain_bg = 2.401; // 1.476;
protected boolean [] selected_channels = {true, true, true, true, true, true, true, true}; protected boolean [] selected_channels = {true, true, true, true, true, true, true, true};
protected int max_lwir_width = 1024; // protected int max_lwir_width = 1024; //
/* /*
protected double [] vnir_exp_corr = {1.0, 1.0, 1.0, 1.0}; protected double [] vnir_exp_corr = {1.0, 1.0, 1.0, 1.0};
protected double [] vnir_gcorr_rbgb = { protected double [] vnir_gcorr_rbgb = {
...@@ -64,7 +63,6 @@ public class LwirReaderParameters { ...@@ -64,7 +63,6 @@ public class LwirReaderParameters {
1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0}; 1.0, 1.0, 1.0};
*/ */
protected double [] vnir_exp_corr = { protected double [] vnir_exp_corr = {
1.0, 1.0026, 0.9868, 1.0211}; 1.0, 1.0026, 0.9868, 1.0211};
...@@ -80,7 +78,19 @@ public class LwirReaderParameters { ...@@ -80,7 +78,19 @@ public class LwirReaderParameters {
protected int debug_level = 0;//-3: OFF, -2:Fatal, -1:ERROR, 0:WARN, 1:INFO,2:DEBUG protected int debug_level = 0;//-3: OFF, -2:Fatal, -1:ERROR, 0:WARN, 1:INFO,2:DEBUG
protected boolean show_images = false; protected boolean show_images = false;
protected int lwir_chn0 = 0; // not configurable
protected int vnir_chn0 = 4; // not configurable
// --- interface methods // --- interface methods
public int getLwirChn0 () {
return lwir_chn0;
}
public int getVnirChn0 () {
return vnir_chn0;
}
public boolean is_LWIR(int width) { public boolean is_LWIR(int width) {
return width <= max_lwir_width; return width <= max_lwir_width;
} }
......
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