Commit c9ee2c7d authored by Andrey Filippov's avatar Andrey Filippov

working on cartesian-defined multi-cameras

parent 1e8f23fb
......@@ -412,6 +412,7 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
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
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,
......@@ -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
......
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
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