Commit 0daef805 authored by Andrey Filippov's avatar Andrey Filippov

Debugging conversion to circular multicam

parent 7ba9c309
......@@ -78,7 +78,16 @@ public class CorrVector{ // TODO: Update to non-quad (extract to a file first)?
return geometryCorrection.getNumSensors();
}
public static int getNumSensors(int vector_length) {
int num_sensors=4;
for (; getLength(num_sensors) < vector_length; num_sensors++);
if (getLength(num_sensors) != vector_length) {
throw new IllegalArgumentException ("Invalid vector length = "+vector_length);
}
return num_sensors;
}
//getLength()
public static String [] getCorrNames(int num_chn) {
String [] corr_names = new String[getLength(num_chn)];
for (int n = 0; n < num_chn; n++) {
......@@ -514,7 +523,7 @@ public class CorrVector{ // TODO: Update to non-quad (extract to a file first)?
}
f_avg /= f.length;
for (int i = 0; i < (f.length-1); i++) {
vector[indx+i] = (f[i] - f_avg)/f_avg;
vector[indx+i] = (f[i] - f_avg)/f_avg; // here first time wrong number of sensors
}
return f_avg;
}
......@@ -636,10 +645,10 @@ public class CorrVector{ // TODO: Update to non-quad (extract to a file first)?
}
}
s = "";
s+= "tilt (up): "; for (int i = 0; i < n; i++) s += String.format(" %8.5fpx", tilts[i]); s+=" (shift of the image center)\n";
s+= "azimuth (right):"; for (int i = 0; i < n; i++) s += String.format(" %8.5fpx", azimuths[i]); s+=" (shift of the image center)\n";
s+= "roll (CW): "; for (int i = 0; i < n; i++) s += String.format(" %8.5fpx", rolls[i]); s+=" (shift at the image half-width from the center)\n";
s+= "diff zoom (in): "; for (int i = 0; i < n; i++) s += String.format(" %8.5fpx", zooms[i]); s+=" (shift at the image half-width from the center)\n";
s+= "tilt (up): "; for (int i = 0; i < n; i++) s += String.format(" %8.4fpx", tilts[i]); s+=" (shift of the image center)\n";
s+= "azimuth (right):"; for (int i = 0; i < n; i++) s += String.format(" %8.4fpx", azimuths[i]); s+=" (shift of the image center)\n";
s+= "roll (CW): "; for (int i = 0; i < n; i++) s += String.format(" %8.4fpx", rolls[i]); s+=" (shift at the image half-width from the center)\n";
s+= "diff zoom (in): "; for (int i = 0; i < n; i++) s += String.format(" %8.4fpx", zooms[i]); s+=" (shift at the image half-width from the center)\n";
s += "Symmetrical vector:\n";
if (getNumSensors() == 4) { // Use arrows for quad camera only (but update to match new
// ← → ↑ ↓ ⇖ ⇗ ⇘ ⇙ ↔ ↺ ↻
......@@ -678,9 +687,9 @@ Vector # 3 [-|+|-|+] 1.00<1.00 [1.0 | 1.0 | 1.0 | 1.0 ] l= 1.0 n=1(1)
if ((j>0) && (j%(n/4) == 0)) {
s += "|";
}
s += rt4[rt_proto[indx][i]];
s += rt4[rt_proto[i][j]];
}
s+=String.format("] %9.6f px", sv[indx]);
s+=String.format("] %9.6f px\n", sv[indx]);
indx++;
}
// rolls
......@@ -691,15 +700,15 @@ Vector # 3 [-|+|-|+] 1.00<1.00 [1.0 | 1.0 | 1.0 | 1.0 ] l= 1.0 n=1(1)
if ((j>0) && (j%(n/4) == 0)) {
s += "|";
}
if (rot_proto[indx][i] > 0) {
if (rot_proto[i][j] > 0) { // Index 30 out of bounds for length 16
s+="↻";
} else if (rot_proto[indx][i] < 0) {
} else if (rot_proto[i][j] < 0) {
s+="↺";
} else {
s+="0";
}
}
s+=String.format("] %9.6f px", sv[indx]);
s+=String.format("] %9.6f px\n", sv[indx]);
indx++;
}
// zooms
......@@ -710,15 +719,15 @@ Vector # 3 [-|+|-|+] 1.00<1.00 [1.0 | 1.0 | 1.0 | 1.0 ] l= 1.0 n=1(1)
if ((j>0) && (j%(n/4) == 0)) {
s += "|";
}
if (zoom_proto[indx][i] > 0) {
if (zoom_proto[i][j] > 0) {
s+="+";
} else if (zoom_proto[indx][i] < 0) {
} else if (zoom_proto[i][j] < 0) {
s+="-";
} else {
s+="0";
}
}
s+=String.format("] %9.6f px", sv[indx]);
s+=String.format("] %9.6f px\n", sv[indx]);
indx++;
}
}
......
......@@ -799,7 +799,12 @@ public class QuadCLTCPU {
}
// Substitute vector generated in initGeometryCorrection with the saved from properties one:
// it also replaces data inside geometryCorrection. TODO: redo to isolate this.extrinsic_vect from geometryCorrection
this.extrinsic_vect = extrinsic_vect_saved;
if (extrinsic_vect_saved.length == this.extrinsic_vect.length) {
this.extrinsic_vect = extrinsic_vect_saved;
} else {
System.out.println("Ignoring incompatible saved extrinsic vector ("+extrinsic_vect_saved.length+
" long) as current vector length is " + this.extrinsic_vect.length);
}
geometryCorrection.setCorrVector(this.extrinsic_vect);
// geometryCorrection = new GeometryCorrection(this.extrinsic_vect);
}
......@@ -832,9 +837,6 @@ public class QuadCLTCPU {
}
public boolean initGeometryCorrection(int debugLevel){ // USED in lwir
// keep rig offsets if edited
if (geometryCorrection == null) {
geometryCorrection = new GeometryCorrection(extrinsic_vect);
}
if (eyesisCorrections.pixelMapping == null) {
// need to initialize sensor data
// eyesisCorrections.initSensorFiles(.debugLevel..);
......@@ -843,6 +845,27 @@ public class QuadCLTCPU {
PixelMapping.SensorData [] sensors = eyesisCorrections.pixelMapping.sensors;
// verify that all sensors have the same distortion parameters
int numSensors = sensors.length;
// if num_sesnors mismatch extrinsic_vect - reset extrinsic_vect and
int vector_length = CorrVector.getLength(numSensors);
if ((extrinsic_vect == null) || (extrinsic_vect.length != vector_length)) {
if (extrinsic_vect == null) {
System.out.println("initGeometryCorrection(): Was not expecting extrinsic_vect == null");
} else {
System.out.println("initGeometryCorrection(): extrinsic_vect.length="+extrinsic_vect.length+
" does not match "+numSensors+ " sensors (it should be "+vector_length+")");
}
System.out.println("Resetting geometryCorrection");
geometryCorrection = null;
System.out.println("Resetting extrinsic_vect");
extrinsic_vect = new double[vector_length];
}
if (geometryCorrection == null) {
geometryCorrection = new GeometryCorrection(extrinsic_vect);
}
for (int i = 1; i < numSensors; i++){
if (// (sensors[0].focalLength != sensors[i].focalLength) || // null pointer
(sensors[0].distortionC != sensors[i].distortionC) ||
......@@ -942,7 +965,7 @@ public class QuadCLTCPU {
System.out.println("=== Extrinsic corrections ===");
System.out.println(geometryCorrection.getCorrVector().toString());
}
double [] dbg_objects = geometryCorrection.toDoubleArray();
//listGeometryCorrection
return true;
}
......
......@@ -95,7 +95,7 @@ public class SymmVector {
public static SymmVectorsSet newVectors (int num_cameras) {
boolean full_type1 = false;
boolean full_type2 = false;
int debug_level = -1;
int debug_level = -2;
SymmVectorsSet rvs = new SymmVectorsSet();
SymmVector sv = new SymmVector(
num_cameras,
......@@ -410,7 +410,7 @@ public class SymmVector {
int offs = zoom_mode ? 1 : 0;
double [][] rslt = new double[rz_indices.length - offs][];
for (int n = 0; n < rslt.length; n++) {
rslt[n]= rz_vectors[rz_indices[n + offs]]; // should be normalized
rslt[n]= rz_vectors[rz_indices[n + offs]].clone(); // should be normalized
}
return rslt;
}
......@@ -1175,10 +1175,10 @@ public class SymmVector {
}
public Matrix[] fromToSym() {
Matrix sym2ta = symToTA(exportXY()); // 2*N-2
Matrix sym2roll = symToRoll(exportRZ(false)); // N
Matrix sym2zoom = symToRoll(exportRZ(true)); // N-1
Matrix sym2ers = Matrix.identity(NUM_ERS,NUM_ERS);// NUM_ERS
Matrix sym2ta = symToTA(exportXY()); // 2*N-2
Matrix sym2roll = symToRoll(exportRZ(false)); // N
Matrix sym2zoom = symToRoll(exportRZ(true)).getMatrix(0,N-2,0,N-2); // N-1, do not use last line
Matrix sym2ers = Matrix.identity(NUM_ERS,NUM_ERS); // NUM_ERS
int i0 = 0;
int i1 = i0 + sym2ta.getColumnDimension();
int i2 = i1 + sym2roll.getColumnDimension();
......@@ -1188,13 +1188,13 @@ public class SymmVector {
from_sym.setMatrix(i0,i1-1,i0,i1-1, sym2ta);
from_sym.setMatrix(i1,i2-1,i1,i2-1, sym2roll);
from_sym.setMatrix(i2,i3-1,i2,i3-1, sym2zoom);
from_sym.setMatrix(i3,i4-1,i4,i4-1, sym2ers);
from_sym.setMatrix(i3,i4-1,i3,i4-1, sym2ers);
Matrix to_sym = new Matrix(i4,i4);
to_sym.setMatrix(i0,i1-1,i0,i1-1, sym2ta.inverse());
to_sym.setMatrix(i1,i2-1,i1,i2-1, sym2roll.inverse());
to_sym.setMatrix(i2,i3-1,i2,i3-1, sym2zoom.inverse());
to_sym.setMatrix(i3,i4-1,i4,i4-1, sym2ers.inverse());
to_sym.setMatrix(i3,i4-1,i3,i4-1, sym2ers.inverse());
return new Matrix[] {from_sym,to_sym};
}
//getColumnDimension
......
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