Commit 36dcabff authored by Andrey Filippov's avatar Andrey Filippov

modifying for non-quad (sym <->vect and derivatives still remain)

parent 0895e5a9
...@@ -7,6 +7,7 @@ import java.nio.ByteOrder; ...@@ -7,6 +7,7 @@ import java.nio.ByteOrder;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
import com.elphel.imagej.common.GenericJTabbedDialog; import com.elphel.imagej.common.GenericJTabbedDialog;
...@@ -52,9 +53,7 @@ public class GeometryCorrection { ...@@ -52,9 +53,7 @@ public class GeometryCorrection {
// use static CorrVector.getCorrNames(numSensors) // use static CorrVector.getCorrNames(numSensors)
// or non-static corrVector.getCorrNames(); // or non-static corrVector.getCorrNames();
public String [] getCorrNames() { /*
return CorrVector.getCorrNames(numSensors);
}
static final String [] CORR_NAMES = { // need to be fixed too! static final String [] CORR_NAMES = { // need to be fixed too!
"tilt0","tilt1","tilt2", "tilt0","tilt1","tilt2",
"azimuth0","azimuth1","azimuth2", "azimuth0","azimuth1","azimuth2",
...@@ -62,7 +61,7 @@ public class GeometryCorrection { ...@@ -62,7 +61,7 @@ public class GeometryCorrection {
"zoom0","zoom1","zoom2", "zoom0","zoom1","zoom2",
"omega_tilt", "omega_azimuth", "omega_roll", "omega_tilt", "omega_azimuth", "omega_roll",
"velocity_x", "velocity_y", "velocity_z"}; "velocity_x", "velocity_y", "velocity_z"};
*/
public int debugLevel = 0; public int debugLevel = 0;
public double line_time = 36.38E-6; // 26.5E-6; // duration of sensor scan line (for ERS) Wrong, 36.38us (change and re-run ERS public double line_time = 36.38E-6; // 26.5E-6; // duration of sensor scan line (for ERS) Wrong, 36.38us (change and re-run ERS
public int pixelCorrectionWidth=2592; // virtual camera center is at (pixelCorrectionWidth/2, pixelCorrectionHeight/2) public int pixelCorrectionWidth=2592; // virtual camera center is at (pixelCorrectionWidth/2, pixelCorrectionHeight/2)
...@@ -141,6 +140,49 @@ public class GeometryCorrection { ...@@ -141,6 +140,49 @@ public class GeometryCorrection {
public int [] woi_tops = null; // used to calculate scanline timing public int [] woi_tops = null; // used to calculate scanline timing
public int [] camera_heights = null; // actual acquired lines (from woi_tops) public int [] camera_heights = null; // actual acquired lines (from woi_tops)
public String [] getCorrNames() {
return CorrVector.getCorrNames(numSensors);
}
// Removing dependence on CORR_NAMES in QuadCLTCPU
public void setPropertiesExtrinsic(String prefix, Properties properties) {
String [] corr_names = getCorrNames(); // variable number of cameras
for (int i = 0; i < corr_names.length; i++){
String name = prefix+"extrinsic_corr_"+corr_names[i];
properties.setProperty(name, getCorrVector().toArray()[i]+"");
}
}
public static void setPropertiesExtrinsic(String prefix, Properties properties, double [] extrinsic_corr) {
int num_cams = CorrVector.getCamerasFromEV(extrinsic_corr.length);
String [] corr_names = CorrVector.getCorrNames(num_cams); // variable number of cameras
for (int i = 0; i < corr_names.length; i++){
String name = prefix+"extrinsic_corr_"+corr_names[i];
if (!Double.isNaN( extrinsic_corr[i])) {
properties.setProperty(name, extrinsic_corr[i]+"");
}
}
}
public static double [] getPropertiesExtrinsic(String prefix, Properties properties) {
// determine number of cameras from maximal tilt?
int num_chn = 4;
for (; true; num_chn++) {
String name = prefix+"extrinsic_corr_"+CorrVector.CORR_TILT+(num_chn - 1); // maximal tilt index = N-2 (tilt2 for quad)
if (properties.getProperty(name) == null) {
break;
}
}
String [] corr_names = CorrVector.getCorrNames(num_chn);
double [] extrinsic_vect = new double [corr_names.length];
Arrays.fill(extrinsic_vect, Double.NaN);
for (int i = 0; i < extrinsic_vect.length; i++) {
String name = prefix+"extrinsic_corr_"+corr_names[i];
if (properties.getProperty(name)!=null) {
extrinsic_vect[i] = Double.parseDouble(properties.getProperty(name));
}
}
return extrinsic_vect;
}
public float [] toFloatArray() { // for GPU comparison public float [] toFloatArray() { // for GPU comparison
return new float[] { return new float[] {
......
...@@ -110,7 +110,7 @@ public class QuadCLTCPU { ...@@ -110,7 +110,7 @@ public class QuadCLTCPU {
public EyesisCorrectionParameters.CorrectionParameters correctionsParameters=null; public EyesisCorrectionParameters.CorrectionParameters correctionsParameters=null;
double [][][][][][] clt_kernels = null; // can be used to determine monochrome too? double [][][][][][] clt_kernels = null; // can be used to determine monochrome too?
public GeometryCorrection geometryCorrection = null; public GeometryCorrection geometryCorrection = null;
double [] extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length]; // extrinsic corrections (needed from properties, before geometryCorrection double[] extrinsic_vect; // = new double [GeometryCorrection.CORR_NAMES.length]; // extrinsic corrections (needed from properties, before geometryCorrection
public int extra_items = 8; // number of extra items saved with kernels (center offset (partial, full, derivatives) public int extra_items = 8; // number of extra items saved with kernels (center offset (partial, full, derivatives)
public ImagePlus eyesisKernelImage = null; public ImagePlus eyesisKernelImage = null;
public long startTime; // start of batch processing public long startTime; // start of batch processing
...@@ -666,10 +666,13 @@ public class QuadCLTCPU { ...@@ -666,10 +666,13 @@ public class QuadCLTCPU {
if (gc == null) { // if it was not yet created if (gc == null) { // if it was not yet created
gc = new GeometryCorrection(this.extrinsic_vect); // not used in lwir gc = new GeometryCorrection(this.extrinsic_vect); // not used in lwir
} }
gc.setPropertiesExtrinsic(prefix, properties);
/*
for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){ for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){
String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i]; String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i];
properties.setProperty(name, gc.getCorrVector().toArray()[i]+""); properties.setProperty(name, gc.getCorrVector().toArray()[i]+"");
} }
*/
if (is_aux && (gc.rigOffset != null)) { if (is_aux && (gc.rigOffset != null)) {
gc.rigOffset.setProperties(prefix,properties); gc.rigOffset.setProperties(prefix,properties);
} }
...@@ -697,10 +700,16 @@ public class QuadCLTCPU { ...@@ -697,10 +700,16 @@ public class QuadCLTCPU {
} }
} }
} }
/*
GeometryCorrection gc = geometryCorrection; GeometryCorrection gc = geometryCorrection;
if (gc == null) { // if it was not yet created if (gc == null) { // if it was not yet created
gc = new GeometryCorrection(this.extrinsic_vect); gc = new GeometryCorrection(this.extrinsic_vect);
} }
*/
double [] other_extrinsic_vect = GeometryCorrection.getPropertiesExtrinsic(other_prefix, other_properties);
int num_cams = CorrVector.getCamerasFromEV(other_extrinsic_vect.length);
GeometryCorrection.setPropertiesExtrinsic(this_prefix, properties, other_extrinsic_vect);
/*
for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){ for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){
String other_name = other_prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i]; String other_name = other_prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i];
if (other_properties.getProperty(other_name)!=null) { if (other_properties.getProperty(other_name)!=null) {
...@@ -713,6 +722,7 @@ public class QuadCLTCPU { ...@@ -713,6 +722,7 @@ public class QuadCLTCPU {
properties.setProperty(this_name, gc.getCorrVector().toArray()[i]+""); properties.setProperty(this_name, gc.getCorrVector().toArray()[i]+"");
// System.out.println("copyPropertiesFrom():"+i+": setProperty("+this_name+","+gc.getCorrVector().toArray()[i]+""); // System.out.println("copyPropertiesFrom():"+i+": setProperty("+this_name+","+gc.getCorrVector().toArray()[i]+"");
} }
*/
// System.out.println("Done copyPropertiesFrom"); // System.out.println("Done copyPropertiesFrom");
} }
...@@ -751,6 +761,21 @@ public class QuadCLTCPU { ...@@ -751,6 +761,21 @@ public class QuadCLTCPU {
} }
} }
// always set extrinsic_corr // always set extrinsic_corr
double [] new_extrinsic_vect = GeometryCorrection.getPropertiesExtrinsic(prefix, properties);
int num_cams = CorrVector.getCamerasFromEV(new_extrinsic_vect.length);
for (int i = 0; i < new_extrinsic_vect.length; i++) {
if (!Double.isNaN(new_extrinsic_vect[i])) {
if (this.extrinsic_vect == null) { // not used in lwir
// only create non-null array if there are saved values
this.extrinsic_vect = new_extrinsic_vect.clone();
}
this.extrinsic_vect[i] = new_extrinsic_vect[i];
if (geometryCorrection != null){ // not used in lwir
geometryCorrection.setCorrVector(i,this.extrinsic_vect[i]); // should be same mumber of cameras
}
}
}
/*
for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){ for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){
String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i]; String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i];
if (properties.getProperty(name)!=null) { if (properties.getProperty(name)!=null) {
...@@ -759,20 +784,12 @@ public class QuadCLTCPU { ...@@ -759,20 +784,12 @@ public class QuadCLTCPU {
this.extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length]; this.extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length];
} }
this.extrinsic_vect[i] = Double.parseDouble(properties.getProperty(name)); this.extrinsic_vect[i] = Double.parseDouble(properties.getProperty(name));
// System.out.println("getProperties():"+i+": getProperty("+name+") -> "+properties.getProperty(name)+"");
if (geometryCorrection != null){ // not used in lwir if (geometryCorrection != null){ // not used in lwir
// if (geometryCorrection.getCorrVector().toArray() == null) {
// geometryCorrection.resetCorrVector(); // make it array of zeros
// }
// geometryCorrection.getCorrVector().toArray()[i] = this.extrinsic_vect[i];
geometryCorrection.setCorrVector(i,this.extrinsic_vect[i]); geometryCorrection.setCorrVector(i,this.extrinsic_vect[i]);
} }
} }
} }
// if (is_aux && (geometryCorrection != null)) { */
// geometryCorrection.setRigOffsetFromProperies(prefix, properties);
// }
if (geometryCorrection == null) { if (geometryCorrection == null) {
double [] extrinsic_vect_saved = this.extrinsic_vect.clone(); double [] extrinsic_vect_saved = this.extrinsic_vect.clone();
...@@ -846,11 +863,11 @@ public class QuadCLTCPU { ...@@ -846,11 +863,11 @@ public class QuadCLTCPU {
// TODO: Verify correction sign! // TODO: Verify correction sign!
double f_avg = geometryCorrection.getCorrVector().setZoomsFromF( double [] f_lengths = new double [sensors.length];
sensors[0].focalLength, for (int i = 0; i < f_lengths.length; i++) {
sensors[1].focalLength, f_lengths[i] = sensors[i].focalLength;
sensors[2].focalLength, }
sensors[3].focalLength); double f_avg = geometryCorrection.getCorrVector().setZoomsFromF(f_lengths);
// following parameters are used for scaling extrinsic corrections // following parameters are used for scaling extrinsic corrections
geometryCorrection.focalLength = f_avg; geometryCorrection.focalLength = f_avg;
...@@ -875,28 +892,13 @@ public class QuadCLTCPU { ...@@ -875,28 +892,13 @@ public class QuadCLTCPU {
sensors[0].pixelCorrectionHeight, sensors[0].pixelCorrectionHeight,
sensors[0].pixelSize); sensors[0].pixelSize);
// set other/individual sensor parameters // set other/individual sensor parameters
/* double [] thetas = new double [sensors.length];
for (int i = 1; i < numSensors; i++){ for (int i = 0; i < thetas.length; i++) thetas[i] = sensors[i].theta;
if ( (sensors[0].theta != sensors[i].theta) || // elevation double theta_avg = geometryCorrection.getCorrVector().setTiltsFromThetas(thetas);
(sensors[0].heading != sensors[i].heading)){
System.out.println("initGeometryCorrection(): All sensors have to have the same elevation and heading, but channels 0 and "+i+" mismatch");
return false;
}
}
*/
double theta_avg = geometryCorrection.getCorrVector().setTiltsFromThetas(
sensors[0].theta,
sensors[1].theta,
sensors[2].theta,
sensors[3].theta);
double heading_avg = geometryCorrection.getCorrVector().setAzimuthsFromHeadings(
sensors[0].heading,
sensors[1].heading,
sensors[2].heading,
sensors[3].heading);
double [] headings = new double [sensors.length];
for (int i = 0; i < headings.length; i++) headings[i] = sensors[i].heading;
double heading_avg = geometryCorrection.getCorrVector().setAzimuthsFromHeadings(headings);
double [] forward = new double[numSensors]; double [] forward = new double[numSensors];
double [] right = new double[numSensors]; double [] right = new double[numSensors];
double [] height = new double[numSensors]; double [] height = new double[numSensors];
......
package com.elphel.imagej.tileprocessor; package com.elphel.imagej.tileprocessor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
/** /**
** **
...@@ -62,10 +63,47 @@ public class SymmVector { ...@@ -62,10 +63,47 @@ public class SymmVector {
private int num_rz_defined; // number of defined rz_indices private int num_rz_defined; // number of defined rz_indices
private boolean [] used_rz_indices;// already used rz_vectors private boolean [] used_rz_indices;// already used rz_vectors
private double [] cumul_rz_influences; // will not work? - all candidates correlate the same private double [] cumul_rz_influences; // will not work? - all candidates correlate the same
public int debug_level = -1;
// caching results of vectors generation for used camera configuration not to re-generate each time
// CorrVector is constructed
public static HashMap <Integer,SymmVectorsSet> vectors_cache = new HashMap <Integer,SymmVectorsSet>();
public static SymmVectorsSet getSymmVectorsSet (int num_cameras) {
SymmVectorsSet rvs = vectors_cache.get(num_cameras);
if (rvs == null) {
rvs = newVectors (num_cameras);
vectors_cache.put(num_cameras, rvs);
}
return rvs;
}
public static double [][] getSymmXY(int num_cameras){
SymmVectorsSet rvs = vectors_cache.get(num_cameras);
if (rvs == null) {
rvs = newVectors (num_cameras);
vectors_cache.put(num_cameras, rvs);
}
return rvs.xy;
}
public int debug_level = -1; public static SymmVectorsSet newVectors (int num_cameras) {
boolean full_type1 = false;
boolean full_type2 = false;
int debug_level = -1;
SymmVectorsSet rvs = new SymmVectorsSet();
SymmVector sv = new SymmVector(
num_cameras,
full_type1,
full_type2,
debug_level);
rvs.xy = sv.exportXY();
rvs.rt = sv.exportRT();
rvs.dir_rt = sv.exportDirRT();
rvs.rots = sv.exportRZ(false); // include common roll
rvs.zooms = sv.exportRZ(true); // no common zoom
return rvs;
}
public SymmVector ( public SymmVector (
int num_cameras, int num_cameras,
...@@ -343,6 +381,18 @@ public class SymmVector { ...@@ -343,6 +381,18 @@ public class SymmVector {
return rslt; return rslt;
} }
/**
* Export directions (0 - radial to center, 1 - tangential CW, 2 - radial out , 3 tangential CW
* @return
*/
public int [][] exportDirRT(){
int [][] rslt = new int[sym_indices.length][];
for (int n = 0; n < sym_indices.length; n++){
rslt[n]= proto_all[sym_indices[n]];
}
return rslt;
}
/** /**
* *
* @param zoom_mode * @param zoom_mode
...@@ -1064,3 +1114,12 @@ public class SymmVector { ...@@ -1064,3 +1114,12 @@ public class SymmVector {
*/ */
} }
class SymmVectorsSet {
// int num_sensors;
double [][] xy;
double [][] rt;
int [][] dir_rt;
double [][] rots;
double [][] zooms;
}
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