Commit cde73fef authored by Andrey Filippov's avatar Andrey Filippov
Browse files

implemented 'neck' parameters (rotating/shifting camera as a whole), old bug fixes

parent 782eb01a
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ public class Aberration_Calibration extends PlugInFrame implements ActionListene
	private Panel panelGoniometer;
	private Panel panelPixelMapping, panelStereo,panelStereo1;
	private Panel panelLWIR;
	private Panel panelLWIR16;
//	private Panel panelLWIR16;
	private ShowDoubleFloatArrays SDFA_INSTANCE; // just for debugging?
	JP46_Reader_camera JP4_INSTANCE;
@@ -508,6 +508,9 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
	    	0.0,
	    	0.0,
	    	0.0, 0.0, 2360, //double [] GXYZ // coordinates (in mm) of the goniometer horizontal axis closest to the moving one in target system
	    	0.0,
	    	0.0,
	    	0.0, 0.0,
	       	2592, // int sensorWidth=      2592;
	    	1936, //int sensorHeight=     1936;
	    	2,    //int    shrinkGridForMask=2; //shrink detected grids by one point for/vert this number of times before calculating masks
@@ -696,6 +699,7 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
		addButton("Save Selected",      panelRun);
		addButton("Restore",            panelRun,color_restore);
		addButton("Restore no autoload",panelRun);
		addButton("Properties clear",   panelRun, color_stop);
		addButton("Restore SFE Latest", panelRun, color_restore);
		addButton("List SFE",           panelRun,color_report);
		addButton("Stop",               panelRun,color_stop);
@@ -1257,6 +1261,10 @@ if (MORE_BUTTONS) {
	    } else if (label.equals("Restore") || label.equals("Restore no autoload")) {
	    	restore(label.equals("Restore no autoload"));
	    	return;
/* ======================================================================== */
	    } else if (label.equals("Properties clear")) {
	    	PROPERTIES=new Properties();
	    	return;
/* ======================================================================== */
		} else if (label.equals("Process Calibration Files")) {
			processCalibrationFiles();
@@ -5977,7 +5985,7 @@ if (MORE_BUTTONS) {
				return;
			}
			GenericDialog gd=new GenericDialog ("Select list mode");
    		gd.addNumericField("Mode 0 - pointers, 1 - shift/Rots, 2 - points/extra, 3 - rms", 3, 0);
    		gd.addNumericField("Mode 0 - pointers, 1 - shift/Rots, 2 - points/extra, 3 - rms, 4 - image numbers", 3, 0);
    		gd.showDialog();
    		if (gd.wasCanceled()) return;
    		int listMode=          (int) gd.getNextNumber();
+182 −205

File changed.

Preview size limit exceeded, changes collapsed.

+80 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Arrays;
//import java.util.Arrays;
//import java.io.StringWriter;
import java.util.List;
@@ -3321,10 +3322,12 @@ For each point in the image
		int numSuccess=0;
		DistortionCalibrationData dcd=fittingStrategy.distortionCalibrationData;
		for (int numGridImage=0;numGridImage<dcd.gIP.length;numGridImage++) {
			/*
			if (numGridImage >= 1680)	{
				System.out.println("Processing debug image "+numGridImage);
				System.out.println("Processing debug image "+numGridImage);
			}
			*/
			int set_number = dcd.gIP[numGridImage].getSetNumber();
			if ((set_number >= start_set) &&
					(set_number <= end_set) &&
@@ -10747,17 +10750,31 @@ M * V = B
    		EyesisCameraParameters eyesisCameraParameters
    ){
    	boolean resetParametersToZero=false;
    	boolean updateAllSubcameras = false;
    	boolean [] parameterMask= new boolean[distortionCalibrationData.getNumParameters()];
    	boolean [] channelMask=   new boolean[distortionCalibrationData.getNumSubCameras()];
    	boolean [] stationMask=   new boolean[distortionCalibrationData.getNumStations()];
    	String [] source_stations = new String[stationMask.length+1];
    	source_stations[0] = "---";
    	for (int i = 0; i < stationMask.length; i++) {
    		source_stations[i+1]=""+i;
    	}
    	for (int i=0;i<parameterMask.length;i++) parameterMask[i]=false;
    	for (int i=0;i<channelMask.length;i++)   channelMask[i]=  true;
    	for (int i=0;i<stationMask.length;i++)   stationMask[i]=  true;
    	GenericDialog gd=new GenericDialog("Update (new) image settings from known data");
    	//
    	gd.addCheckbox("Reset selected parameters to zero (false - update from camera parameters)", resetParametersToZero);
    	if (stationMask.length > 1) {
    		gd.addChoice("Copy selected parameters from tis station to all other stations" , source_stations, source_stations[0]);
    	}
    	gd.addMessage("Select which individual image parameters to be updated from the camera parameters (or reset to 0)");
    	for (int i=0;i<parameterMask.length;i++) gd.addCheckbox(i+": "+distortionCalibrationData.getParameterName(i), parameterMask[i]);
    	
    	gd.addCheckbox("Update all subcamera parameters", updateAllSubcameras);
    	
    	for (int i=0;i<parameterMask.length;i++) {
    		gd.addCheckbox(i+": "+distortionCalibrationData.getParameterName(i), parameterMask[i]);
    	}
    	gd.addMessage("----------");
    	gd.addMessage("Select which channels (sub-cameras) to update");
    	for (int i=0;i<channelMask.length;i++) gd.addCheckbox("Subcamera "+i, channelMask[i]);
@@ -10776,6 +10793,12 @@ M * V = B
    	gd.showDialog();
    	if (gd.wasCanceled()) return false;
    	resetParametersToZero=gd.getNextBoolean();
    	int source_station = -1;
    	if (stationMask.length > 1) {
    		source_station = gd.getNextChoiceIndex() - 1;
    	}

    	updateAllSubcameras = gd.getNextBoolean();
    	for (int i=0;i<parameterMask.length;i++) parameterMask[i]= gd.getNextBoolean();
    	for (int i=0;i<channelMask.length;i++)   channelMask[i]=   gd.getNextBoolean();
    	if (stationMask.length>1) {
@@ -10784,6 +10807,25 @@ M * V = B
    	boolean updateFromTimestamps= gd.getNextBoolean();
    	boolean allowClosest=         gd.getNextBoolean();
    	boolean reCenterVertically=   gd.getNextBoolean();

    	if (updateAllSubcameras) {
    		resetParametersToZero = false; // just for safety
        	for (int i=0;i<parameterMask.length;i++) {
        		parameterMask[i] |= distortionCalibrationData.isSubcameraParameter(i);
        	}
    	}
    	
    	if (source_station >= 0) {
    		updateOtherStations(
    	    		eyesisCameraParameters,
    	    		source_station,
    	    		parameterMask,
    	    		channelMask,
    	    		stationMask);    		
    	}
    	
    	
    	
    	if (reCenterVertically){
    		eyesisCameraParameters.recenterVertically(channelMask, stationMask);
    		for (int i=0;i<channelMask.length;i++) channelMask[i]= true;
@@ -10904,6 +10946,38 @@ M * V = B
    }

    
    /**
     * Update selected parameters from sourceStation to selected (stationMask) stations, filtered by channelMask
     * @param eyesisCameraParameters
     * @param sourceStation
     * @param parameterMask
     * @param channelMask
     * @param stationMask
     */
    public void updateOtherStations(
    		EyesisCameraParameters eyesisCameraParameters,
    		int                    sourceStation,
    		boolean []             parameterMask,
    		boolean []             channelMask,
    		boolean []             stationMask
    		) {
    	for (int stationNumber = 0; stationNumber <  stationMask.length; stationNumber++) if (stationMask[stationNumber]) {
    		for (int subCam=0; subCam < channelMask.length; subCam++) if (channelMask[subCam]) {
        		double [] oldVector=eyesisCameraParameters.getParametersVector(stationNumber,subCam);
        		double [] newVector=eyesisCameraParameters.getParametersVector(sourceStation,subCam);
        		for (int j=0;j<oldVector.length;j++) if (parameterMask[j]){
        			oldVector[j]=newVector[j];
        		}
    			eyesisCameraParameters.setParametersVector(
    					newVector,
    					parameterMask,
    					stationNumber,
    					subCam);
    		}
    	}
    }
    

    /**
     * Copies selected parameters from the camera parameters to per-image parameters (i.e. for new/previously disabled images)
     * @param distortionCalibrationData grid distortionCalibrationData
@@ -11078,6 +11152,10 @@ M * V = B
    	int numSeries=allImages?(-1):this.fittingStrategy.currentSeriesNumber;
		boolean [] selectedImages=fittingStrategy.selectedImages(numSeries); // all enabled
		boolean [] selectedImagesDebug=null;
		boolean include_disabled = allImages;
		if (include_disabled) {
			Arrays.fill(selectedImages, true);
		}
		boolean debugThis=false;
		int maxDebugImages=10;
		if (this.debugLevel>0) System.out.println("updateCameraParametersFromCalculated("+allImages+")");
@@ -11108,6 +11186,7 @@ M * V = B
					System.out.println(i+": "+fittingStrategy.distortionCalibrationData.getParameterName(i)+" = "+par[i]);
				}
			}
//			System.out.println(numImg+"[21]: "+fittingStrategy.distortionCalibrationData.getParameterName(21)+" = "+par[21]);
		}
		if (this.debugLevel>1) System.out.println("updateCameraParametersFromCalculated("+allImages+") for series="+numSeries);
		// Next line is not needed anymore (will harm as will set orientationEstimated for all unselected sets)
+63 −38
Original line number Diff line number Diff line
@@ -669,6 +669,9 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    	 */

    	public int  buildParameterMap (int numSeries){
    		return buildParameterMap (numSeries, true);
    	}
       	public int  buildParameterMap (int numSeries, boolean mark_disabled){
    		int numPars=this.distortionCalibrationData.getNumParameters();
    		int numImg=this.distortionCalibrationData.getNumImages();
    		int numTPars=this.parameterMode[numSeries].length;
@@ -681,7 +684,11 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
//    		int [][] tmpMap=new int[numTPars][3]; // temporary array parameterMap[][] (will be truncated)
    		int [][] tmpMap=new int[numPars*numImg][3]; // temporary array parameterMap[][] (will be truncated)
			double masterTS=this.distortionCalibrationData.getImageTimestamp(this.masterImages[numSeries]); // timestamp of the master image
			int [] masterVectorIndices = new int [numTPars];
			int [] masterVectorIndices = new int [numTPars]; //[855] 
			// all but [4][21] are 0,[4][21] is 2 (modeSupercommon),
			// [4][63,105,147,189,231,273,315,357,399,441,483,525,567,609,651,]=10
			// [4][693]= 2 EO(==16)?
			// [4][733,777,819]= 26
// iterate through all global/subcamera parameters
    		for (int numTPar=0;numTPar<numTPars;numTPar++) if (this.parameterMode[numSeries][numTPar]!=modeFixed){ // skip "fixed"
    			boolean isCommon=
@@ -695,7 +702,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    			int numPar=this.parameterList[numTPar][1]; // number of per-image parameter for this total parameter index
    			boolean isSubCamera=this.distortionCalibrationData.isSubcameraParameter(numPar);
    			// is it "same as" ?
    			int sameAs = this.parameterMode[numSeries][numTPar] - this.definedModesAll.length; // number of subcamera to use
    			int sameAs = this.parameterMode[numSeries][numTPar] - this.definedModesAll.length; // number of subcamera to use (this.definedModesAll.length==10)
    			int numTParMaster = -1;
    			int vectorIndexMaster = -1;
    			if (sameAs < 0  ) {
@@ -713,20 +720,26 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    				vectorIndexMaster = masterVectorIndices[numTParMaster]; // use as vectorIndex for slaves
    			}

    			if (this.debugLevel>2) System.out.println("numTPar="+numTPar+" numSub="+numSub+" numPar="+numPar+" numTParMaster="+numTParMaster);
    			if (this.debugLevel > 2) System.out.println("numTPa = "+numTPar+" numSub="+numSub+" numPar="+numPar+" numTParMaster="+numTParMaster);
// iterate through available images
    			for (int numThisImg=0;numThisImg<numImg;numThisImg++) {
    				if ((selectedEnabledImages[numThisImg]) &&
    						(!isSubCamera || (numSub==this.distortionCalibrationData.getImageSubcamera(numThisImg))) &&
//    				if ((selectedEnabledImages[numThisImg]) &&
//    						(!isSubCamera || (numSub==this.distortionCalibrationData.getImageSubcamera(numThisImg))) &&
//    						(this.reverseParameterMap[numThisImg][numPar]<0)){ // image used, this cell is not (yet) defined
    					
        			if((!isSubCamera || (numSub==this.distortionCalibrationData.getImageSubcamera(numThisImg))) &&
        						(this.reverseParameterMap[numThisImg][numPar]<0)){ // image used, this cell is not (yet) defined
    					if (this.debugLevel>2){
    						System.out.println("buildParameterMap("+numSeries+"): numThisImg="+numThisImg+", numPar="+numPar+", vectorIndex="+vectorIndex);
    					}
// is it "same as" ?
// is it "same as" ? // "same as" is only applicable to subcamera parameters
    					if (vectorIndexMaster >= 0){
    						if (mark_disabled || selectedEnabledImages[numThisImg]) {
    							this.reverseParameterMap[numThisImg][numPar] = vectorIndexMaster;
    						}
    						// does not look for same parameter in later images - leave it for the master?
    					} else {
    						if (selectedEnabledImages[numThisImg]) {
// assign it a new parameter
    							this.reverseParameterMap[numThisImg][numPar]=vectorIndex;
    							masterVectorIndices[numTPar] = vectorIndex;
@@ -739,9 +752,14 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    							double minDist=Math.abs(this.distortionCalibrationData.getImageTimestamp(numThisImg)-masterTS);
    							if (this.debugLevel>2) System.out.println("vectorIndex="+vectorIndex+" numThisImg="+numThisImg);
// see if same parameter in some other (later) image(s) is shared
    						for (int numOtherImg=numThisImg + 1; numOtherImg < numImg; numOtherImg++)
    							if ((selectedEnabledImages[numOtherImg]) && // OOB 1
    									(!isSubCamera || (numSub==this.distortionCalibrationData.getImageSubcamera(numOtherImg))) &&
//    							for (int numOtherImg=numThisImg + 1; numOtherImg < numImg; numOtherImg++) {
    							boolean proc_disabled = mark_disabled && (isCommon || isStation || isGroup);
       							for (int numOtherImg=0; numOtherImg < numImg; numOtherImg++) {
       								// 06.03.2021: old way for enabled images - only assign to later images
       								// disabled or unselected images - assign to even earlier ones
   								    if ((selectedEnabledImages[numOtherImg] && (numOtherImg > numThisImg)) || (proc_disabled && !selectedEnabledImages[numOtherImg])) {
//   								    	if ((selectedEnabledImages[numOtherImg]) && // OOB 1
							    		if ((!isSubCamera || (numSub==this.distortionCalibrationData.getImageSubcamera(numOtherImg))) &&
   								    			(this.reverseParameterMap[numOtherImg][numPar]<0)){ // image used, this cell is not (yet) defined
   								    		if ((this.distortionCalibrationData.getImageTimestamp(numOtherImg)==thisTS) ||  // same parameter same timestamp - same group even if is set differently
   								    				(isStation && (this.distortionCalibrationData.gIP[numOtherImg].getStationNumber()==thisStation)) || // new
@@ -757,10 +775,15 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
   								    			}
   								    		}
   								    	}
   								    }
       							}
    							vectorIndex++;
    						}
    					}
    				}
    			}
// second pass    			
    			

    		}
    		// reverseParameterMap built,   vectorIndex equals to the total number of parameters needed for fitting
@@ -1140,7 +1163,9 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    									" nSub="+nSub+" distortionCalibrationData.getImageSubcamera("+numImg+")="+distortionCalibrationData.getImageSubcamera(numImg)+
    									" vector["+vPar+"]="+vector[vPar]);
    						}
    						if ((!isSubCamera) || (nSub==this.distortionCalibrationData.getImageSubcamera(numImg))) {
//    						if ((!isSubCamera) || (nSub==this.distortionCalibrationData.getImageSubcamera(numImg))) {
    						if ((!isSubCamera) || (nSub==this.distortionCalibrationData.getImageSubcamera(numImg)) ||
    								(this.reverseParameterMap[numImg][nPar] == vPar)) { // 06.03.2021
//    							this.distortionCalibrationData.pars[numImg][nPar]=vector[vPar];
    							this.distortionCalibrationData.setParameterValue(numImg,nPar,vector[vPar],true);
    						}
@@ -1170,7 +1195,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
    		return vector;
    	}
    	/**
    	 * Calculates which of all parameters for the particular sensor are to be adjusted (to reduce calcualtions)
    	 * Calculates which of all parameters for the particular sensor are to be adjusted (to reduce calculations)
    	 * @param numImg number of image
    	 * @param vector parameters vector
    	 * @return mask vector to be used with the results of getImageParametersVector()
@@ -2334,7 +2359,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit


						thisChoice = theseChoices[indx];
						System.out.println("selectStrategyStep(): this.parameterMode["+numSeries+"]["+i+"]=" + this.parameterMode[numSeries][i]+" indx = "+indx);
//						System.out.println("selectStrategyStep(): this.parameterMode["+numSeries+"]["+i+"]=" + this.parameterMode[numSeries][i]+" indx = "+indx);
					}
					gd.addChoice( // ArrayIndexOutOfBoundsException: 9
							(this.distortionCalibrationData.isSubcameraParameter(parIndex)?"":"* ") +
+283 −152

File changed.

Preview size limit exceeded, changes collapsed.

Loading