Commit 8295add0 authored by Andrey Filippov's avatar Andrey Filippov

implementing initial orientation estimation, full window for eo

acquisition
parent f406805d
......@@ -2165,7 +2165,7 @@ if (MORE_BUTTONS) {
);
// set initial orientation of the cameras from the sensors that see mpst of the matching pointers
// just for the LMA to start
DISTORTION_CALIBRATION_DATA.setInitialOrientation(true);
DISTORTION_CALIBRATION_DATA.setInitialOrientation(PATTERN_PARAMETERS, true);
return;
}
......@@ -5871,7 +5871,7 @@ if (MORE_BUTTONS) {
DISTORTION_CALIBRATION_DATA.updateSetOrientation(null); // restore orientation from (enabled) image files
if (DEBUG_LEVEL>0) System.out.println("Setting sets orientation from per-grid image data");
}
if (overwriteAll) DISTORTION_CALIBRATION_DATA.setInitialOrientation(overwriteAll); // needed here? modify?
if (overwriteAll) DISTORTION_CALIBRATION_DATA.setInitialOrientation(PATTERN_PARAMETERS, overwriteAll); // needed here? modify?
if ((DEBUG_LEVEL>0) && (DISTORTION_CALIBRATION_DATA.gIS!=null)){
System.out.println("There are now "+DISTORTION_CALIBRATION_DATA.getNumberOfEstimated(true)+ "("+DISTORTION_CALIBRATION_DATA.getNumberOfEstimated(false)+") images with estimated orientation");
}
......@@ -6255,7 +6255,7 @@ if (MORE_BUTTONS) {
/* ======================================================================== */
if (label.equals("Get Orientation")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (DEBUG_LEVEL>0){
if (DEBUG_LEVEL>10) { // 0){
IJ.showMessage("disabled option");
return;
}
......@@ -6278,11 +6278,22 @@ if (MORE_BUTTONS) {
System.out.println("GONIOMETER was initialized");
}
// initialize needed classes
if (DISTORTION_CALIBRATION_DATA == null ) {
System.out.println("Initiaslizing DISTORTION_CALIBRATION_DATA");
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // images are not setup yet
EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters
GONIOMETER_PARAMETERS);
} else if (DEBUG_LEVEL>1){
System.out.println("DISTORTION_CALIBRATION_DATA was initialized");
}
if ((LENS_DISTORTIONS!=null) && (LENS_DISTORTIONS.fittingStrategy!=null)) {
LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData=DISTORTION_CALIBRATION_DATA;
if (DEBUG_LEVEL>0){
System.out.println("Setting LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData=DISTORTION_CALIBRATION_DATA");
}
} else if (DEBUG_LEVEL>0){
System.out.println("Was already set: LENS_DISTORTIONS.fittingStrategy.distortionCalibrationData=DISTORTION_CALIBRATION_DATA");
}
if (DEBUG_LEVEL>1){
......@@ -6301,9 +6312,10 @@ if (MORE_BUTTONS) {
IJ.showMessage("Error",msg);
return;
}
LENS_DISTORTIONS=new Distortions(LENS_DISTORTION_PARAMETERS,PATTERN_PARAMETERS,REFINE_PARAMETERS,this.SYNC_COMMAND.stopRequested);
if (DEBUG_LEVEL>1){
System.out.println("Initiaslizing Distortions class");
System.out.println("Initiaslizing Distortions class (LENS_DISTORTIONS)");
}
} else if (DEBUG_LEVEL>1){
System.out.println("LENS_DISTORTIONS was initialized");
......@@ -6324,6 +6336,9 @@ if (MORE_BUTTONS) {
return;
}
GONIOMETER_PARAMETERS.gridGeometryFile=gridPathname;
if (DEBUG_LEVEL > 0){
System.out.println("Using pattern file: "+gridPathname);
}
// Find curernt orientation
double [] currentOrientation=GONIOMETER.estimateOrientation (
......@@ -9871,7 +9886,22 @@ if (MORE_BUTTONS) {
PATTERN_PARAMETERS.debugLevel=MASTER_DEBUG_LEVEL;
EYESIS_CAMERA_PARAMETERS.updateNumstations (numStations);
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // new way for LWIR - initialize form dirs
// Adding class here to use for orientation estimation - will not be needed?
if (GONIOMETER==null) {
GONIOMETER= new Goniometer(
CAMERAS, // CalibrationHardwareInterface.CamerasInterface cameras,
DISTORTION, //MatchSimulatedPattern.DistortionParameters distortion,
PATTERN_DETECT, //MatchSimulatedPattern.PatternDetectParameters patternDetectParameters,
EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters,
LASER_POINTERS, // MatchSimulatedPattern.LaserPointer laserPointers
SIMUL, //SimulationPattern.SimulParameters simulParametersDefault,
GONIOMETER_PARAMETERS, //LensAdjustment.FocusMeasurementParameters focusMeasurementParameters,
DISTORTION_PROCESS_CONFIGURATION
);
}
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // new way for LWIR - initialize from dirs
gridFileDirs,
sourceStationDirs,
gridFilter,
......@@ -9889,7 +9919,7 @@ if (MORE_BUTTONS) {
);
// set initial orientation of the cameras from the sensors that see most of the matching pointers
// just for the LMA to start
DISTORTION_CALIBRATION_DATA.setInitialOrientation(true);
DISTORTION_CALIBRATION_DATA.setInitialOrientation(PATTERN_PARAMETERS, true);
return true;
......@@ -771,7 +771,7 @@ horizontal axis:
throw new IllegalArgumentException(msg);
}
// remove unneeded, copied from updateFocusGrid()
// remove unneeded, copied from updateFocusGrid() Now it is not needed?
SimulationPattern.SimulParameters simulParameters = modifySimulParameters();
MatchSimulatedPattern.DistortionParameters distortionParameters = modifyDistortionParameters();
......@@ -1007,6 +1007,10 @@ horizontal axis:
};
return result;
}
public static class GoniometerParameters {
public String gridGeometryFile="";
public String initialCalibrationFile="";
......
......@@ -6818,8 +6818,11 @@ public class MatchSimulatedPattern {
numPointerDetected++;
}
}
if (numPointerDetected>0) return pointersXY;
else return null;
if (numPointerDetected>0) {
return pointersXY;
} else {
return null;
}
}
public static void setPointersXYUV(ImagePlus imp, double [][] pointersXYUV){
......
......@@ -739,6 +739,7 @@ import ij.io.Opener;
int [] iUV={u1-this.U0, v1-this.V0};
return iUV;
}
public double[] getXYZM(int u, int v, boolean verbose, int station){ // u=0,v=0 - center!
int u1=u+this.U0;
int v1=v+this.V0;
......@@ -761,6 +762,31 @@ import ij.io.Opener;
return result;
// return this.gridGeometry[v1][u1];
}
public double[] getXYZ(
double [] uv,
boolean verbose,
int station){ // u=0,v=0 - center!
int iu = (int) Math.floor(uv[0]);
int iv = (int) Math.floor(uv[1]);
double fu = uv[0] - iu;
double fv = uv[1] - iv;
double [][] corn = new double [4][];
corn[0] = getXYZM(iu, iv, verbose, station);
corn[1] = getXYZM(iu + 1, iv, verbose, station);
corn[2] = getXYZM(iu, iv + 1, verbose, station);
corn[3] = getXYZM(iu + 1, iv + 1, verbose, station);
if ((corn[0] == null) || (corn[1] == null) || (corn[2] == null) || (corn[3] == null)) {
System.out.println("Optical axis outside of te grid: TODO: modify getXYZM() to handle!");
return null;
}
double [] rslt_xyz = new double[3];
rslt_xyz[0] = (1-fu) * (1-fv) * corn[0][0] + fu * (1-fv) * corn[1][0] + (1-fu) * fv * corn[2][0] + fu * fv * corn[3][0];
rslt_xyz[1] = (1-fu) * (1-fv) * corn[0][1] + fu * (1-fv) * corn[1][1] + (1-fu) * fv * corn[2][1] + fu * fv * corn[3][1];
rslt_xyz[2] = (1-fu) * (1-fv) * corn[0][2] + fu * (1-fv) * corn[1][2] + (1-fu) * fv * corn[2][2] + fu * fv * corn[3][2];
return rslt_xyz;
}
public int getGridIndex(int u, int v){ // u=0,v=0 - center!
int u1=u+this.U0;
int v1=v+this.V0;
......
......@@ -665,8 +665,13 @@ public class LwirReader {
"&TRIG_BITLENGTH=31*0"+
"&EXTERN_TIMESTAMP=1*0";
}
if (lrp.eo_full_window) {
urls[num_lwir+chn] +=
"&WOI_LEFT=0"+
"&WOI_TOP=0"+
"&WOI_WIDTH=2592"+
"&WOI_HEIGHT=1936";
}
}
for (int i = 0; i < urls.length; i++) {
LOGGER.debug("programLWIRCamera(): reading url " + urls[i]);
......
......@@ -45,6 +45,7 @@ public class LwirReaderParameters {
protected int [] lwir_channels = {0, 1, 2 ,3};
protected int [] eo_channels = {0, 1, 2 ,3};
protected boolean lwir_telemetry = true;
protected boolean eo_full_window = true;
protected double eo_quality = 98.0;
protected boolean eo_scale = false; // restore sensor pixel values, undo camera white balancing
protected boolean eo_autoexp = false;
......@@ -119,6 +120,7 @@ public class LwirReaderParameters {
properties.setProperty(prefix+"lwir_channels", arr_to_str(this.lwir_channels));
properties.setProperty(prefix+"eo_channels", arr_to_str(this.eo_channels));
properties.setProperty(prefix+"lwir_telemetry", this.lwir_telemetry+"");
properties.setProperty(prefix+"eo_full_window", this.eo_full_window+"");
properties.setProperty(prefix+"eo_quality", this.eo_quality+"");
properties.setProperty(prefix+"eo_scale", this.eo_scale+"");
properties.setProperty(prefix+"eo_autoexp", this.eo_autoexp+"");
......@@ -137,7 +139,6 @@ public class LwirReaderParameters {
properties.setProperty(prefix+"debug_level", this.debug_level+"");
properties.setProperty(prefix+"selected_channels", arr_to_str(this.selected_channels));
properties.setProperty(prefix+"show_images", this.show_images+"");
}
public void getProperties(String prefix,Properties properties){
......@@ -164,6 +165,7 @@ public class LwirReaderParameters {
if (properties.getProperty(prefix+"lwir_channels")!=null) this.lwir_channels=str_to_iarr(properties.getProperty(prefix+"lwir_channels"));
if (properties.getProperty(prefix+"eo_channels")!=null) this.eo_channels=str_to_iarr(properties.getProperty(prefix+"eo_channels"));
if (properties.getProperty(prefix+"lwir_telemetry")!=null) this.lwir_telemetry= Boolean.parseBoolean(properties.getProperty(prefix+"lwir_telemetry"));
if (properties.getProperty(prefix+"eo_full_window")!=null) this.eo_full_window= Boolean.parseBoolean(properties.getProperty(prefix+"eo_full_window"));
if (properties.getProperty(prefix+"eo_quality")!=null) this.eo_quality=Double.parseDouble(properties.getProperty(prefix+"eo_quality"));
if (properties.getProperty(prefix+"eo_scale")!=null) this.eo_scale= Boolean.parseBoolean(properties.getProperty(prefix+"eo_scale"));
if (properties.getProperty(prefix+"eo_autoexp")!=null) this.eo_autoexp= Boolean.parseBoolean(properties.getProperty(prefix+"eo_autoexp"));
......@@ -195,6 +197,7 @@ public class LwirReaderParameters {
lrp.lwir_channels= this.lwir_channels.clone();
lrp.eo_channels= this.eo_channels.clone();
lrp.lwir_telemetry= this.lwir_telemetry;
lrp.eo_full_window= this.eo_full_window;
lrp.eo_quality= this.eo_quality;
lrp.eo_scale= this.eo_scale;
lrp.eo_autoexp= this.eo_autoexp;
......@@ -233,6 +236,7 @@ public class LwirReaderParameters {
(java.util.Arrays.equals(lrp.lwir_channels, this.lwir_channels)) &&
(java.util.Arrays.equals(lrp.eo_channels, this.eo_channels)) &&
(lrp.lwir_telemetry == this.lwir_telemetry) &&
(lrp.eo_full_window == this.eo_full_window) &&
(lrp.eo_quality == this.eo_quality) &&
(lrp.eo_scale == this.eo_scale) &&
(lrp.eo_autoexp == this.eo_autoexp) &&
......@@ -265,6 +269,7 @@ public class LwirReaderParameters {
result = prime * result + arr_to_str(lwir_channels).hashCode();
result = prime * result + arr_to_str(eo_channels).hashCode();
result = prime * result + (lwir_telemetry?1:0);
result = prime * result + (eo_full_window?1:0);
result = prime * result + (new Double(eo_quality)).hashCode();
result = prime * result + (eo_scale?1:0);
result = prime * result + (eo_autoexp?1:0);
......@@ -293,10 +298,11 @@ public class LwirReaderParameters {
gd.addStringField ("EO IP", this.eo_ip, 20, "Visible range high resolution camera IP address");
gd.addStringField ("LWIR channels", arr_to_str(this.lwir_channels), 20, "Space-separated list of used LWIR camera channels, such as '0 1 2 3'");
gd.addStringField ("EO channels", arr_to_str(this.eo_channels), 20, "Space-separated list of used visible range camera channels, such as '0 1 2 3'");
gd.addCheckbox ("LWIR telemetry", this.lwir_telemetry, "Set LWIR sesnors to provide telemetry data in the last 2 lines (may become mandatory later)");
gd.addCheckbox ("LWIR telemetry",this.lwir_telemetry, "Set LWIR sesnors to provide telemetry data in the last 2 lines (may become mandatory later)");
gd.addCheckbox ("EO full window",this.eo_full_window, "Set EO to full window, disregarding preset margins (need reset to restore original)");
gd.addNumericField("EO quality", this.eo_quality, 3,6,"%", "Visible range camera JPEG compression quality (all channels)");
gd.addCheckbox ("EO undo white balance", this.eo_scale, "Undo in-camera white balancing");
gd.addCheckbox ("EO autoexposure", this.eo_autoexp, "Enable autoexposure for the visible range camera");
gd.addCheckbox ("EO autoexposure",this.eo_autoexp, "Enable autoexposure for the visible range camera");
gd.addNumericField("EO eo_max_autoexp_ms", this.eo_max_autoexp_ms, 3,6,"ms", "Visible range camera maximal exposure in autoexposure mode");
gd.addNumericField("EO exposure", this.eo_exposure_ms, 3,6,"ms", "Visible range camera exposure time (all channels)");
gd.addCheckbox ("EO white balance", this.eo_whitebal, "Enable automatic white balancing for the visible range camera");
......@@ -323,6 +329,7 @@ public class LwirReaderParameters {
this.lwir_channels = str_to_iarr(gd.getNextString());
this.eo_channels = str_to_iarr(gd.getNextString());
this.lwir_telemetry = gd.getNextBoolean();
this.eo_full_window = gd.getNextBoolean();
this.eo_quality = gd.getNextNumber();
this.eo_scale = gd.getNextBoolean();
this.eo_autoexp = gd.getNextBoolean();
......@@ -346,7 +353,7 @@ public class LwirReaderParameters {
public boolean showJDialog() {
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",800,900);
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set LWIR/EO parameters",800,900);
// gd.addTab ("General", "General parameters");
dialogQuestions(gd);
gd.showDialog();
......
......@@ -3378,15 +3378,52 @@ public class QuadCLT {
}
/// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
float [] vign_pixels = eyesisCorrections.channelVignettingCorrection[srcChannel];
if (pixels.length!=vign_pixels.length){
// System.out.println("Vignetting data for channel "+srcChannel+" has "+vign_pixels.length+" pixels, image "+sourceFiles[nFile]+" has "+pixels.length);
int woi_width = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_WIDTH"));
int woi_height = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_HEIGHT"));
int woi_top = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
int woi_left = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_LEFT"));
int vign_width = eyesisCorrections.pixelMapping.sensors[srcChannel].pixelCorrectionWidth;
int vign_height = eyesisCorrections.pixelMapping.sensors[srcChannel].pixelCorrectionHeight;
if (pixels.length != woi_width * woi_height){
System.out.println("Vignetting data for channel "+srcChannel+" has "+vign_pixels.length+" pixels, < "+
sourceFiles[nFile]+" has "+pixels.length);
woi_width = width;
woi_height = height;
}
if (vign_width < (woi_left + woi_width)) {
System.out.println("Vignetting data for channel "+srcChannel+
" has width + left ("+(woi_left+woi_width)+") > vign_width ("+vign_width+")");
return null;
}
if (vign_height < (woi_top + woi_height)) {
System.out.println("Vignetting data for channel "+srcChannel+
" has height + top ("+(woi_top+woi_height)+") > vign_height ("+vign_width+")");
return null;
}
if (pixels.length != woi_width * woi_height){
System.out.println("Vignetting data for channel "+srcChannel+" has "+vign_pixels.length+" pixels, < "+
sourceFiles[nFile]+" has "+pixels.length);
return null;
}
vign_pixels = new float[woi_width * woi_height];
for (int row = 0; row < woi_height; row++) {
System.arraycopy(
eyesisCorrections.channelVignettingCorrection[srcChannel], // src
(woi_top + row) * vign_width + woi_left, // srcPos,
vign_pixels, // dest,
row * woi_width, // destPos,
woi_width); // length);
}
if (pixels.length!=eyesisCorrections.channelVignettingCorrection[srcChannel].length){
System.out.println("Vignetting data for channel "+srcChannel+" has "+eyesisCorrections.channelVignettingCorrection[srcChannel].length+" pixels, image "+sourceFiles[nFile]+" has "+pixels.length);
return null; // not used in lwir
}
// TODO: Move to do it once:
double min_non_zero = 0.0;
for (int i=0;i<pixels.length;i++){
double d = eyesisCorrections.channelVignettingCorrection[srcChannel][i];
double d = vign_pixels[i];
if ((d > 0.0) && ((min_non_zero == 0) || (min_non_zero > d))){
min_non_zero = d;
}
......@@ -3395,7 +3432,7 @@ public class QuadCLT {
System.out.println("Vignetting data: channel="+srcChannel+", min = "+min_non_zero);
for (int i=0;i<pixels.length;i++){
double d = eyesisCorrections.channelVignettingCorrection[srcChannel][i];
double d = vign_pixels[i];
if (d > max_vign_corr) d = max_vign_corr;
pixels[i]*=d;
}
......
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