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

updating correction

parent f580e71e
Loading
Loading
Loading
Loading
+41 −6
Original line number Original line Diff line number Diff line
@@ -2081,7 +2081,7 @@ if (MORE_BUTTONS) {
		if (label.equals("List Eyesis4pi") || label.equals("List X-cam")) {
		if (label.equals("List Eyesis4pi") || label.equals("List X-cam")) {
			DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
			DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
			DistortionCalibrationData dcd=(DISTORTION_CALIBRATION_DATA!=null)?DISTORTION_CALIBRATION_DATA:
			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"));
			dcd.listCameraParameters(label.equals("List X-cam"));
			return;
			return;
		}
		}
@@ -2137,11 +2137,27 @@ if (MORE_BUTTONS) {
			PATTERN_PARAMETERS.debugLevel=MASTER_DEBUG_LEVEL;
			PATTERN_PARAMETERS.debugLevel=MASTER_DEBUG_LEVEL;
			EYESIS_CAMERA_PARAMETERS.updateNumstations (numStations);
			EYESIS_CAMERA_PARAMETERS.updateNumstations (numStations);
//if (MASTER_DEBUG_LEVEL==0) return; //TODO: Remove - just debugging
//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(
			DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData(
					gridFiles,
					gridFiles,
					PATTERN_PARAMETERS,
					PATTERN_PARAMETERS,
					EYESIS_CAMERA_PARAMETERS,
					EYESIS_CAMERA_PARAMETERS,
					LASER_POINTERS,
					LASER_POINTERS,
					GONIOMETER_PARAMETERS,
					MASTER_DEBUG_LEVEL);
					MASTER_DEBUG_LEVEL);
			LENS_DISTORTIONS.initImageSet(
			LENS_DISTORTIONS.initImageSet(
 					DISTORTION_CALIBRATION_DATA,
 					DISTORTION_CALIBRATION_DATA,
@@ -2178,7 +2194,6 @@ if (MORE_BUTTONS) {
		if       (label.equals("Restore Calibration")) {
		if       (label.equals("Restore Calibration")) {
			DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
			DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
			String defaultPath= (DISTORTION_CALIBRATION_DATA!=null)?DISTORTION_CALIBRATION_DATA.pathName:"";
			String defaultPath= (DISTORTION_CALIBRATION_DATA!=null)?DISTORTION_CALIBRATION_DATA.pathName:"";
//    public static DistortionCalibrationData DISTORTION_CALIBRATION_DATA=null;
			DistortionCalibrationData oldDISTORTION_CALIBRATION_DATA=DISTORTION_CALIBRATION_DATA;
			DistortionCalibrationData oldDISTORTION_CALIBRATION_DATA=DISTORTION_CALIBRATION_DATA;
			DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData(
			DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData(
					false,
					false,
@@ -2187,6 +2202,7 @@ if (MORE_BUTTONS) {
					EYESIS_CAMERA_PARAMETERS,
					EYESIS_CAMERA_PARAMETERS,
					ABERRATIONS_PARAMETERS,
					ABERRATIONS_PARAMETERS,
					LASER_POINTERS,
					LASER_POINTERS,
					GONIOMETER_PARAMETERS,
					null); // gridImages null - use specified files
					null); // gridImages null - use specified files
			if (DISTORTION_CALIBRATION_DATA.pathName== null){ // failed to select/open the file
			if (DISTORTION_CALIBRATION_DATA.pathName== null){ // failed to select/open the file
				DISTORTION_CALIBRATION_DATA=oldDISTORTION_CALIBRATION_DATA;
				DISTORTION_CALIBRATION_DATA=oldDISTORTION_CALIBRATION_DATA;
@@ -3563,6 +3579,7 @@ if (MORE_BUTTONS) {
						EYESIS_CAMERA_PARAMETERS, // is it null or 1?
						EYESIS_CAMERA_PARAMETERS, // is it null or 1?
						ABERRATIONS_PARAMETERS,
						ABERRATIONS_PARAMETERS,
						LASER_POINTERS,
						LASER_POINTERS,
						GONIOMETER_PARAMETERS,
						imp_calibrated); // gridImages null - use specified files - single image
						imp_calibrated); // gridImages null - use specified files - single image
				if (DISTORTION_CALIBRATION_DATA.pathName== null){ // failed to select/open the file
				if (DISTORTION_CALIBRATION_DATA.pathName== null){ // failed to select/open the file
					DISTORTION_CALIBRATION_DATA=null;
					DISTORTION_CALIBRATION_DATA=null;
@@ -6262,7 +6279,8 @@ if (MORE_BUTTONS) {
			}
			}
			// initialize needed classes
			// initialize needed classes
			DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // images are not setup yet
			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)) {
			if ((LENS_DISTORTIONS!=null) && (LENS_DISTORTIONS.fittingStrategy!=null)) {
				LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData=DISTORTION_CALIBRATION_DATA;
				LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData=DISTORTION_CALIBRATION_DATA;
			}
			}
@@ -9861,6 +9879,7 @@ if (MORE_BUTTONS) {
				PATTERN_PARAMETERS,
				PATTERN_PARAMETERS,
				EYESIS_CAMERA_PARAMETERS,
				EYESIS_CAMERA_PARAMETERS,
				LASER_POINTERS,          //LaserPointer                                           laserPointers
				LASER_POINTERS,          //LaserPointer                                           laserPointers
				GONIOMETER_PARAMETERS,   //
				true,                    // boolean read_grids
				true,                    // boolean read_grids
				MASTER_DEBUG_LEVEL);
				MASTER_DEBUG_LEVEL);
@@ -9868,7 +9887,7 @@ if (MORE_BUTTONS) {
					DISTORTION_CALIBRATION_DATA,
					DISTORTION_CALIBRATION_DATA,
				EYESIS_CAMERA_PARAMETERS
				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
		// just for the LMA to start
		DISTORTION_CALIBRATION_DATA.setInitialOrientation(true);
		DISTORTION_CALIBRATION_DATA.setInitialOrientation(true);
		return true;
		return true;
@@ -9899,6 +9918,7 @@ if (MORE_BUTTONS) {
				null,
				null,
				LENS_DISTORTIONS,
				LENS_DISTORTIONS,
				DISTORTION_CALIBRATION_DATA, // may be null, then it will not be updated, obviously (sensor masks)
				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
				ABERRATIONS_PARAMETERS.calibrationDirectory);//String calibration_directory
//getProperties(String prefix,Properties properties)
//getProperties(String prefix,Properties properties)
//EyesisCameraParameters
//EyesisCameraParameters
@@ -9951,6 +9971,7 @@ if (MORE_BUTTONS) {
        					" (of "+ sourceFilesList[nset].length+"), file "+in_file+" (of "+ numFiles+ ") success in "+saved_file+" - "+sourceFilesList[nset][nfile]);
        					" (of "+ sourceFilesList[nset].length+"), file "+in_file+" (of "+ numFiles+ ") success in "+saved_file+" - "+sourceFilesList[nset][nfile]);
        		}
        		}
        		String grid_path = null;
        		String grid_path = null;
        		/*
        		if (saveGrids && !overwriteGrids){ // check if result already exists
        		if (saveGrids && !overwriteGrids){ // check if result already exists
        			i = sourceFilesList[nset][nfile].lastIndexOf('/');
        			i = sourceFilesList[nset][nfile].lastIndexOf('/');
        			if (i>0){
        			if (i>0){
@@ -9961,6 +9982,19 @@ if (MORE_BUTTONS) {
    						continue;
    						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
        		imp_sel=new ImagePlus(sourceFilesList[nset][nfile]); // read source file
        		EyesisTiff.decodeProperiesFromInfo(imp_sel);
        		EyesisTiff.decodeProperiesFromInfo(imp_sel);
@@ -11260,6 +11294,7 @@ if (MORE_BUTTONS) {
				eyesisCameraParameters,
				eyesisCameraParameters,
				aberrationParameters,
				aberrationParameters,
				laserPointers,
				laserPointers,
				GONIOMETER_PARAMETERS,
				null); // gridImages null - use specified files
				null); // gridImages null - use specified files
		if (distortions.fittingStrategy!=null) {
		if (distortions.fittingStrategy!=null) {
			distortions.fittingStrategy.distortionCalibrationData=dcd;
			distortions.fittingStrategy.distortionCalibrationData=dcd;
@@ -11291,7 +11326,7 @@ if (MORE_BUTTONS) {
		if (configPaths[2] !=null){ // load grid file
		if (configPaths[2] !=null){ // load grid file
			patternParameters.debugLevel=debugLevel;
			patternParameters.debugLevel=debugLevel;
			patternParameters.updateStatus=updateStstus;
			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
			patternParameters.selectAndRestore(true,configPaths[2],dcd.eyesisCameraParameters.numStations); // returns path or null on failure
		} else {
		} else {
			System.out.println("No pattern grid file (ground gtruth) is provided");
			System.out.println("No pattern grid file (ground gtruth) is provided");
+126 −24
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ import ij.text.TextWindow;
    	public static final int INDEX_B =        7;
    	public static final int INDEX_B =        7;
    	public static final double SMALL_FRACTION = 0.8; // consider sensor to be a "small" if average grid period < this fraction of the large
    	public static final double SMALL_FRACTION = 0.8; // consider sensor to be a "small" if average grid period < this fraction of the large


    	Goniometer.GoniometerParameters goniometerParameters = null;
    	public String pathName=null;
    	public String pathName=null;
    	public EyesisCameraParameters eyesisCameraParameters; // has "cartesian"
    	public EyesisCameraParameters eyesisCameraParameters; // has "cartesian"
        public int       numSubCameras=1;
        public int       numSubCameras=1;
@@ -631,14 +632,16 @@ import ij.text.TextWindow;
        		String [] filenames,
        		String [] filenames,
        		PatternParameters patternParameters,
        		PatternParameters patternParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		LaserPointer laserPointers
        		LaserPointer laserPointers,
        		Goniometer.GoniometerParameters goniometerParameters
        		) {
        		) {
    	    String [][] stationFilenames={filenames};
    	    String [][] stationFilenames={filenames};
        	setupDistortionCalibrationData(
        	setupDistortionCalibrationData(
        			stationFilenames,
        			stationFilenames,
            		patternParameters,
            		patternParameters,
            		eyesisCameraParameters, // debugLevel
            		eyesisCameraParameters, // debugLevel
            		laserPointers
            		laserPointers,
            		goniometerParameters
            		);
            		);
        }
        }
        public DistortionCalibrationData (
        public DistortionCalibrationData (
@@ -646,6 +649,7 @@ import ij.text.TextWindow;
        		PatternParameters      patternParameters,
        		PatternParameters      patternParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		LaserPointer           laserPointers,
        		LaserPointer           laserPointers,
        		Goniometer.GoniometerParameters goniometerParameters,
        		int debugLevel
        		int debugLevel
        		) {
        		) {
        	    this.debugLevel=debugLevel;
        	    this.debugLevel=debugLevel;
@@ -654,7 +658,8 @@ import ij.text.TextWindow;
        			stationFilenames,
        			stationFilenames,
            		patternParameters,
            		patternParameters,
            		eyesisCameraParameters, // debugLevel
            		eyesisCameraParameters, // debugLevel
            		laserPointers
            		laserPointers,
            		goniometerParameters
            		);
            		);
        }
        }


@@ -663,6 +668,7 @@ import ij.text.TextWindow;
        		PatternParameters patternParameters,
        		PatternParameters patternParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		LaserPointer laserPointers,
        		LaserPointer laserPointers,
        		Goniometer.GoniometerParameters goniometerParameters,
        		int debugLevel
        		int debugLevel
        		) {
        		) {
        	    this.debugLevel=debugLevel;
        	    this.debugLevel=debugLevel;
@@ -670,7 +676,8 @@ import ij.text.TextWindow;
        			stationFilenames,
        			stationFilenames,
            		patternParameters,
            		patternParameters,
            		eyesisCameraParameters, // debugLevel
            		eyesisCameraParameters, // debugLevel
            		laserPointers
            		laserPointers,
            		goniometerParameters
            		);
            		);
        }
        }


@@ -682,6 +689,7 @@ import ij.text.TextWindow;
        		PatternParameters                                      patternParameters,
        		PatternParameters                                      patternParameters,
        		EyesisCameraParameters                                 eyesisCameraParameters,
        		EyesisCameraParameters                                 eyesisCameraParameters,
        		LaserPointer                                           laserPointers, // as a backup if data is not available in the file
        		LaserPointer                                           laserPointers, // as a backup if data is not available in the file
        		Goniometer.GoniometerParameters                        goniometerParameters,
        		boolean                                                read_grids,
        		boolean                                                read_grids,
        		int                                                    debugLevel
        		int                                                    debugLevel
        		) {
        		) {
@@ -694,6 +702,7 @@ import ij.text.TextWindow;
            		patternParameters,
            		patternParameters,
            		eyesisCameraParameters, // debugLevel
            		eyesisCameraParameters, // debugLevel
            		laserPointers, // as a backup if data is not available in the file
            		laserPointers, // as a backup if data is not available in the file
            		goniometerParameters,
            		read_grids
            		read_grids
            		);
            		);
        }
        }
@@ -703,8 +712,10 @@ import ij.text.TextWindow;
        		String [][]            stationFilenames,
        		String [][]            stationFilenames,
        		PatternParameters      patternParameters,
        		PatternParameters      patternParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		LaserPointer           laserPointers // as a backup if data is not available in the file
        		LaserPointer           laserPointers, // as a backup if data is not available in the file
        		Goniometer.GoniometerParameters goniometerParameters
        		) {
        		) {
        	this.goniometerParameters = goniometerParameters;
        	setupIndices();
        	setupIndices();
        	this.eyesisCameraParameters=eyesisCameraParameters;
        	this.eyesisCameraParameters=eyesisCameraParameters;
        	int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
        	int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
@@ -772,6 +783,7 @@ import ij.text.TextWindow;
        		PatternParameters                                      patternParameters,
        		PatternParameters                                      patternParameters,
        		EyesisCameraParameters                                 eyesisCameraParameters,
        		EyesisCameraParameters                                 eyesisCameraParameters,
        		LaserPointer                                           laserPointers, // as a backup if data is not available in the file
        		LaserPointer                                           laserPointers, // as a backup if data is not available in the file
        		Goniometer.GoniometerParameters goniometerParameters,
        		boolean                                                read_grids
        		boolean                                                read_grids
        		) {
        		) {
        	class DirTs{
        	class DirTs{
@@ -836,6 +848,7 @@ import ij.text.TextWindow;
        			}
        			}
        		}
        		}
        	}
        	}
    		this.goniometerParameters =  goniometerParameters;
        	boolean ignore_LWIR_pointers = true; // skip LWIR absolute marks, use them later
        	boolean ignore_LWIR_pointers = true; // skip LWIR absolute marks, use them later
        	int max_lwir_width = 1023;  // use LWIR class
        	int max_lwir_width = 1023;  // use LWIR class
        	setupIndices();
        	setupIndices();
@@ -1548,9 +1561,11 @@ import ij.text.TextWindow;




        public DistortionCalibrationData (
        public DistortionCalibrationData (
        		EyesisCameraParameters eyesisCameraParameters
        		EyesisCameraParameters eyesisCameraParameters,
        		Goniometer.GoniometerParameters goniometerParameters
        		) {
        		) {
        	setupIndices();
        	setupIndices();
        	this.goniometerParameters = goniometerParameters;
        	int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
        	int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;


        	this.numSubCameras=numSubCameras;
        	this.numSubCameras=numSubCameras;
@@ -1562,9 +1577,11 @@ import ij.text.TextWindow;
        		ImagePlus []           images, // images in the memory
        		ImagePlus []           images, // images in the memory
        		PatternParameters      patternParameters,
        		PatternParameters      patternParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		EyesisCameraParameters eyesisCameraParameters,
        		LaserPointer           laserPointers
        		LaserPointer           laserPointers,
        		Goniometer.GoniometerParameters goniometerParameters
        		) {
        		) {
        	setupIndices();
        	setupIndices();
        	this.goniometerParameters = goniometerParameters;
        	int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
        	int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
        	this.numSubCameras=numSubCameras;
        	this.numSubCameras=numSubCameras;
        	this.eyesisCameraParameters=eyesisCameraParameters;
        	this.eyesisCameraParameters=eyesisCameraParameters;
@@ -2690,9 +2707,11 @@ import ij.text.TextWindow;
                    			if (this.debugLevel>0) System.out.println("Failed to find any known orientation");
                    			if (this.debugLevel>0) System.out.println("Failed to find any known orientation");
                    			return null;
                    			return null;
                			}
                			}
                			if       (late_set <0) iBest= early_set;
                			if       (late_set <0) {
                			else if  (early_set <0) iBest= late_set;
                				iBest= early_set;
                			else {
                			} else if  (early_set <0) {
                				iBest= late_set;
                			} else {
                				// interpolate
                				// interpolate
            					double axialEarly=this.gIS[early_set].goniometerAxial;
            					double axialEarly=this.gIS[early_set].goniometerAxial;
            					double axialLate= this.gIS[late_set].goniometerAxial;
            					double axialLate= this.gIS[late_set].goniometerAxial;
@@ -2745,9 +2764,12 @@ import ij.text.TextWindow;
                			}
                			}
            				this.gIS[i].orientationEstimated=true;
            				this.gIS[i].orientationEstimated=true;
                			double [] result = {
                			double [] result = {
                					this.gIS[iBest].goniometerTilt,
//                					this.gIS[iBest].goniometerTilt,
                					this.gIS[iBest].goniometerAxial,
//                					this.gIS[iBest].goniometerAxial,
                					this.gIS[iBest].interAxisAngle
///                					this.gIS[iBest].interAxisAngle
                					this.gIS[i].goniometerTilt,
                					this.gIS[i].goniometerAxial,
                					this.gIS[i].interAxisAngle
                			};
                			};
        					return result;
        					return result;
        				}
        				}
@@ -2768,14 +2790,17 @@ import ij.text.TextWindow;
            				if ( //   (j!=i)  && // not needed - this set does not have orientation
            				if ( //   (j!=i)  && // not needed - this set does not have orientation
            						(this.gIS[j].getStationNumber()==stationNumber) &&
            						(this.gIS[j].getStationNumber()==stationNumber) &&
            						(this.gIS[j].motors[mHorizontal]==thisMotorHorizontal) &&
            						(this.gIS[j].motors[mHorizontal]==thisMotorHorizontal) &&
            						!this.gIS[j].orientationEstimated && // new
            						!Double.isNaN(this.gIS[j].goniometerTilt) &&
            						!Double.isNaN(this.gIS[j].goniometerTilt) &&
            						!Double.isNaN(this.gIS[j].goniometerAxial) &&
            						!Double.isNaN(this.gIS[j].goniometerAxial) &&
            						!Double.isNaN(this.gIS[j].interAxisAngle)){
            						!Double.isNaN(this.gIS[j].interAxisAngle)){
            					System.out.println("Found image set "+j+" with timestamp "+ timeStamp + " with known attitude to estimate this attitude");
            					setList.add(new Integer(j));
            					setList.add(new Integer(j));
            				}
            				}
            			}
            			}
            			if (setList.size()>=2){
            			if (setList.size()>=2){
            				if (this.debugLevel>2) System.out.println("getImagesetTiltAxial("+timeStamp+"): estimating orientation for set # "+i+": this.debugLevel="+this.debugLevel);
//            				if (this.debugLevel>2) System.out.println("getImagesetTiltAxial("+timeStamp+"): estimating orientation for set # "+i+": this.debugLevel="+this.debugLevel);
            				if (this.debugLevel > -1) System.out.println("getImagesetTiltAxial("+timeStamp+"): estimating orientation for set # "+i+": this.debugLevel="+this.debugLevel);
            				// find the closest one
            				// find the closest one
            				int indexClosest=setList.get(0);
            				int indexClosest=setList.get(0);
            				double dClosest=Math.abs(this.gIS[indexClosest].motors[mAxial]-thisMotorAxial);
            				double dClosest=Math.abs(this.gIS[indexClosest].motors[mAxial]-thisMotorAxial);
@@ -2849,10 +2874,22 @@ import ij.text.TextWindow;
                    					") is not defined, using interpolated between sets # "+indexClosest+" (timestamp "+IJ.d2s(this.gIS[indexClosest].timeStamp,6)+") "+
                    					") is not defined, using interpolated between sets # "+indexClosest+" (timestamp "+IJ.d2s(this.gIS[indexClosest].timeStamp,6)+") "+
                    					"and # "+indexSecond+" (timestamp "+IJ.d2s(this.gIS[indexSecond].timeStamp,6)+")");
                    					"and # "+indexSecond+" (timestamp "+IJ.d2s(this.gIS[indexSecond].timeStamp,6)+")");
            				}
            				}
//            			} else if (setList.size() >= 1){
//            				if (this.debugLevel > -1) System.out.println("getImagesetTiltAxial("+timeStamp+
//            						"): estimating orientation for set # "+i+" from a single set "+setList.get(0)+": this.debugLevel="+this.debugLevel);

            			} else { // old way
            			} else { // old way
            				// first try for the same station number only:
            				iBest = -1;
            				double d2Min=-1;
            				double d2Min=-1;
            				for (int j=0;j<this.gIS.length;j++) if ((j!=i) && (this.gIS[j].motors!=null) &&
            				int station_number = this.gIS[i].getStationNumber();
            						!Double.isNaN(this.gIS[j].goniometerTilt) && !Double.isNaN(this.gIS[j].goniometerAxial )  && !Double.isNaN(this.gIS[j].interAxisAngle)) {
            				for (int j=0;j<this.gIS.length;j++) if ((j!=i) &&
            						(this.gIS[j].getStationNumber() == station_number) &&
            						!this.gIS[j].orientationEstimated &&
            						(this.gIS[j].motors!=null) &&
            						!Double.isNaN(this.gIS[j].goniometerTilt) &&
            						!Double.isNaN(this.gIS[j].goniometerAxial )  &&
            						!Double.isNaN(this.gIS[j].interAxisAngle)) {
            					double d2=0;
            					double d2=0;
            					for (int k=0;k<this.gIS[j].motors.length;k++){
            					for (int k=0;k<this.gIS[j].motors.length;k++){
            						d2+=1.0*(this.gIS[j].motors[k]-this.gIS[i].motors[k])*
            						d2+=1.0*(this.gIS[j].motors[k]-this.gIS[i].motors[k])*
@@ -2863,21 +2900,84 @@ import ij.text.TextWindow;
            						iBest=j;
            						iBest=j;
            					}
            					}
            				}
            				}
            				if (iBest < 0) {
                				d2Min=-1;
                				for (int j=0;j<this.gIS.length;j++) if ((j!=i) &&
                						(this.gIS[j].motors!=null) &&
                						!this.gIS[j].orientationEstimated &&
                						!Double.isNaN(this.gIS[j].goniometerTilt) &&
                						!Double.isNaN(this.gIS[j].goniometerAxial )  &&
                						!Double.isNaN(this.gIS[j].interAxisAngle)) {
                					double d2=0;
                					for (int k=0;k<this.gIS[j].motors.length;k++){
                						d2+=1.0*(this.gIS[j].motors[k]-this.gIS[i].motors[k])*
                						(this.gIS[j].motors[k]-this.gIS[i].motors[k]);
                					}
                					if ((d2Min<0) || (d2Min>d2)) {
                						d2Min=d2;
                						iBest=j;
                					}
                					}
                				}
                				}
        			double [] result = {
                				if (iBest < 0) {
        					this.gIS[iBest].goniometerTilt,
                    				d2Min=-1;
        					this.gIS[iBest].goniometerAxial,
                    				for (int j=0;j<this.gIS.length;j++) if ((j!=i) &&
        					this.gIS[iBest].interAxisAngle
                    						(this.gIS[j].motors!=null) &&
        			};
                    						!Double.isNaN(this.gIS[j].goniometerTilt) &&
                    						!Double.isNaN(this.gIS[j].goniometerAxial )  &&
                    						!Double.isNaN(this.gIS[j].interAxisAngle)) {
                    					double d2=0;
                    					for (int k=0;k<this.gIS[j].motors.length;k++){
                    						d2+=1.0*(this.gIS[j].motors[k]-this.gIS[i].motors[k])*
                    						(this.gIS[j].motors[k]-this.gIS[i].motors[k]);
                    					}
                    					if ((d2Min<0) || (d2Min>d2)) {
                    						d2Min=d2;
                    						iBest=j;
                    					}
                    				}
                    				System.out.println("Used any station numer with even estimated orientation, iBest = "+iBest);
                				} else {
                    				System.out.println("Used different station numer, iBest = "+iBest);
                				}
            				} else {
                				System.out.println("Used the same station number, iBest = "+iBest);

            				}


            			}
        			}
//        			double [] result = {
//        					this.gIS[iBest].goniometerTilt,
//        					this.gIS[iBest].goniometerAxial,
//        					this.gIS[iBest].interAxisAngle
//        			};
        			if (iBest!=i){
        			if (iBest!=i){
        				boolean usable_tilt  = (this.gIS[i].motors != null);
        				boolean usable_axial = usable_tilt && (this.gIS[i].getStationNumber() == this.gIS[iBest].getStationNumber());
        				double diff_axial = usable_axial? (this.gIS[i].motors[mAxial]-this.gIS[iBest].motors[mAxial])/
        						goniometerParameters.goniometerMotors.stepsPerDegreeAxial : 0.0;
        				double diff_horizontal = usable_tilt? (this.gIS[i].motors[mHorizontal]-this.gIS[iBest].motors[mHorizontal])/
        						goniometerParameters.goniometerMotors.stepsPerDegreeTilt: 0.0;
        				this.gIS[i].goniometerTilt =  this.gIS[iBest].goniometerTilt + diff_horizontal;
        				this.gIS[i].goniometerAxial = this.gIS[iBest].goniometerAxial + diff_axial;

        				this.gIS[i].goniometerTilt-=360.0*Math.floor((this.gIS[i].goniometerTilt+180.0)/360.0);
        				this.gIS[i].goniometerAxial-=360.0*Math.floor((this.gIS[i].goniometerAxial+180.0)/360.0);

            			if (this.debugLevel>0) System.out.println("Orientation for set # "+i+" timestamp "+IJ.d2s(this.gIS[i].timeStamp,6)+
            			if (this.debugLevel>0) System.out.println("Orientation for set # "+i+" timestamp "+IJ.d2s(this.gIS[i].timeStamp,6)+
            					") is not defined, using # "+iBest+" (timestamp "+IJ.d2s(this.gIS[iBest].timeStamp,6)+")" );
            					") is not defined, estimating from  # "+iBest+" (timestamp "+IJ.d2s(this.gIS[iBest].timeStamp,6)+")" );
            			this.gIS[i].orientationEstimated=true;
            			this.gIS[i].orientationEstimated=true;
    					this.gIS[i].goniometerTilt= this.gIS[iBest].goniometerTilt;
//    					this.gIS[i].goniometerTilt= this.gIS[iBest].goniometerTilt;
    					this.gIS[i].goniometerAxial=this.gIS[iBest].goniometerAxial;
//    					this.gIS[i].goniometerAxial=this.gIS[iBest].goniometerAxial;
    					this.gIS[i].interAxisAngle=this.gIS[iBest].interAxisAngle;
    					this.gIS[i].interAxisAngle=this.gIS[iBest].interAxisAngle;
        			}
        			}
        			double [] result = {
        					this.gIS[i].goniometerTilt,
        					this.gIS[i].goniometerAxial,
        					this.gIS[i].interAxisAngle
        			};

       				return result; // may have Double.NaN
       				return result; // may have Double.NaN
        	}
        	}
        	return null;
        	return null;
@@ -2942,7 +3042,9 @@ import ij.text.TextWindow;
        		EyesisCameraParameters eyesisCameraParameters,
        		EyesisCameraParameters eyesisCameraParameters,
    			EyesisAberrations.AberrationParameters aberrationParameters,
    			EyesisAberrations.AberrationParameters aberrationParameters,
    			LaserPointer laserPointers,
    			LaserPointer laserPointers,
    			Goniometer.GoniometerParameters goniometerParameters,
				ImagePlus[] gridImages  ){ // null - use specified files
				ImagePlus[] gridImages  ){ // null - use specified files
        	this.goniometerParameters = goniometerParameters;
        	setupIndices();
        	setupIndices();
			String [] extensions={".dcal-xml","-distcal.xml"};
			String [] extensions={".dcal-xml","-distcal.xml"};
			MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
			MultipleExtensionsFileFilter parFilter = new MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
+2 −1
Original line number Original line Diff line number Diff line
@@ -3026,6 +3026,7 @@ For each point in the image
			if (imp.getRoi() instanceof PointRoi) {
			if (imp.getRoi() instanceof PointRoi) {
				pointRoi =  (PointRoi) imp.getRoi();
				pointRoi =  (PointRoi) imp.getRoi();
			} else {
			} 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);
				IJ.showMessage("This image does not have point marks - please mark it in "+source_path);
				return null;
				return null;
			}
			}
@@ -3123,7 +3124,7 @@ For each point in the image
				xyuv[i][3]=0.5;
				xyuv[i][3]=0.5;
			}
			}
			GenericDialog gd=new GenericDialog("Specify U,V coordinates of the marker(s)");
			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++) {
			for (int n = 0; n < markers.length; n++) {
				String label = "Marker "+(n+1)+" (x="+markers[n][0]+", y="+markers[n][1];
				String label = "Marker "+(n+1)+" (x="+markers[n][0]+", y="+markers[n][1];
				gd.addNumericField(label+" U", xyuv[n][2], 1, 5, "");
				gd.addNumericField(label+" U", xyuv[n][2], 1, 5, "");
+33 −5
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ package com.elphel.imagej.calibration;
 **
 **
 */
 */
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Arrays;
@@ -49,6 +50,7 @@ import Jama.Matrix; // Download here: http://math.nist.gov/javanumerics/jama/
import ij.IJ;
import ij.IJ;
import ij.ImagePlus;
import ij.ImagePlus;
import ij.ImageStack;
import ij.ImageStack;
import ij.gui.PointRoi;
import ij.gui.Roi;
import ij.gui.Roi;
import ij.process.FHT; // get rid, change to double
import ij.process.FHT; // get rid, change to double
import ij.process.FloatProcessor;
import ij.process.FloatProcessor;
@@ -3133,7 +3135,7 @@ public class MatchSimulatedPattern {
		if (roi==null){
		if (roi==null){
			selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
			selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
		} else {
		} 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 matchSimulatedPattern=new MatchSimulatedPattern(distortionParameters.FFTSize);
		matchSimulatedPattern.debugLevel=debugLevel;
		matchSimulatedPattern.debugLevel=debugLevel;
@@ -3299,7 +3301,7 @@ public class MatchSimulatedPattern {
		if (roi==null){
		if (roi==null){
			selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
			selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
		} else {
		} 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,
		Rectangle initialPatternCell=new Rectangle(xc-fft_size,
				yc-fft_size,
				yc-fft_size,
@@ -3626,7 +3628,7 @@ public class MatchSimulatedPattern {
			if (roi==null){
			if (roi==null){
				selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
				selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
			} else {
			} else {
				selection=roi.getBounds();
				selection= (roi instanceof PointRoi) ? (new Rectangle(0, 0, imp.getWidth(), imp.getHeight())) : roi.getBounds();
			}
			}
		} else {
		} else {
			if ((getImageHeight()!=imp.getHeight()) || (getImageWidth()!=imp.getWidth())){
			if ((getImageHeight()!=imp.getHeight()) || (getImageWidth()!=imp.getWidth())){
@@ -6190,12 +6192,36 @@ public class MatchSimulatedPattern {
		Roi roi= imp.getRoi();
		Roi roi= imp.getRoi();
		Rectangle selection;
		Rectangle selection;
		if (roi==null){
		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());
				setWOI(0, 0, imp.getWidth(), imp.getHeight());
				selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
				selection=new Rectangle(0, 0, imp.getWidth(), imp.getHeight());
			} else {
			} else {
				setWOI(roi.getBounds());
				setWOI(roi.getBounds());
				selection=roi.getBounds();
				selection=roi.getBounds();
			}
			}
		}
		this.debugLevel=global_debug_level;
		this.debugLevel=global_debug_level;
		int patternCells=0;
		int patternCells=0;
		// save initial distortionParameters.correlationMinInitialContrast
		// save initial distortionParameters.correlationMinInitialContrast
@@ -6377,6 +6403,8 @@ public class MatchSimulatedPattern {
		int numPointers=(laserPointer!=null)?laserPointer.laserUVMap.length:0;
		int numPointers=(laserPointer!=null)?laserPointer.laserUVMap.length:0;
		double [][] pointersXY=(numPointers>0)?getPointersXYUV(imp, laserPointer):null;
		double [][] pointersXY=(numPointers>0)?getPointersXYUV(imp, laserPointer):null;
		if (global_debug_level > (debugThreshold+1)){
		if (global_debug_level > (debugThreshold+1)){
			if (pointersXY!=null){
			if (pointersXY!=null){
				System.out.println("calculateDistortions() numPointers="+numPointers+" pointersXY.length="+pointersXY.length);
				System.out.println("calculateDistortions() numPointers="+numPointers+" pointersXY.length="+pointersXY.length);
+5 −2

File changed.

Preview size limit exceeded, changes collapsed.