Commit 05f8b7db authored by Andrey Filippov's avatar Andrey Filippov

updating correction

parent f580e71e
......@@ -2081,7 +2081,7 @@ if (MORE_BUTTONS) {
if (label.equals("List Eyesis4pi") || label.equals("List X-cam")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
DistortionCalibrationData dcd=(DISTORTION_CALIBRATION_DATA!=null)?DISTORTION_CALIBRATION_DATA:
new DistortionCalibrationData(EYESIS_CAMERA_PARAMETERS);
new DistortionCalibrationData(EYESIS_CAMERA_PARAMETERS,GONIOMETER_PARAMETERS);
dcd.listCameraParameters(label.equals("List X-cam"));
return;
}
......@@ -2137,11 +2137,27 @@ if (MORE_BUTTONS) {
PATTERN_PARAMETERS.debugLevel=MASTER_DEBUG_LEVEL;
EYESIS_CAMERA_PARAMETERS.updateNumstations (numStations);
//if (MASTER_DEBUG_LEVEL==0) return; //TODO: Remove - just debugging
if (GONIOMETER==null) {
GONIOMETER= new Goniometer(
CAMERAS, // CalibrationHardwareInterface.CamerasInterface cameras,
DISTORTION, //MatchSimulatedPattern.DistortionParameters distortion,
PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters,
LASER_POINTERS, // MatchSimulatedPattern.LaserPointer laserPointers
SIMUL, //SimulationPattern.SimulParameters simulParametersDefault,
GONIOMETER_PARAMETERS, //LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
DISTORTION_PROCESS_CONFIGURATION
);
}
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData(
gridFiles,
PATTERN_PARAMETERS,
EYESIS_CAMERA_PARAMETERS,
LASER_POINTERS,
GONIOMETER_PARAMETERS,
MASTER_DEBUG_LEVEL);
LENS_DISTORTIONS.initImageSet(
DISTORTION_CALIBRATION_DATA,
......@@ -2178,7 +2194,6 @@ if (MORE_BUTTONS) {
if (label.equals("Restore Calibration")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
String defaultPath= (DISTORTION_CALIBRATION_DATA!=null)?DISTORTION_CALIBRATION_DATA.pathName:"";
// public static DistortionCalibrationData DISTORTION_CALIBRATION_DATA=null;
DistortionCalibrationData oldDISTORTION_CALIBRATION_DATA=DISTORTION_CALIBRATION_DATA;
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData(
false,
......@@ -2187,6 +2202,7 @@ if (MORE_BUTTONS) {
EYESIS_CAMERA_PARAMETERS,
ABERRATIONS_PARAMETERS,
LASER_POINTERS,
GONIOMETER_PARAMETERS,
null); // gridImages null - use specified files
if (DISTORTION_CALIBRATION_DATA.pathName== null){ // failed to select/open the file
DISTORTION_CALIBRATION_DATA=oldDISTORTION_CALIBRATION_DATA;
......@@ -3563,6 +3579,7 @@ if (MORE_BUTTONS) {
EYESIS_CAMERA_PARAMETERS, // is it null or 1?
ABERRATIONS_PARAMETERS,
LASER_POINTERS,
GONIOMETER_PARAMETERS,
imp_calibrated); // gridImages null - use specified files - single image
if (DISTORTION_CALIBRATION_DATA.pathName== null){ // failed to select/open the file
DISTORTION_CALIBRATION_DATA=null;
......@@ -6262,7 +6279,8 @@ if (MORE_BUTTONS) {
}
// initialize needed classes
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // images are not setup yet
EYESIS_CAMERA_PARAMETERS); //EyesisCameraParameters eyesisCameraParameters
EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters
GONIOMETER_PARAMETERS);
if ((LENS_DISTORTIONS!=null) && (LENS_DISTORTIONS.fittingStrategy!=null)) {
LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData=DISTORTION_CALIBRATION_DATA;
}
......@@ -9861,6 +9879,7 @@ if (MORE_BUTTONS) {
PATTERN_PARAMETERS,
EYESIS_CAMERA_PARAMETERS,
LASER_POINTERS, //LaserPointer laserPointers
GONIOMETER_PARAMETERS, //
true, // boolean read_grids
MASTER_DEBUG_LEVEL);
......@@ -9868,7 +9887,7 @@ if (MORE_BUTTONS) {
DISTORTION_CALIBRATION_DATA,
EYESIS_CAMERA_PARAMETERS
);
// set initial orientation of the cameras from the sensors that see mpst of the matching pointers
// set initial orientation of the cameras from the sensors that see most of the matching pointers
// just for the LMA to start
DISTORTION_CALIBRATION_DATA.setInitialOrientation(true);
return true;
......@@ -9899,6 +9918,7 @@ if (MORE_BUTTONS) {
null,
LENS_DISTORTIONS,
DISTORTION_CALIBRATION_DATA, // may be null, then it will not be updated, obviously (sensor masks)
GONIOMETER_PARAMETERS, // for motor sensitivity
ABERRATIONS_PARAMETERS.calibrationDirectory);//String calibration_directory
//getProperties(String prefix,Properties properties)
//EyesisCameraParameters
......@@ -9951,6 +9971,7 @@ if (MORE_BUTTONS) {
" (of "+ sourceFilesList[nset].length+"), file "+in_file+" (of "+ numFiles+ ") success in "+saved_file+" - "+sourceFilesList[nset][nfile]);
}
String grid_path = null;
/*
if (saveGrids && !overwriteGrids){ // check if result already exists
i = sourceFilesList[nset][nfile].lastIndexOf('/');
if (i>0){
......@@ -9961,6 +9982,19 @@ if (MORE_BUTTONS) {
continue;
}
}
}
*/
if (saveGrids){ // check if result already exists
i = sourceFilesList[nset][nfile].lastIndexOf('/');
if (i>0){
String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1);
grid_path = gridSetPath + Prefs.getFileSeparator() + grid_name;
if (!overwriteGrids && ((new File(grid_path)).exists())){ // check if result already exists
if (DEBUG_LEVEL>0) System.out.println("-->>> Skipping existing "+grid_path+" (as requested in \"Configure Process Distortions\")");
continue;
}
}
}
imp_sel=new ImagePlus(sourceFilesList[nset][nfile]); // read source file
EyesisTiff.decodeProperiesFromInfo(imp_sel);
......@@ -11260,6 +11294,7 @@ if (MORE_BUTTONS) {
eyesisCameraParameters,
aberrationParameters,
laserPointers,
GONIOMETER_PARAMETERS,
null); // gridImages null - use specified files
if (distortions.fittingStrategy!=null) {
distortions.fittingStrategy.distortionCalibrationData=dcd;
......@@ -11291,7 +11326,7 @@ if (MORE_BUTTONS) {
if (configPaths[2] !=null){ // load grid file
patternParameters.debugLevel=debugLevel;
patternParameters.updateStatus=updateStstus;
if (DEBUG_LEVEL>0) System.out.println("Autolading grid file "+configPaths[2]);
if (DEBUG_LEVEL>0) System.out.println("Autoloading grid file "+configPaths[2]);
patternParameters.selectAndRestore(true,configPaths[2],dcd.eyesisCameraParameters.numStations); // returns path or null on failure
} else {
System.out.println("No pattern grid file (ground gtruth) is provided");
......@@ -3026,6 +3026,7 @@ For each point in the image
if (imp.getRoi() instanceof PointRoi) {
pointRoi = (PointRoi) imp.getRoi();
} else {
System.out.println("This image does not have point marks - please mark it in "+source_path);
IJ.showMessage("This image does not have point marks - please mark it in "+source_path);
return null;
}
......@@ -3123,7 +3124,7 @@ For each point in the image
xyuv[i][3]=0.5;
}
GenericDialog gd=new GenericDialog("Specify U,V coordinates of the marker(s)");
gd.addMessage("Center white cell U=0.5, V=0.5");
gd.addMessage("Center white (LWIR black) cell U=0.5, V=0.5");
for (int n = 0; n < markers.length; n++) {
String label = "Marker "+(n+1)+" (x="+markers[n][0]+", y="+markers[n][1];
gd.addNumericField(label+" U", xyuv[n][2], 1, 5, "");
......
......@@ -24,6 +24,7 @@ package com.elphel.imagej.calibration;
**
*/
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -49,6 +50,7 @@ import Jama.Matrix; // Download here: http://math.nist.gov/javanumerics/jama/
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.gui.PointRoi;
import ij.gui.Roi;
import ij.process.FHT; // get rid, change to double
import ij.process.FloatProcessor;
......@@ -3133,7 +3135,7 @@ public class MatchSimulatedPattern {
if (roi==null){
selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
} else {
selection=roi.getBounds();
selection= (roi instanceof PointRoi) ? (new Rectangle(0, 0, imp.getWidth(), imp.getHeight())) : roi.getBounds();
}
MatchSimulatedPattern matchSimulatedPattern=new MatchSimulatedPattern(distortionParameters.FFTSize);
matchSimulatedPattern.debugLevel=debugLevel;
......@@ -3299,7 +3301,7 @@ public class MatchSimulatedPattern {
if (roi==null){
selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
} else {
selection=roi.getBounds();
selection= (roi instanceof PointRoi) ? (new Rectangle(0, 0, imp.getWidth(), imp.getHeight())) : roi.getBounds();
}
Rectangle initialPatternCell=new Rectangle(xc-fft_size,
yc-fft_size,
......@@ -3626,7 +3628,7 @@ public class MatchSimulatedPattern {
if (roi==null){
selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
} else {
selection=roi.getBounds();
selection= (roi instanceof PointRoi) ? (new Rectangle(0, 0, imp.getWidth(), imp.getHeight())) : roi.getBounds();
}
} else {
if ((getImageHeight()!=imp.getHeight()) || (getImageWidth()!=imp.getWidth())){
......@@ -6190,12 +6192,36 @@ public class MatchSimulatedPattern {
Roi roi= imp.getRoi();
Rectangle selection;
if (roi==null){
setWOI(0, 0, imp.getWidth(), imp.getHeight());
selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
} else {
if (roi instanceof PointRoi) {
PointRoi pointRoi = (PointRoi) roi;
Point [] points = pointRoi.getContainedPoints();
int [][] ipoints = new int [points.length][2];
for (int n = 0; n < ipoints.length; n++) {
ipoints[n][0] = points[n].x;
ipoints[n][1] = points[n].y;
}
// as if they a laser pointers
double [][] xyuv = new double [points.length][4];
for (int i =0; i < ipoints.length; i++) {
xyuv[i][0]=ipoints[i][0];
xyuv[i][1]=ipoints[i][1];
xyuv[i][2]=0.5;
xyuv[i][3]=0.5;
}
System.out.println("Setting first marker (of "+ipoints.length+") as pointer 0.5/0.5 - use use multiple?");
System.out.println("**** Not yet implemented, use 'Manual hint' command for each of the annotated files ****");
// setPointersXYUV(imp, xyuv);
setWOI(0, 0, imp.getWidth(), imp.getHeight());
selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
} else {
setWOI(roi.getBounds());
selection=roi.getBounds();
}
}
this.debugLevel=global_debug_level;
int patternCells=0;
// save initial distortionParameters.correlationMinInitialContrast
......@@ -6377,6 +6403,8 @@ public class MatchSimulatedPattern {
int numPointers=(laserPointer!=null)?laserPointer.laserUVMap.length:0;
double [][] pointersXY=(numPointers>0)?getPointersXYUV(imp, laserPointer):null;
if (global_debug_level > (debugThreshold+1)){
if (pointersXY!=null){
System.out.println("calculateDistortions() numPointers="+numPointers+" pointersXY.length="+pointersXY.length);
......
......@@ -7,6 +7,7 @@ import com.elphel.imagej.calibration.CalibrationFileManagement;
import com.elphel.imagej.calibration.DistortionCalibrationData;
import com.elphel.imagej.calibration.Distortions;
import com.elphel.imagej.calibration.EyesisAberrations;
import com.elphel.imagej.calibration.Goniometer;
import com.elphel.imagej.calibration.LensDistortionParameters;
import com.elphel.imagej.calibration.MultipleExtensionsFileFilter;
import com.elphel.imagej.common.GenericJTabbedDialog;
......@@ -2705,6 +2706,7 @@ import ij.gui.GenericDialog;
SubsystemOffsets subsystemOffsets,
Distortions systemDistortions,
DistortionCalibrationData system_distortionCalibrationData,
Goniometer.GoniometerParameters goniometerParameters,
String calibration_directory) {
EyesisCameraParameters sub_system = new EyesisCameraParameters();
sub_system.getProperties(prefix, properties);
......@@ -2745,7 +2747,8 @@ import ij.gui.GenericDialog;
System.out.println("sensors_path = "+sensors_path);
/// String [][] stationFilenames = new String[sub_system.numStations][0];
sub_distortionCalibrationData = new DistortionCalibrationData(
sub_system // EyesisCameraParameters eyesisCameraParameters
sub_system, // EyesisCameraParameters eyesisCameraParameters
goniometerParameters
);
// now read all sensor files
if ((sensors_path !=null) && (sensors_path != "")){ // load sensor
......@@ -2827,7 +2830,7 @@ import ij.gui.GenericDialog;
for (int i = 0; i < tmpPixelCorrection.length; i++ ) systemDistortions.pixelCorrection[i] = tmpPixelCorrection[i];
}
if (system_distortionCalibrationData == null) {
system_distortionCalibrationData = new DistortionCalibrationData (this);
system_distortionCalibrationData = new DistortionCalibrationData (this, goniometerParameters);
}
if (system_distortionCalibrationData.sensorMasks == null) {
system_distortionCalibrationData.sensorMasks = new double [new_channels][];
......
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