Commit c9ee2c7d authored by Andrey Filippov's avatar Andrey Filippov

working on cartesian-defined multi-cameras

parent 1e8f23fb
......@@ -411,7 +411,8 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
// public static double [] defaultGoniometerPosition={0.0, 0.0, 2360};
public static EyesisCameraParameters EYESIS_CAMERA_PARAMETERS=new EyesisCameraParameters(
1, //int numStations,
true, //false, // boolean isTripod=false; // when true - make goniometerHorizontal rotation around "vertical" axis and "goniometerAxial" - around
true, //false, // boolean isTripod=false; // when true - make goniometerHorizontal rotation around "vertical" axis and "goniometerAxial" - around
false, // boolean cartesian,
0.0, // double goniometerHorizontal, // goniometer rotation around "horizontal" axis (tilting from the target - positive)
0.0, // double goniometerAxial, // goniometer rotation around Eyesis axis (clockwise in plan - positive
1, // 26, // 1, // int numSubCameras,
......@@ -55,7 +55,7 @@ import org.apache.commons.configuration.XMLConfiguration;
// saves / restores them from a disk file
public class DistortionCalibrationData{
public String pathName=null;
public EyesisCameraParameters eyesisCameraParameters;
public EyesisCameraParameters eyesisCameraParameters; // has "cartesian"
// public int numStations=1; // number of differnt camera tripod/goniometer stations (locations)
public int numSubCameras=1;
public int numPointers=4; // maximal number of pointers to look for
......@@ -446,6 +446,20 @@ import org.apache.commons.configuration.XMLConfiguration;
}
}
public int index_right; // = getParameterIndexByName("subcamRight"); // 0
public int index_forward; // = getParameterIndexByName("subcamForward"); // 1
public int index_azimuth; // = getParameterIndexByName("subcamAzimuth"); // 0
public int index_heading; // = getParameterIndexByName("subcamHeading"); // 3
public int index_elevation; // = getParameterIndexByName("subcamElevation"); // 4
public int index_gh; //= getParameterIndexByName("goniometerHorizontal"); // 6
public int index_ga; //= getParameterIndexByName("goniometerAxial"); // 7
public String [][] parameterDescriptionsCartesian ={ // may be shorter, have null rows, shorter rows - will use parameterDescriptions for missing data
{"subcamRight", "Subcamera distance from the vertical rotation axis, positive - right looking to the target","mm","S","E"}, // 0
{"subcamForward", "Subcamera distance from the vertical rotation axis, positive - towards the target","mm","S","E"}, // 1
null, // 2
{"subcamHeading", "Optical axis heading (0 - to the target, positive - CW looking from top)","degrees","S","E"}}; // 3
public String [][] parameterDescriptions ={
{"subcamAzimuth", "Subcamera azimuth, clockwise looking from top","degrees","S","E"}, // 0
{"subcamDistance", "Subcamera distance from the axis","mm","S","E"}, // 1
......@@ -508,14 +522,47 @@ import org.apache.commons.configuration.XMLConfiguration;
{"subcamElong_A8_o", "Orthogonal elongation for r^8","relative","S","I"}, // 51 51 (49)
{"subcamElong_A8_d", "Diagonal elongation for r^8","relative","S","I"} // 52 52 (50)
};
public String [] channelSuffixes={ // natural order (same as array indices, may be modified to camera/subcamera
"00","01","02","03","04","05","06","07","08","09",
"10","11","12","13","14","15","16","17","18","19",
"20","21","22","23","24","25","26","27","28","29"};
public void setupIndices(){ // should be always called during initialization !
this.index_right = getParameterIndexByName("subcamRight"); // 0 may be -1 if !cartesian
this.index_forward = getParameterIndexByName("subcamForward"); // 1 may be -1 if !cartesian
this.index_azimuth = getParameterIndexByName("subcamAzimuth"); // 0
this.index_heading = getParameterIndexByName("subcamAzimuth"); // 3
this.index_elevation = getParameterIndexByName("subcamElevation"); // 4
this.index_gh= getParameterIndexByName("goniometerHorizontal"); // 6
this.index_ga= getParameterIndexByName("goniometerAxial"); // 7
}
public boolean isCartesian(){
return (eyesisCameraParameters !=null) && eyesisCameraParameters.cartesian;
}
public String descrField(int i,int j){
if (
(eyesisCameraParameters !=null) &&
eyesisCameraParameters.cartesian &&
(i < this.parameterDescriptionsCartesian.length) &&
(this.parameterDescriptionsCartesian[i]!=null) &&
(j<this.parameterDescriptionsCartesian[i].length)){
return this.parameterDescriptionsCartesian[i][j];
}
return this.parameterDescriptions[i][j];
}
public boolean isNonRadial(int index){
return parameterDescriptions[index][0].startsWith("subcamEccen_") || parameterDescriptions[index][0].startsWith("subcamElong_");
}
public int getParameterIndexByName(String name){
if (isCartesian()){
for (int i=0;i<this.parameterDescriptionsCartesian.length;i++) if ((this.parameterDescriptionsCartesian[i]!=null) && this.parameterDescriptionsCartesian[i][0].equals(name)){
return i;
}
}
for (int i=0;i<this.parameterDescriptions.length;i++) if (this.parameterDescriptions[i][0].equals(name)){
return i;
}
......@@ -573,6 +620,7 @@ import org.apache.commons.configuration.XMLConfiguration;
PatternParameters patternParameters,
EyesisCameraParameters eyesisCameraParameters
) {
setupIndices();
this.eyesisCameraParameters=eyesisCameraParameters;
int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
this.numSubCameras=numSubCameras;
......@@ -581,9 +629,6 @@ import org.apache.commons.configuration.XMLConfiguration;
for (int i=0;i<stationFilenames.length;i++) numFiles+=stationFilenames[i].length;
this.gIP=new GridImageParameters[numFiles];
// this.paths=new String [filenames.length];
// this.timestamps=new double [filenames.length];
// this.channels= new int [filenames.length];
int numFile=0;
for (int numStation=0;numStation<stationFilenames.length;numStation++){
......@@ -622,7 +667,6 @@ import org.apache.commons.configuration.XMLConfiguration;
}
}
// Create parameters array
// this.pars=new double[this.gIP.length][parameterDescriptions.length];
initPars (this.gIP.length,parameterDescriptions.length);
if (this.debugLevel>1) System.out.println("setupDistortionCalibrationData(): Resetting this.gIS");
this.gIS=null; // so it will be initialized in readAllGrids()
......@@ -630,12 +674,11 @@ import org.apache.commons.configuration.XMLConfiguration;
// no orientation
}
// return (Integer) this.images[sensorNum].getProperty("POINTERS");
public DistortionCalibrationData (
EyesisCameraParameters eyesisCameraParameters
) {
setupIndices();
int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
this.numSubCameras=numSubCameras;
......@@ -648,6 +691,7 @@ import org.apache.commons.configuration.XMLConfiguration;
PatternParameters patternParameters,
EyesisCameraParameters eyesisCameraParameters
) {
setupIndices();
int numSubCameras=(eyesisCameraParameters==null)?1:eyesisCameraParameters.eyesisSubCameras[0].length;
this.numSubCameras=numSubCameras;
this.eyesisCameraParameters=eyesisCameraParameters;
......@@ -745,7 +789,6 @@ import org.apache.commons.configuration.XMLConfiguration;
}
// Create parameters array
// this.pars=new double[images.length][parameterDescriptions.length];
initPars (this.gIP.length,parameterDescriptions.length);
this.gIS=null; // so it will be created in readAllGrids()
readAllGrids(patternParameters); // prepare grid parameters for LMA
......@@ -1141,9 +1184,12 @@ import org.apache.commons.configuration.XMLConfiguration;
}
}
if (bestRating>0){
EyesisSubCameraParameters esp = this.eyesisCameraParameters.eyesisSubCameras[stationNumber][bestChannel];
if (overwriteAll || Double.isNaN(this.gIS[i].goniometerAxial)){
// System.out.println("setInitialOrientation("+overwriteAll+"), Double.isNaN(this.gIS["+i+"].goniometerAxial)="+Double.isNaN(this.gIS[i].goniometerAxial));
this.gIS[i].goniometerAxial=-this.eyesisCameraParameters.eyesisSubCameras[stationNumber][bestChannel].azimuth;
double subcam_heading = (esp.heading + (esp.cartesian? 0: esp.azimuth));
this.gIS[i].goniometerAxial=-subcam_heading;
for (int j=0;j<this.gIS[i].imageSet.length;j++) if (this.gIS[i].imageSet[j]!=null) setGA(this.gIS[i].imageSet[j].imgNumber,this.gIS[i].goniometerAxial);
this.gIS[i].orientationEstimated=true;
if (this.debugLevel>1) {
......@@ -1152,7 +1198,7 @@ import org.apache.commons.configuration.XMLConfiguration;
}
if (overwriteAll || Double.isNaN(this.gIS[i].goniometerTilt )){
// System.out.println("setInitialOrientation("+overwriteAll+"), Double.isNaN(this.gIS["+i+"].goniometerTilt)="+Double.isNaN(this.gIS[i].goniometerTilt));
this.gIS[i].goniometerTilt= -this.eyesisCameraParameters.eyesisSubCameras[stationNumber][bestChannel].theta;
this.gIS[i].goniometerTilt= -esp.theta;
for (int j=0;j<this.gIS[i].imageSet.length;j++) if (this.gIS[i].imageSet[j]!=null) setGH(this.gIS[i].imageSet[j].imgNumber,this.gIS[i].goniometerTilt);
this.gIS[i].orientationEstimated=true;
if (this.debugLevel>1) {
......@@ -1671,6 +1717,7 @@ import org.apache.commons.configuration.XMLConfiguration;
EyesisCameraParameters eyesisCameraParameters,
EyesisAberrations.AberrationParameters aberrationParameters,
ImagePlus[] gridImages ){ // null - use specified files
setupIndices();
String [] extensions={".dcal-xml","-distcal.xml"};
CalibrationFileManagement.MultipleExtensionsFileFilter parFilter = new CalibrationFileManagement.MultipleExtensionsFileFilter("",extensions,"Distortion calibration *.dcal-xml files");
String pathname=CalibrationFileManagement.selectFile(
......@@ -1732,7 +1779,7 @@ import org.apache.commons.configuration.XMLConfiguration;
}
*/
public void setFromXML(String pathname,
EyesisCameraParameters eyesisCameraParameters,
EyesisCameraParameters eyesisCameraParameters, // should have cartesian set
EyesisAberrations.AberrationParameters aberrationParameters) {
this.eyesisCameraParameters=eyesisCameraParameters;
......@@ -1763,9 +1810,13 @@ import org.apache.commons.configuration.XMLConfiguration;
this.gIS[index].stationNumber= Integer.parseInt(sub.getString("stationNumber"));
int minIndex= this.gIS[index].getMinIndex();
int maxIndexPlusOne=this.gIS[index].getMaxIndexPlusOne();
for (int j=minIndex;j<maxIndexPlusOne;j++) if (sub.getString(parameterDescriptions[j][0])!=null) {
this.gIS[index].setParameterValue(j,Double.parseDouble(sub.getString(parameterDescriptions[j][0])), false);
for (int j=minIndex;j<maxIndexPlusOne;j++){
// if (sub.getString(parameterDescriptions[j][0])!=null) {
if (sub.getString(descrField(j,0)) != null) {
this.gIS[index].setParameterValue(j,Double.parseDouble(sub.getString(descrField(j,0))), false);
}
}
if (sub.getString("orientationEstimated")!=null) {
this.gIS[i].orientationEstimated=Boolean.parseBoolean(sub.getString("orientationEstimated"));
/* System.out.println(i+": restored orientationEstimated="+this.gIS[i].orientationEstimated+
......@@ -1802,14 +1853,10 @@ import org.apache.commons.configuration.XMLConfiguration;
// if (aberrationParameters.trustEnabled && this.gIP[i].enabled) this.gIP[i].hintedMatch=2; // trusted
if (aberrationParameters.trustEnabled) this.gIP[i].hintedMatch= this.gIP[i].enabled?2:-1; // trusted and only trusted to enabled
// if (sub.getString("setNumber")!=null) {
// this.gIP[i].setNumber=Integer.parseInt(sub.getString("setNumber"));
// } else {
// this.gIP[i].setNumber=-1;
// }
for (int j=0;j<this.parameterDescriptions.length;j++){
if (sub.getString(parameterDescriptions[j][0])!=null)
this.pars[i][j] = Double.parseDouble(sub.getString(parameterDescriptions[j][0]));
// if (sub.getString(parameterDescriptions[j][0])!=null)
if (sub.getString(descrField(j,0))!=null)
this.pars[i][j] = Double.parseDouble(sub.getString(descrField(j,0)));
else
if (isNonRadial(j)){
this.pars[i][j] = 0.0; // old calibration files without non-radial parameters
......@@ -1861,7 +1908,8 @@ import org.apache.commons.configuration.XMLConfiguration;
this.gIS[is].setParameterValue(pi,parVal,false);
}
if (differs){
System.out.println("ImageSet #"+is+": "+parameterDescriptions[j][0] +" has different values for individual images, skipping");
// System.out.println("ImageSet #"+is+": "+parameterDescriptions[j][0] +" has different values for individual images, skipping");
System.out.println("ImageSet #"+is+": "+descrField(j,0) +" has different values for individual images, skipping");
}
}
}
......@@ -1922,7 +1970,7 @@ import org.apache.commons.configuration.XMLConfiguration;
hConfig.addProperty("file.gridShiftY",UVShiftRot[1]);
hConfig.addProperty("file.gridRotate",UVShiftRot[2]);
for (int j=0;j<this.parameterDescriptions.length;j++){
hConfig.addProperty("file."+parameterDescriptions[j][0],this.pars[i][j]);
hConfig.addProperty("file."+descrField(j,0),this.pars[i][j]);
}
}
// save image sets
......@@ -1934,7 +1982,7 @@ import org.apache.commons.configuration.XMLConfiguration;
hConfig.addProperty("set.orientationEstimated",this.gIS[i].orientationEstimated);
double [] vector = this.gIS[i].updateParameterVectorFromSet(null); // unused parameters will be NaN
for (int j=0;j<vector.length;j++) if (!Double.isNaN(vector[j])){
hConfig.addProperty("set."+parameterDescriptions[j][0],vector[j]);
hConfig.addProperty("set."+descrField(j,0),vector[j]);
}
}
......@@ -2149,7 +2197,7 @@ import org.apache.commons.configuration.XMLConfiguration;
this.debugLevel+(thisDebug?3:0),
thisDebug?("fixBad-"+fileNumber):null
);
if (this.debugLevel>1) {
if (this.debugLevel>-1) {
if (numBadNodes>0)
System.out.print(" -- replaced "+numBadNodes+" bad grid nodes");
int [] uvrot=this.gIP[fileNumber].getUVShiftRot();
......@@ -2671,14 +2719,20 @@ import org.apache.commons.configuration.XMLConfiguration;
return this.gIP[numImg];
}
public double [] getAzEl(int imgNum){ // get sensor azimuth and elevation DANGEROUS - absolute indices of parameters
// next is just for goniometer - use elevation and heading for cartesian mode?
public double [] getHeadEl(int imgNum){ // get sensor heading +(azimuth) and elevation
if ((imgNum<0) || (imgNum>=this.pars.length)) {
String msg="There are only "+this.pars.length+" images defined, requested #"+imgNum;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
double [] azel={this.pars[imgNum][0],this.pars[imgNum][4]};
return azel;
double [] headel={this.pars[imgNum][index_heading],this.pars[imgNum][index_elevation]};
if (!isCartesian()) {
headel[0] += this.pars[imgNum][index_azimuth];
}
System.out.println("getHeadEl("+imgNum+") "+isCartesian()+" -> "+headel[0]+"/"+ headel[1]+", "+this.pars[imgNum][index_azimuth]+","+
this.pars[imgNum][index_heading]+", "+this.pars[imgNum][index_elevation]);
return headel;
}
// set goniometer horizontal axis angle and goniometer axial angles in all images
public void setGHGA(double gh, double ga){
......@@ -2689,21 +2743,21 @@ import org.apache.commons.configuration.XMLConfiguration;
setGA(imgNum, ga);
}
public void setGH(int numImg, double gh){
this.pars[numImg][6]=gh;
this.pars[numImg][index_gh]=gh;
if (this.gIP[numImg].gridImageSet!=null) this.gIP[numImg].gridImageSet.goniometerTilt= gh;
}
public void setGA(int numImg, double ga){
this.pars[numImg][7]=ga;
this.pars[numImg][index_ga]=ga;
if (this.gIP[numImg].gridImageSet!=null) this.gIP[numImg].gridImageSet.goniometerAxial= ga;
}
public double getGH(int numImg){
if (this.gIP[numImg].gridImageSet!=null) return this.gIP[numImg].gridImageSet.goniometerTilt;
return this.pars[numImg][6];
return this.pars[numImg][index_gh];
}
public double getGA(int numImg){
if (this.gIP[numImg].gridImageSet!=null) return this.gIP[numImg].gridImageSet.goniometerAxial;
return this.pars[numImg][7];
return this.pars[numImg][index_ga];
}
public void setParameters(double [] parameters, int numImg, boolean[] mask){
......@@ -2765,7 +2819,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return parameterDescriptions[num][0];
return descrField(num,0);
}
public String getParameterDescription(int num){
......@@ -2774,7 +2828,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return this.parameterDescriptions[num][1];
return descrField(num,1);
}
public String getParameterUnits(int num){
......@@ -2783,8 +2837,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return this.parameterDescriptions[num][2];
return descrField(num,2);
}
public boolean isSubcameraParameter(int num){
if ((num<0) || (num>=this.parameterDescriptions.length)) {
......@@ -2792,7 +2845,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return (this.parameterDescriptions[num][3].equals("S"));
return (descrField(num,3).equals("S"));
}
public boolean isLocationParameter(int num){ //X,Y or Z location of the camera
......@@ -2801,7 +2854,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return (this.parameterDescriptions[num][3].equals("T"));
return (descrField(num,3).equals("T"));
}
public boolean isOrientationParameter(int num){ //one of the 2 goniometer orientation angles
......@@ -2810,7 +2863,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return (this.parameterDescriptions[num][3].equals("R"));
return (descrField(num,3).equals("R"));
}
public boolean isIntrinsicParameter(int num){ // updated from image calibration file
......@@ -2819,7 +2872,7 @@ import org.apache.commons.configuration.XMLConfiguration;
IJ.showMessage("Error",msg);
throw new IllegalArgumentException (msg);
}
return (this.parameterDescriptions[num][4].equals("I"));
return (descrField(num,4).equals("I"));
}
public String getImagePath(int num) {
......
......@@ -2975,8 +2975,10 @@ For each point in the image
// double [] parVector=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getParametersVector(stationNumber,subCamera);
// System.out.println("setupLensDistortionParameters(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial);
boolean isTripod=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod;
boolean cartesian=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian;
LensDistortionParameters lensDistortionParameters = new LensDistortionParameters (
isTripod,
cartesian,
null, //double [][] interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
// this.fittingStrategy.distortionCalibrationData.pars[numImg], //parVector,
this.fittingStrategy.distortionCalibrationData.getParameters(numImg), //parVector,
......@@ -3001,8 +3003,10 @@ For each point in the image
if (!Double.isNaN(goniometerAxial))parVector[goniometerAxialIndex]=goniometerAxial;
// System.out.println("setupLensDistortionParameters(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial);
boolean isTripod=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod;
boolean cartesian=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian;
LensDistortionParameters lensDistortionParameters = new LensDistortionParameters (
isTripod,
cartesian,
null, //double [][] interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
parVector,
null, //boolean [] mask, // calculate only selected derivatives (all parVect values are still
......@@ -3152,6 +3156,7 @@ For each point in the image
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters, // 22-long parameter vector for the image
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
null, // this.interParameterDerivatives, // [22][]
parVector,
null); // if no derivatives, null is OK
......@@ -3276,6 +3281,7 @@ For each point in the image
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
this.interParameterDerivatives, // [22][]
imgVector,
imgMask); // calculate only selected derivatives (all parVect values are still
......@@ -3299,6 +3305,7 @@ For each point in the image
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
null, // this.interParameterDerivatives, // just values, no derivatives
vector_delta,
imgMask);
......@@ -3386,6 +3393,7 @@ For each point in the image
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
calcJacobian?this.interParameterDerivatives:null, // [22][]
imgVector,
imgMask); // imgMask may be null if no derivativescalculate only selected derivatives (all parVect values are still
......@@ -3399,7 +3407,7 @@ For each point in the image
if (fullIndex>=this.targetXYZ.length){
System.out.println("BUG: calculateFxAndJacobian() imgNum="+imgNum+" pointNum="+pointNum+" fullIndex="+fullIndex+" this.targetXYZ.length="+this.targetXYZ.length);
}
double [][]derivatives15= lensDistortionParameters.calcPartialDerivatives(
double [][]derivatives15= lensDistortionParameters.calcPartialDerivatives( // [NaN, NaN]
this.targetXYZ[fullIndex][0], // target point horizontal, positive - right, mm
this.targetXYZ[fullIndex][1], // target point vertical, positive - down, mm
this.targetXYZ[fullIndex][2], // target point horizontal, positive - away from camera, mm
......@@ -3503,6 +3511,7 @@ For each point in the image
lensDistortionParameters.lensCalcInterParamers(
lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
calcJacobian?interParameterDerivatives:null, // [22][]
imgVector,
imgMask); // calculate only selected derivatives (all parVect values are still
......@@ -3586,6 +3595,7 @@ For each point in the image
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
null, //this.interParameterDerivatives, // [22][]
imgVector,
imgMask); // calculate only selected derivatives (all parVect values are still
......@@ -3681,7 +3691,7 @@ List calibration
gd.addCheckbox("Show physical camera parameters", this.showEyesisParameters);
gd.addCheckbox("Show intrinsic lens/sensor parameters ", this.showIntrinsicParameters);
gd.addCheckbox("Show intrinsic lens/sensor parameters", this.showExtrinsicParameters);
gd.addCheckbox("Show extrinsic lens/sensor parameters", this.showExtrinsicParameters);
gd.addNumericField("Extra decimal places (precision) in the list", this.extraDecimals, 0);
gd.showDialog();
if (gd.wasCanceled()) return false;
......@@ -4132,6 +4142,7 @@ List calibration
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
null, //this.interParameterDerivatives, // [22][]
// fittingStrategy.distortionCalibrationData.pars[imgNum], // 22-long parameter vector for the image
fittingStrategy.distortionCalibrationData.getParameters(imgNum), // 22-long parameter vector for the image
......@@ -7628,6 +7639,7 @@ D2=
final boolean updateStatus
){
final boolean isTripod=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod;
final boolean cartesian=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian;
final int [][] dirs= {{0,0},{-1,0},{1,0},{0,-1},{0,1}}; // possible to make 8 directions
final double [][][] derivatives={ // for of /du, /dv 3 variants, depending on which neighbors are available
{
......@@ -7680,6 +7692,7 @@ D2=
lensDistortionParameters.lensCalcInterParamers(
lensDistortionParameters,
isTripod,
cartesian,
null, //this.interParameterDerivatives, // [22][]
// fittingStrategy.distortionCalibrationData.pars[imgNum], // 22-long parameter vector for the image
fittingStrategy.distortionCalibrationData.getParameters(imgNum), // 22-long parameter vector for the image
......@@ -7876,6 +7889,7 @@ D2=
this.lensDistortionParameters.lensCalcInterParamers(
this.lensDistortionParameters,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod,
this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.cartesian,
null, //this.interParameterDerivatives, // [22][]
// fittingStrategy.distortionCalibrationData.pars[imgNum], // 22-long parameter vector for the image
fittingStrategy.distortionCalibrationData.getParameters(imgNum), // 22-long parameter vector for the image
......
......@@ -52,7 +52,8 @@ import org.apache.commons.configuration.XMLConfiguration;
// non-adjustable parameters, not parts of vector
public int numStations;
public double [] stationWeight; // reprojection error weights (close station - relax errors)
public boolean isTripod=false; // when true - make goniometerHorizontal rotation around "vertical" axis and "goniometerAxial" - around
public boolean isTripod= false; // when true - make goniometerHorizontal rotation around "vertical" axis and "goniometerAxial" - around
public boolean cartesian=false; //
// rotated horizontal.
public int sensorWidth= 2592;
public int sensorHeight= 1936;
......@@ -293,6 +294,7 @@ import org.apache.commons.configuration.XMLConfiguration;
public EyesisCameraParameters (
int numStations,
boolean isTripod,
boolean cartesian,
double goniometerHorizontal, // goniometer rotation around "horizontal" axis (tilting from the target - positive)
double goniometerAxial, // goniometer rotation around Eyesis axis (clockwise in plan - positive
int numSubCameras,
......@@ -329,6 +331,7 @@ import org.apache.commons.configuration.XMLConfiguration;
setSameEyesisCameraParameters (
numStations,
isTripod,
cartesian,
goniometerHorizontal, // goniometer rotation around "horizontal" axis (tilting from the target - positive)
goniometerAxial, // goniometer rotation around Eyesis axis (clockwise in plan - positive
numSubCameras,
......@@ -363,6 +366,7 @@ import org.apache.commons.configuration.XMLConfiguration;
public EyesisCameraParameters (
int numStations,
boolean isTripod,
boolean cartesiam,
double goniometerHorizontal, // goniometer rotation around "horizontal" axis (tilting from the target - positive)
double goniometerAxial, // goniometer rotation around Eyesis axis (clockwise in plan - positive
int numSubCameras,
......@@ -396,6 +400,7 @@ import org.apache.commons.configuration.XMLConfiguration;
setSameEyesisCameraParameters (
numStations,
isTripod,
cartesian,
goniometerHorizontal, // goniometer rotation around "horizontal" axis (tilting from the target - positive)
goniometerAxial, // goniometer rotation around Eyesis axis (clockwise in plan - positive
numSubCameras,
......@@ -430,6 +435,7 @@ import org.apache.commons.configuration.XMLConfiguration;
void setSameEyesisCameraParameters (
int numStations,
boolean isTripod,
boolean cartesian,
double goniometerHorizontal, // goniometer rotation around "horizontal" axis (tilting from the target - positive)
double goniometerAxial, // goniometer rotation around Eyesis axis (clockwise in plan - positive
int numSubCameras,
......@@ -462,6 +468,7 @@ import org.apache.commons.configuration.XMLConfiguration;
){
this.numStations=numStations;
this.isTripod=isTripod;
this.cartesian = cartesian; // Need to set each subcamera?
this.sensorWidth=sensorWidth;
this.sensorHeight=sensorHeight;
this.shrinkGridForMask=shrinkGridForMask; //shrink detected grids by one point for/vert this number of times before calculating masks
......@@ -513,7 +520,7 @@ import org.apache.commons.configuration.XMLConfiguration;
/**
* Capoy parameters from source EysesisCamerParameters to destination, trimming/expanding nu,ber of stations
* Copy parameters from source EysesisCamerParameters to destination, trimming/expanding number of stations
* @param newNumStations new number of stations
* @param source source EysesisCamerParameters
* @param destination destination EysesisCamerParameters
......@@ -573,10 +580,12 @@ import org.apache.commons.configuration.XMLConfiguration;
}
}
}
destination.cartesian = source.cartesian;
}
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"isTripod",this.isTripod+"");
properties.setProperty(prefix+"cartesian",this.cartesian+"");
properties.setProperty(prefix+"sensorWidth",this.sensorWidth+"");
properties.setProperty(prefix+"sensorHeight",this.sensorHeight+"");
properties.setProperty(prefix+"shrinkGridForMask",this.shrinkGridForMask+"");
......@@ -619,6 +628,8 @@ import org.apache.commons.configuration.XMLConfiguration;
public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"isTripod")!=null)
this.isTripod=Boolean.parseBoolean(properties.getProperty(prefix+"isTripod"));
if (properties.getProperty(prefix+"cartesian")!=null)
this.cartesian=Boolean.parseBoolean(properties.getProperty(prefix+"cartesian"));
if (properties.getProperty(prefix+"sensorWidth")!=null)
this.sensorWidth=Integer.parseInt(properties.getProperty(prefix+"sensorWidth"));
if (properties.getProperty(prefix+"sensorHeight")!=null)
......@@ -757,6 +768,7 @@ import org.apache.commons.configuration.XMLConfiguration;
// public double goniometerHorizontal; // goniometer rotation around "horizontal" axis (tilting from the target - positive)
// public double goniometerAxial; // goniometer rotation around Eyesis axis (clockwise in plan - positive
//this.isTripod
gd.addCheckbox("Cartesian coordinates for subcamera (false - cylindrical)", this.cartesian);
String [] modelChoice=new String [distortionModelDescriptions.length+1];
modelChoice[0]="--- keep current ---";
for (int i=0;i<distortionModelDescriptions.length;i++) modelChoice[i+1]=distortionModelDescriptions[i];
......@@ -820,6 +832,7 @@ import org.apache.commons.configuration.XMLConfiguration;
WindowTools.addScrollBars(gd);
gd.showDialog();
if (gd.wasCanceled()) return -1;
boolean newCartesian = gd.getNextBoolean();
int modelIndex=gd.getNextChoiceIndex()-1;
if (modelIndex>=0){
for (EyesisSubCameraParameters [] esps:this.eyesisSubCameras){
......@@ -874,6 +887,11 @@ import org.apache.commons.configuration.XMLConfiguration;
}
}
if (numSubCam<0)numSubCam=0;
if (newCartesian != this.cartesian){
this.cartesian = newCartesian;
updateCartesian();
}
return gd.wasOKed()?numSubCam:-1;
}
......@@ -881,6 +899,7 @@ import org.apache.commons.configuration.XMLConfiguration;
int numSubCam,
String title) {
GenericDialog gd = new GenericDialog(title);
if (this.numStations > 1) gd.addCheckbox ("Propagate first station parameters to other stations ",false);
for (int numStation=0;numStation<this.numStations;numStation++) {
EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam];
if (subCam!=null) {
......@@ -891,10 +910,20 @@ import org.apache.commons.configuration.XMLConfiguration;
if (this.numStations>1) gd.addMessage("--- Station number "+numStation+" ---");
gd.addNumericField("Subcamera lens distortion model", subCam.lensDistortionModel, 5,0,"");
gd.addCheckbox ("Enable matching w/o laser pointers", subCam.enableNoLaser);
gd.addNumericField("Subcamera azimuth", subCam.azimuth, 5,9,"degrees");
gd.addNumericField("Subcamera distance from the axis", subCam.radius, 5,9,"mm");
if (subCam.cartesian) {
gd.addNumericField("Subcamera right from the axis", subCam.right, 5,9,"mm");
gd.addNumericField("Subcamera forward from the rotation axis", subCam.forward, 5,9,"mm");
} else {
gd.addNumericField("Subcamera azimuth", subCam.azimuth, 5,9,"degrees");
gd.addNumericField("Subcamera distance from the axis", subCam.radius, 5,9,"mm");
}
gd.addNumericField("Subcamera height from the 'equator'", subCam.height, 5,9,"mm");
gd.addNumericField("Optical axis heading (relative to azimuth)", subCam.phi, 5,9,"degrees");
if (subCam.cartesian) {
gd.addNumericField("Optical axis heading (absulute, CW positive)", subCam.heading, 5,9,"degrees");
} else {
gd.addNumericField("Optical axis heading (relative to azimuth)", subCam.phi, 5,9,"degrees");
}
gd.addNumericField("Optical axis elevation (up from equator)", subCam.theta, 5,9,"degrees");
gd.addNumericField("Camera roll, positive CW looking to the target",subCam.psi, 5,9,"degrees");
gd.addNumericField("Lens focal length", subCam.focalLength, 5,8,"mm");
......@@ -952,6 +981,7 @@ import org.apache.commons.configuration.XMLConfiguration;
gd.showDialog();
if (gd.wasCanceled()) return false;
double channelWeightDefault=1.0;
boolean propagateFirstStation = (this.numStations > 1) ? gd.getNextBoolean() : false;
for (int numStation=0;numStation<this.numStations;numStation++) {
EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam];
if (subCam!=null) {
......@@ -962,10 +992,19 @@ import org.apache.commons.configuration.XMLConfiguration;
subCam.channelWeightDefault= channelWeightDefault; // assign to all stations
subCam.lensDistortionModel= (int) gd.getNextNumber();
subCam.enableNoLaser = gd.getNextBoolean();
subCam.azimuth= gd.getNextNumber();
subCam.radius= gd.getNextNumber();
if (subCam.cartesian) {
subCam.right= gd.getNextNumber();
subCam.forward= gd.getNextNumber();
} else {
subCam.azimuth= gd.getNextNumber();
subCam.radius= gd.getNextNumber();
}
subCam.height= gd.getNextNumber();
subCam.phi= gd.getNextNumber();
if (subCam.cartesian) {
subCam.heading= gd.getNextNumber();
}else {
subCam.phi= gd.getNextNumber();
}
subCam.theta= gd.getNextNumber();
subCam.psi= gd.getNextNumber();
subCam.focalLength= gd.getNextNumber();
......@@ -1009,6 +1048,76 @@ import org.apache.commons.configuration.XMLConfiguration;
subCam.r_od[6][1]= 0.01*gd.getNextNumber();
}
}
if (propagateFirstStation){
EyesisSubCameraParameters first=this.eyesisSubCameras[0][numSubCam];
if (first != null){
for (int numStation=1;numStation<this.numStations;numStation++) {
EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam];
if (subCam!=null) {
if (subCam.cartesian) {
subCam.right= first.right;
subCam.forward= first.forward;
} else {
subCam.azimuth= first.azimuth;
subCam.radius= first.radius;
}
subCam.height= first.height;
if (subCam.cartesian) {
subCam.heading= first.heading;
}else {
subCam.phi= first.phi;
}
subCam.theta= first.theta;
subCam.psi= first.psi;
subCam.focalLength= first.focalLength;
subCam.pixelSize= first.pixelSize;
subCam.distortionRadius=first.distortionRadius;
subCam.distortionA8= first.distortionA8;
subCam.distortionA7= first.distortionA7;
subCam.distortionA6= first.distortionA6;
subCam.distortionA5= first.distortionA5;
subCam.distortionA= first.distortionA;
subCam.distortionB= first.distortionB;
subCam.distortionC= first.distortionC;
subCam.px0= first.px0;
subCam.py0= first.py0;
subCam.r_od[0][0]= subCam.r_od[0][0];
subCam.r_od[0][1]= subCam.r_od[0][1];
subCam.r_xy[0][0]= subCam.r_xy[0][0];
subCam.r_xy[0][1]= subCam.r_xy[0][1];
subCam.r_od[1][0]= subCam.r_od[1][0];
subCam.r_od[1][1]= subCam.r_od[1][1];
subCam.r_xy[1][0]= subCam.r_xy[1][0];
subCam.r_xy[1][1]= subCam.r_xy[1][1];
subCam.r_od[2][0]= subCam.r_od[2][0];
subCam.r_od[2][1]= subCam.r_od[2][1];
subCam.r_xy[2][0]= subCam.r_xy[2][0];
subCam.r_xy[2][1]= subCam.r_xy[2][1];
subCam.r_od[3][0]= subCam.r_od[3][0];
subCam.r_od[3][1]= subCam.r_od[3][1];
subCam.r_xy[3][0]= subCam.r_xy[3][0];
subCam.r_xy[3][1]= subCam.r_xy[3][1];
subCam.r_od[4][0]= subCam.r_od[4][0];
subCam.r_od[4][1]= subCam.r_od[4][1];
subCam.r_xy[4][0]= subCam.r_xy[4][0];
subCam.r_xy[4][1]= subCam.r_xy[4][1];
subCam.r_od[5][0]= subCam.r_od[5][0];
subCam.r_od[5][1]= subCam.r_od[5][1];
subCam.r_xy[5][0]= subCam.r_xy[5][0];
subCam.r_xy[5][1]= subCam.r_xy[5][1];
subCam.r_od[6][0]= subCam.r_od[6][0];
subCam.r_od[6][1]= subCam.r_od[6][1];
}
}
}
}
for (int numStation=0;numStation<this.numStations;numStation++) {
EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam];
if (subCam!=null) {
subCam.updateCartesian();
}
}
return gd.wasOKed();
}
......@@ -1071,12 +1180,12 @@ import org.apache.commons.configuration.XMLConfiguration;
EyesisSubCameraParameters subCam=this.eyesisSubCameras[stationNumber][subCamNumber];
// System.out.println("getParametersVector("+stationNumber+","+subCamNumber+"), subCam is "+((subCam==null)?"null":"NOT null"));
double [] parVect={
subCam.azimuth, // 0 azimuth of the lens entrance pupil center, degrees, clockwise looking from top
subCam.radius, // 1 mm, distance from the rotation axis
subCam.height, // 2 mm, up (was downwards?) - from the origin point
subCam.phi, // 3 degrees, optical axis from azimuth/r vector, clockwise
subCam.theta, // 4 degrees, optical axis from the eyesis horizon, positive - up
subCam.psi, // 5 degrees, rotation (of the sensor) around the optical axis. Positive if camera is rotated clockwise looking to the target
(subCam.cartesian?subCam.right: subCam.azimuth), // 0 azimuth of the lens entrance pupil center, degrees, clockwise looking from top
(subCam.cartesian?subCam.forward:subCam.radius), // 1 mm, distance from the rotation axis
subCam.height, // 2 mm, up (was downwards?) - from the origin point
(subCam.cartesian?subCam.heading:subCam.phi), // 3 degrees, optical axis from azimuth/r vector, clockwise
subCam.theta, // 4 degrees, optical axis from the eyesis horizon, positive - up
subCam.psi, // 5 degrees, rotation (of the sensor) around the optical axis. Positive if camera is rotated clockwise looking to the target
this.goniometerHorizontal[stationNumber], // 6 goniometer rotation around "horizontal" axis (tilting from the target - positive)
this.goniometerAxial[stationNumber], // 7 goniometer rotation around Eyesis axis (clockwise in plan - positive
this.interAxisDistance[stationNumber], // 8 distance in mm between two goniometer axes
......@@ -1181,10 +1290,19 @@ import org.apache.commons.configuration.XMLConfiguration;
(this.eyesisSubCameras[stationNumber].length<=subCamNumber)) throw new IllegalArgumentException
("Nonexistent subcamera "+subCamNumber+ " and/or station number="+stationNumber);
EyesisSubCameraParameters subCam=this.eyesisSubCameras[stationNumber][subCamNumber];
if (update[0]) subCam.azimuth=parVect[0]; // 0 azimuth of the lens entrance pupil center, degrees, clockwise looking from top
if (update[1]) subCam.radius=parVect[1]; // 1 mm, distance from the rotation axis
if (update[2]) subCam.height=parVect[2]; // 2 mm, up (was downwards?) - from the origin point
if (update[2]) subCam.phi=parVect[3]; // 3 degrees, optical axis from azimuth/r vector, clockwise
if (subCam.cartesian){
if (update[0]) subCam.right=parVect[0]; // 0 mm, right of the camera axis from goniometer vertical rotation center to the target
if (update[1]) subCam.forward=parVect[1]; // 1 mm, forward from the goniometer vertical rotation center
} else {
if (update[0]) subCam.azimuth=parVect[0]; // 0 azimuth of the lens entrance pupil center, degrees, clockwise looking from top
if (update[1]) subCam.radius=parVect[1]; // 1 mm, distance from the rotation axis
}
if (update[2]) subCam.height=parVect[2]; // 2 mm, up (was downwards?) - from the origin point
if (subCam.cartesian){
if (update[2]) subCam.heading=parVect[3]; // 3 degrees, optical axis from Z (to target), clockwise
} else {
if (update[2]) subCam.phi=parVect[3]; // 3 degrees, optical axis from azimuth/r vector, clockwise
}
if (update[4]) subCam.theta=parVect[4]; // 4 degrees, optical axis from the eyesis horizon, positive - up
if (update[5]) subCam.psi=parVect[5]; // 5 degrees, rotation (of the sensor) around the optical axis. Positive if camera is rotated clockwise looking to the target
if (update[6]) this.goniometerHorizontal[stationNumber]=parVect[6]; // 6 goniometer rotation around "horizontal" axis (tilting from the target - positive)
......@@ -1236,6 +1354,14 @@ import org.apache.commons.configuration.XMLConfiguration;
if (update[52]) subCam.r_od[6][1]= parVect[52];
}
public void updateCartesian(){
for (int numStation = 0; numStation < this.eyesisSubCameras.length; numStation++){
for (int numSub = 0; numSub < this.eyesisSubCameras[numStation].length; numSub++){
this.eyesisSubCameras[numStation][numSub].setCartesian(this.cartesian);
}
}
}
public void initSubCameras(
int numStation,
int numSubCameras){
......@@ -1243,9 +1369,12 @@ import org.apache.commons.configuration.XMLConfiguration;
this.eyesisSubCameras[numStation]=new EyesisSubCameraParameters[numSubCameras];
for (int i=0;i<numSubCameras;i++) this.eyesisSubCameras[numStation][i]=null;
if (numSubCameras==3) {
this.cartesian = false; // change?
this.eyesisSubCameras[numStation][0]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
0.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
52.53, // double radius, // mm, distance from the rotation axis
34.64, // double height, // mm, up (was downwards) - from the origin point
......@@ -1268,8 +1397,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][1]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
30.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
60.0, // double radius, // mm, distance from the rotation axis
-17.32, // double height, // mm, up (was downwards) - from the origin point
......@@ -1292,8 +1423,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][2]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-30.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
60.0, // double radius, // mm, distance from the rotation axis
-17.32, // double height, // mm, up (was downwards) - from the origin point
......@@ -1316,9 +1449,12 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
} else if (numSubCameras==1) {
this.cartesian = false;
this.eyesisSubCameras[numStation][0]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
0.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
0.0, // double radius, // mm, distance from the rotation axis
0.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1344,9 +1480,12 @@ import org.apache.commons.configuration.XMLConfiguration;
// ================
// PHG21 parameters
//
this.cartesian = false; // change
this.eyesisSubCameras[numStation][0]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
0.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
46.57, // double radius, // mm, distance from the rotation axis
0.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1369,8 +1508,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][1]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
21.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
50.36, // double radius, // mm, distance from the rotation axis
-15.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1393,8 +1534,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][2]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-21.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
50.36, // double radius, // mm, distance from the rotation axis
-15.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1417,8 +1560,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][3]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
0.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
46.57, // double radius, // mm, distance from the rotation axis
70.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1441,8 +1586,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][4]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
21.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
50.36, // double radius, // mm, distance from the rotation axis
55.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1465,8 +1612,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][5]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-21.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
50.36, // double radius, // mm, distance from the rotation axis
55.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1489,8 +1638,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][6]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
52.47, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
76.45, // double radius, // mm, distance from the rotation axis
35.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1513,8 +1664,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][7]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
59.13, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
91.65, // double radius, // mm, distance from the rotation axis
20.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1537,8 +1690,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][8]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
42.16, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
63.43, // double radius, // mm, distance from the rotation axis
20.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1561,8 +1716,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][9]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
52.47, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
76.45, // double radius, // mm, distance from the rotation axis
-35.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1585,8 +1742,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][10]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
59.13, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
91.65, // double radius, // mm, distance from the rotation axis
-50.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1609,8 +1768,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][11]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
42.16, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
63.43, // double radius, // mm, distance from the rotation axis
-50.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1633,8 +1794,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][12]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
0.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
46.57, // double radius, // mm, distance from the rotation axis
-70.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1657,8 +1820,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][13]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
21.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
50.36, // double radius, // mm, distance from the rotation axis
-85.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1681,8 +1846,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][14]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-21.0, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
50.36, // double radius, // mm, distance from the rotation axis
-85.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1705,8 +1872,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][15]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-52.47, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
76.45, // double radius, // mm, distance from the rotation axis
-35.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1729,8 +1898,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][16]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-42.16, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
63.43, // double radius, // mm, distance from the rotation axis
-50.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1753,8 +1924,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][17]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-59.13, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
91.65, // double radius, // mm, distance from the rotation axis
-50.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1777,8 +1950,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][18]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-52.47, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
76.45, // double radius, // mm, distance from the rotation axis
35.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1801,8 +1976,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][19]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-42.16, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
63.43, // double radius, // mm, distance from the rotation axis
20.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1825,8 +2002,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
this.eyesisSubCameras[numStation][20]=new EyesisSubCameraParameters( //TODO: modify for lens adjustment defaults?
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
-59.13, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
91.65, // double radius, // mm, distance from the rotation axis
20.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1854,8 +2033,10 @@ import org.apache.commons.configuration.XMLConfiguration;
} else {
// default setup for the 26 sub-cameras
for (int i=0;i<8;i++) if (i<numSubCameras) this.eyesisSubCameras[numStation][i]=new EyesisSubCameraParameters( // top 8 cameras
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
45.0*i, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
41.540, // double radius, // mm, distance from the rotation axis
42.883, // double height, // mm, up (was downwards?) - from the origin point
......@@ -1878,8 +2059,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
for (int i=8;i<16;i++) if (i<numSubCameras) this.eyesisSubCameras[numStation][i]=new EyesisSubCameraParameters( // middle 8 cameras
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
45.0*(i-8), // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
54.525, // double radius, // mm, distance from the rotation axis
0.0, // double height, // mm, up (was downwards) - from the origin point
......@@ -1902,8 +2085,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
for (int i=16;i<24;i++) if (i<numSubCameras) this.eyesisSubCameras[numStation][i]=new EyesisSubCameraParameters( // bottom eight cameras
this.cartesian,
defaultLensDistortionModel,
true,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
45.0*(i-16), // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
41.540, // double radius, // mm, distance from the rotation axis
-42.883, // double height, // mm, up (was downwards?) - from the origin point
......@@ -1926,8 +2111,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
1.0); //channelWeightDefault
if (24<numSubCameras) this.eyesisSubCameras[numStation][24]=new EyesisSubCameraParameters(
this.cartesian,
defaultLensDistortionModel,
false,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
90, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
12.025, // double radius, // mm, distance from the rotation axis
-807.0, // double height, // mm, up - from the origin point
......@@ -1950,8 +2137,10 @@ import org.apache.commons.configuration.XMLConfiguration;
null, // elongation for c,b,a,a5,a6,a7,a8
8.0); //channelWeightDefault (was 4)
if (25<numSubCameras) this.eyesisSubCameras[numStation][25]=new EyesisSubCameraParameters(
this.cartesian,
defaultLensDistortionModel,
false,
0.0, 0.0, 0.0, // cartesian righ/forward/heading
270, // double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
12.025, // double radius, // mm, distance from the rotation axis
-841.0, // double height, // mm, up - from the origin point
......
......@@ -25,12 +25,17 @@ import java.util.Properties;
public class EyesisSubCameraParameters{
// origin is on the rotation axis of the tube body closest to the goniometer horizontal axis
public boolean cartesian = false; // cartesian coordinates mode (false - cylindrical)
public int lensDistortionModel=0;
public boolean enableNoLaser=true; // enable images for this channel w/o matched laser pointer
public double right; // distance to the right (radius*sin(azimuth))
public double forward; // distance forward (radius*cos(azimuth))
public double heading; // absolute heading in degrees (used in cartesian mode)
public double azimuth; // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
public double radius; // mm, distance from the rotation axis
public double height; // mm, up - from the origin point
public double phi; // degrees, optical axis from azimuth/r vector, clockwise
public double phi; // degrees, optical axis from azimuth/r vector, clockwise (absolute if cylindrical = false)
public double theta; // degrees, optical axis from the eyesis horizon, positive - up
public double psi; // degrees, rotation (of the sensor) around the optical axis. Positive if camera is rotated clockwise looking to the target
public double focalLength=4.5;
......@@ -68,8 +73,12 @@ import java.util.Properties;
*/
public EyesisSubCameraParameters(
boolean cartesian,
int lensDistortionModel,
boolean enableNoLaser,
double right, // distance to the right (radius*sin(azimuth))
double forward, // distance forward (radius*cos(azimuth))
double heading, // used in cartesian mode
double azimuth, // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
double radius, // mm, distance from the rotation axis
double height, // mm, up from the origin point
......@@ -92,8 +101,13 @@ import java.util.Properties;
double [][] r_od, // elongation for c,b,a,a5,a6,a7,a8
double channelWeightDefault
){
this.cartesian = cartesian;
this.lensDistortionModel=lensDistortionModel;
this.enableNoLaser=enableNoLaser;
this.right = right;
this.forward = forward;
this.heading = heading;
this.azimuth=azimuth;
this.radius=radius;
this.height=height;
......@@ -123,12 +137,17 @@ import java.util.Properties;
this.defectsXY=null; // pixel defects coordinates list (starting with worst)
this.defectsDiff=null; // pixel defects value (diff from average of neighbors), matching defectsXY
updateCartesian(); // set alternative
}
// defects are not cloned!
public EyesisSubCameraParameters clone() {
return new EyesisSubCameraParameters(
this.cartesian,
this.lensDistortionModel,
this.enableNoLaser,
this.right,
this.forward,
this.heading,
this.azimuth,
this.radius,
this.height,
......@@ -160,8 +179,12 @@ import java.util.Properties;
}
// TODO: add/restore new properties
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"cartesian",this.cartesian+"");
properties.setProperty(prefix+"lensDistortionModel",this.lensDistortionModel+"");
properties.setProperty(prefix+"enableNoLaser",this.enableNoLaser+"");
properties.setProperty(prefix+"right",this.right+"");
properties.setProperty(prefix+"heading",this.heading+"");
properties.setProperty(prefix+"forward",this.forward+"");
properties.setProperty(prefix+"azimuth",this.azimuth+"");
properties.setProperty(prefix+"radius",this.radius+"");
properties.setProperty(prefix+"height",this.height+"");
......@@ -194,8 +217,17 @@ import java.util.Properties;
getProperties(prefix,properties, -1);
}
public void getProperties(String prefix,Properties properties, int channel){
if (properties.getProperty(prefix+"cartesian")!=null)
this.cartesian=Boolean.parseBoolean(properties.getProperty(prefix+"cartesian"));
if (properties.getProperty(prefix+"lensDistortionModel")!=null)
this.lensDistortionModel=Integer.parseInt(properties.getProperty(prefix+"lensDistortionModel"));
if (properties.getProperty(prefix+"right")!=null)
this.right=Double.parseDouble(properties.getProperty(prefix+"right"));
if (properties.getProperty(prefix+"forward")!=null)
this.forward=Double.parseDouble(properties.getProperty(prefix+"forward"));
if (properties.getProperty(prefix+"heading")!=null)
this.heading=Double.parseDouble(properties.getProperty(prefix+"heading"));
if (properties.getProperty(prefix+"azimuth")!=null)
this.azimuth=Double.parseDouble(properties.getProperty(prefix+"azimuth"));
if (properties.getProperty(prefix+"radius")!=null)
......@@ -264,4 +296,21 @@ import java.util.Properties;
public double getChannelWeightDefault(){
return this.channelWeightDefault;
}
public void updateCartesian(){ // set alternative parameters
if (cartesian) {
this.azimuth = Math.atan2(this.right, this.forward)*180.0/Math.PI;
this.radius = Math.sqrt(this.forward*this.forward + this.right*this.right);
this.phi = this.heading - this.azimuth;
} else {
this.forward = this.radius * Math.cos(Math.PI*this.azimuth/180.0);
this.right = this.radius * Math.sin(Math.PI*this.azimuth/180.0);
this.heading = this.phi + this.azimuth;
}
}
public void setCartesian(boolean cartesian){
if (this.cartesian == cartesian) return; // already in this mode
updateCartesian();
this.cartesian = cartesian;
}
}
......@@ -900,10 +900,11 @@ horizontal axis:
distortionCalibrationData.initImageSet(eyesisCameraParameters);
// Set initial azimuth and elevation
double [] initialAzEl=distortionCalibrationData.getAzEl(imgWithMaxPointers);
// Set initial heading and elevation
double [] initialHeadEl=distortionCalibrationData.getHeadEl(imgWithMaxPointers);
// set goniometer horizontal axis angle and goniometer axial angles in all images
distortionCalibrationData.setGHGA(-initialAzEl[1], -initialAzEl[0]);
if (debug_level > 1) System.out.println("Initial Azimuth and Elevation are set to az="+IJ.d2s(-initialAzEl[0],2)+", elvation="+IJ.d2s(-initialAzEl[1],2));
distortionCalibrationData.setGHGA(-initialHeadEl[1], -initialHeadEl[0]);
if (debug_level > 1) System.out.println("Initial Heading and Elevation are set to heading="+IJ.d2s(-initialHeadEl[0],2)+", elvation="+IJ.d2s(-initialHeadEl[1],2));
lensDistortions.copySensorConstants(eyesisCameraParameters); // copy from the first channel
// lensDistortions.fittingStrategy will be defined later, no need to
......
......@@ -95,6 +95,7 @@ import Jama.Matrix;
public LensDistortionParameters(
// LensDistortionParameters lensDistortionParameters,
boolean isTripod,
boolean cartesian,
double [][] interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
double [] parVect,
boolean [] mask, // calculate only selected derivatives (all parVect values are still
......@@ -105,6 +106,7 @@ import Jama.Matrix;
lensCalcInterParamers( // changed name to move calcInterParamers method from enclosing class
this,
isTripod,
cartesian,
interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
parVect,
mask // calculate only selected derivatives (all parVect values are still
......@@ -1854,19 +1856,22 @@ dPXmmc/dphi=
public void lensCalcInterParamers(
LensDistortionParameters lensDistortionParameters,
boolean isTripod,
boolean cartesian,
double [][] interParameterDerivatives, //partial derivative matrix from subcamera-camera-goniometer to single camera (12x21) if null - just values, no derivatives
double [] parVect,
boolean [] mask // calculate only selected derivatives (all parVect values are still
// boolean calculateDerivatives // calculate this.interParameterDerivatives -derivatives array (false - just this.values)
){
// LensDistortionParameters lensDistortionParameters=this;
boolean calculateDerivatives=(interParameterDerivatives!=null); // calculate this.interParameterDerivatives -derivatives array (false - just this.values)
// change meaning of goniometerHorizontal (tripod vertical) and goniometerAxial (tripod horizontal)
// boolean isTripod=this.fittingStrategy.distortionCalibrationData.eyesisCameraParameters.isTripod;
double azimuth=parVect[0];
double radius= parVect[1];
double height= parVect[2];
double phi= parVect[3];
// change meaning of goniometerHorizontal (tripod vertical) and goniometerAxial (tripod horizontal)
// Alternative variables for cartesian/cylindrical modes
double azimuth_cyl= cartesian? Double.NaN: parVect[0];
double right_cart= cartesian? parVect[0] : Double.NaN;
double radius_cyl= cartesian? Double.NaN: parVect[1];
double forward_cart= cartesian? parVect[1]: Double.NaN;
double height= parVect[2];
double phi_cyl= cartesian? Double.NaN: parVect[3];
double heading_cart= cartesian? parVect[3]: Double.NaN;
double theta= parVect[4];
double psi= parVect[5];
double goniometerHorizontal=parVect[6];
......@@ -1885,10 +1890,14 @@ dPXmmc/dphi=
double sPS= Math.sin(psi*Math.PI/180); // subCam.psi
double cTH= Math.cos(theta*Math.PI/180); // subCam.theta
double sTH= Math.sin(theta*Math.PI/180); // subCam.theta
double cAZP= Math.cos((azimuth+phi)*Math.PI/180); //subCam.azimuth+subCam.phi
double sAZP= Math.sin((azimuth+phi)*Math.PI/180); //subCam.azimuth+subCam.phi
double cAZ= Math.cos(azimuth*Math.PI/180); //subCam.azimuth
double sAZ= Math.sin(azimuth*Math.PI/180); //subCam.azimuth
double cAZP= Math.cos((cartesian?heading_cart:(azimuth_cyl+phi_cyl))*Math.PI/180); //subCam.azimuth+subCam.phi
double sAZP= Math.sin((cartesian?heading_cart:(azimuth_cyl+phi_cyl))*Math.PI/180); //subCam.azimuth+subCam.phi
// renaming the following 2 to be replaced for cartesian coordinates
double cAZ_cyl= Math.cos(azimuth_cyl*Math.PI/180); //subCam.azimuth
double sAZ_cyl= Math.sin(azimuth_cyl*Math.PI/180); //subCam.azimuth
double cGA= Math.cos(goniometerAxial*Math.PI/180); //eyesisCameraParameters.goniometerAxial
double sGA= Math.sin(goniometerAxial*Math.PI/180); //eyesisCameraParameters.goniometerAxial
double cGH= Math.cos(goniometerHorizontal*Math.PI/180); //eyesisCameraParameters.goniometerHorizontal
......@@ -1940,7 +1949,10 @@ dPXmmc/dphi=
| Yey | = | height+centerAboveHorizontal | + |Yc3|
| Zey | | r * cos (azimuth) | |Zc3|
*/
double [][] aT1={{radius*sAZ},{(height+centerAboveHorizontal)},{radius*cAZ}}; // {{subCam.radius*sAZ},{subCam.height},{subCam.radius*cAZ}};
double [][] aT1_cyl= {{radius_cyl*sAZ_cyl},{(height+centerAboveHorizontal)},{radius_cyl*cAZ_cyl}}; // {{subCam.radius*sAZ},{subCam.height},{subCam.radius*cAZ}};
double [][] aT1_cart={{right_cart}, {(height+centerAboveHorizontal)},{forward_cart}}; // {{subCam.radius*sAZ},{subCam.height},{subCam.radius*cAZ}};
double [][] aT1= cartesian ? aT1_cart : aT1_cyl;
Matrix T1=new Matrix(aT1);
/**
......@@ -2047,13 +2059,6 @@ dPXmmc/dphi=
lensDistortionParameters.pitch=extrinsicParams[4];
lensDistortionParameters.yaw= extrinsicParams[3];
lensDistortionParameters.roll= extrinsicParams[5];
// lensDistortionParameters.focalLength=parVect[15]; //subCam.focalLength;
// lensDistortionParameters.px0=parVect[16]; //subCam.px0;
// lensDistortionParameters.py0=parVect[17]; //subCam.py0;
// lensDistortionParameters.distortionA5=parVect[18]; //subCam.distortion5;
// lensDistortionParameters.distortionA=parVect[19]; //subCam.distortionA;
// lensDistortionParameters.distortionB=parVect[20]; //subCam.distortionB;
// lensDistortionParameters.distortionC=parVect[21]; //subCam.distortionC;
lensDistortionParameters.focalLength=parVect[17]; //subCam.focalLength;
lensDistortionParameters.px0=parVect[18]; //subCam.px0;
......@@ -2068,8 +2073,6 @@ dPXmmc/dphi=
lensDistortionParameters.r_xy=new double [6][2];
lensDistortionParameters.r_od=new double [7][2];
// parVect here is o[0],d[0],{x[0],y[0],o[1],d[1]}, {} = same term
int index=27;
for (int i=0;i<lensDistortionParameters.r_od.length;i++){
......@@ -2268,10 +2271,13 @@ dPXmmc/dphi=
Which parameters affect which matrices
R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 || T0 | T1 | T2 | T3 |
0 public double azimuth; // | | + | | | | | || | + | | |
1 public double radius; // | | | | | | | || | + | | |
0 public double azimuth_cyl; // | | + | | | | | || | + | | |
1 public double radius_cyl; // | | | | | | | || | + | | |
0 public double right_cart; // | | | | | | | || | + | | |
1 public double forward_cart; // | | | | | | | || | + | | |
2 public double height; // | | | | | | | || | + | | |
3 public double phi; // | | + | | | | | || | | | |
3 public double phi_cyl; // | | + | | | | | || | | | |
3 public double head_cart; // | | + | | | | | || | | | |
4 public double theta; // | + | | | | | | || | | | |
5 public double psi; // + | | | | | | | || | | | |
6 public double goniometerHorizontal; // | | | | | + | | || | | | |
......@@ -2293,41 +2299,70 @@ dPXmmc/dphi=
System.out.println("calcInterParamers(): parVect["+i+"]="+parVect[i]);
}
}
//0 public double azimuth; // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
//0 public double right_cart; // right displacement of the lens entrance pupil center, mm
if (mask[0]) {
double [][] adR3_azimuth={{-sAZP,0.0,cAZP},{0.0,0.0,0.0},{-cAZP,0.0,-sAZP}};
Matrix dR3_azimuth=new Matrix(adR3_azimuth);
// double [][] adT1_azimuth={{radius*cAZ},{height},{-radius*sAZ}}; //{{subCam.radius*cAZ},{subCam.height},{-subCam.radius*sAZ}}
double [][] adT1_azimuth={{radius*cAZ},{0.0},{-radius*sAZ}}; //{{subCam.radius*cAZ},{subCam.height},{-subCam.radius*sAZ}}
Matrix dT1_azimuth=new Matrix(adT1_azimuth);
Matrix dMA_azimuth=R8.times(R7.times(R6.times(R5.times(R4.times(dR3_azimuth.times(R2.times(R1)))))));
Matrix dMB0_azimuth=R8.times(R7.times(R6.times(R5.times(R4.times(dT1_azimuth)))));
Matrix dMB_azimuth=dMB0_azimuth.plus(dMA_azimuth.times(T0)); // new term
interParameterDerivatives[0]=d_parametersFromMAMB(dMA_azimuth,dMB_azimuth,MA,MB,true); // all after 6 are 0;
if (this.debugLevel>2) {
System.out.println("dMA_azimuth:");
dMA_azimuth.print(10, 5);
System.out.println("dMB_azimuth:");
dMB_azimuth.print(10, 5);
System.out.println("interParameterDerivatives[0]="+sprintfArray(interParameterDerivatives[0]));
}
if (cartesian) {
double [][] adT1_right_cart={{1.0},{0.0},{0.0}};
Matrix dT1_right_cart=new Matrix(adT1_right_cart);
Matrix dMA_right_cart=new Matrix(3,3,0.0); // zero
Matrix dMB_right_cart=R8.times(R7.times(R6.times(R5.times(R4.times(dT1_right_cart)))));
interParameterDerivatives[0]=d_parametersFromMAMB(dMA_right_cart,dMB_right_cart,MA,MB,false);
if (this.debugLevel>2) {
System.out.println("dMA_right_cart:");
dMA_right_cart.print(10, 5);
System.out.println("dMB_right_cart:");
dMB_right_cart.print(10, 5);
System.out.println("interParameterDerivatives[0]="+sprintfArray(interParameterDerivatives[0]));
}
} else {
//0 public double azimuth; // azimuth of the lens entrance pupil center, degrees, clockwise looking from top
double [][] adR3_azimuth_cyl={{-sAZP,0.0,cAZP},{0.0,0.0,0.0},{-cAZP,0.0,-sAZP}};
Matrix dR3_azimuth_cyl=new Matrix(adR3_azimuth_cyl);
double [][] adT1_azimuth_cyl={{radius_cyl*cAZ_cyl},{0.0},{-radius_cyl*sAZ_cyl}}; //{{subCam.radius*cAZ},{subCam.height},{-subCam.radius*sAZ}}
Matrix dT1_azimuth_cyl=new Matrix(adT1_azimuth_cyl);
Matrix dMA_azimuth_cyl=R8.times(R7.times(R6.times(R5.times(R4.times(dR3_azimuth_cyl.times(R2.times(R1)))))));
Matrix dMB0_azimuth_cyl=R8.times(R7.times(R6.times(R5.times(R4.times(dT1_azimuth_cyl)))));
Matrix dMB_azimuth_cyl=dMB0_azimuth_cyl.plus(dMA_azimuth_cyl.times(T0)); // new term
interParameterDerivatives[0]=d_parametersFromMAMB(dMA_azimuth_cyl,dMB_azimuth_cyl,MA,MB,true); // all after 6 are 0;
if (this.debugLevel>2) {
System.out.println("dMA_azimuth_cyl:");
dMA_azimuth_cyl.print(10, 5);
System.out.println("dMB_azimuth_cyl:");
dMB_azimuth_cyl.print(10, 5);
System.out.println("interParameterDerivatives[0]="+sprintfArray(interParameterDerivatives[0]));
}
}
} else interParameterDerivatives[0]=null;
//1 public double radius; // mm, distance from the rotation axis
if (mask[1]) {
double [][] adT1_radius={{sAZ},{0.0},{cAZ}}; //{{subCam.radius*sAZ},{0.0},{subCam.radius*cAZ}}
Matrix dT1_radius=new Matrix(adT1_radius);
Matrix dMA_radius=new Matrix(3,3,0.0);
Matrix dMB_radius=R8.times(R7.times(R6.times(R5.times(R4.times(dT1_radius)))));
interParameterDerivatives[1]=d_parametersFromMAMB(dMA_radius,dMB_radius,MA,MB,false); // all after 6 are 0;
if (this.debugLevel>2) {
System.out.println("dMA_radius:");
dMA_radius.print(10, 5);
System.out.println("dMB_radius:");
dMB_radius.print(10, 5);
System.out.println("interParameterDerivatives[1]="+sprintfArray(interParameterDerivatives[1]));
}
if (cartesian) {
double [][] adT1_forward_cart={{0.0},{0.0},{1.0}}; //{{subCam.radius*sAZ},{0.0},{subCam.radius*cAZ}}
Matrix dT1_forward_cart=new Matrix(adT1_forward_cart);
Matrix dMA_forward_cart=new Matrix(3,3,0.0);
Matrix dMB_forward_cart=R8.times(R7.times(R6.times(R5.times(R4.times(dT1_forward_cart)))));
interParameterDerivatives[1]=d_parametersFromMAMB(dMA_forward_cart,dMB_forward_cart,MA,MB,false); // all after 6 are 0;
if (this.debugLevel>2) {
System.out.println("dMA_forward_cart:");
dMA_forward_cart.print(10, 5);
System.out.println("dMB_forward_cart:");
dMB_forward_cart.print(10, 5);
System.out.println("interParameterDerivatives[1]="+sprintfArray(interParameterDerivatives[1]));
}
} else {
double [][] adT1_radius_cyl={{sAZ_cyl},{0.0},{cAZ_cyl}}; //{{subCam.radius*sAZ},{0.0},{subCam.radius*cAZ}}
Matrix dT1_radius_cyl=new Matrix(adT1_radius_cyl);
Matrix dMA_radius_cyl=new Matrix(3,3,0.0);
Matrix dMB_radius_cyl=R8.times(R7.times(R6.times(R5.times(R4.times(dT1_radius_cyl)))));
interParameterDerivatives[1]=d_parametersFromMAMB(dMA_radius_cyl,dMB_radius_cyl,MA,MB,false); // all after 6 are 0;
if (this.debugLevel>2) {
System.out.println("dMA_radius_cyl:");
dMA_radius_cyl.print(10, 5);
System.out.println("dMB_radius_cyl:");
dMB_radius_cyl.print(10, 5);
System.out.println("interParameterDerivatives[1]="+sprintfArray(interParameterDerivatives[1]));
}
}
} else interParameterDerivatives[1]=null;
//2 public double height; // mm, downwards - from the origin point
if (mask[2]) {
......@@ -2345,7 +2380,7 @@ dPXmmc/dphi=
}
} else interParameterDerivatives[2]=null;
//3 public double phi; // degrees, optical axis from azimuth/r vector, clockwise
if (mask[3]) {
if (mask[3]) { // here the same for cartesian
double [][] adR3_phi={{-sAZP,0.0,cAZP},{0.0,0.0,0.0},{-cAZP,0.0,-sAZP}}; // same as adR3_azimuth
Matrix dR3_phi=new Matrix(adR3_phi); // same as dR3_azimuth
Matrix dMA_phi=R8.times(R7.times(R6.times(R5.times(R4.times(dR3_phi.times(R2.times(R1))))))); //same as dMA_azimuth
......
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