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
DISTORTION_CALIBRATION_DATA=new DistortionCalibrationData( // images are not setup yet
EYESIS_CAMERA_PARAMETERS, //EyesisCameraParameters eyesisCameraParameters
GONIOMETER_PARAMETERS);
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,10 +6336,13 @@ 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 (
CAMERAS.getImages(1), // last acquired images with number of pointers detected>0
CAMERAS.getImages(1), // last acquired images with number of pointers detected>0
DISTORTION_CALIBRATION_DATA, // DistortionCalibrationData distortionCalibrationData,
PATTERN_PARAMETERS, //PatternParameters patternParameters, // should not be null
LENS_DISTORTIONS, //Distortions lensDistortions, // should not be null
......@@ -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;
......
......@@ -77,7 +77,7 @@ public class LwirReader {
public static final int MAX_THREADS = 100; // combine from all classes?
public static final int FRAMES_AHEAD = 5;
/** Logger for this class. */
private static final Logger LOGGER =
LoggerFactory.getLogger(LwirReader.class);
......@@ -568,7 +568,7 @@ public class LwirReader {
fs.saveAsTiff(path);
}
}
if (lrp.isShowImages()) {
if (imps_avg != null) {
for (ImagePlus imp: imps_avg) {
......@@ -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]);
......
......@@ -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