Commit 3a3ced75 authored by Andrey Filippov's avatar Andrey Filippov

next snapshot

parent 5a110e1d
...@@ -840,6 +840,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -840,6 +840,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addButton("Aux Build Series", panelLWIRWorld, color_stop); addButton("Aux Build Series", panelLWIRWorld, color_stop);
addButton("Build World", panelLWIRWorld, color_process); addButton("Build World", panelLWIRWorld, color_process);
addButton("Test IMX5", panelLWIRWorld, color_process); addButton("Test IMX5", panelLWIRWorld, color_process);
addButton("Show mice", panelLWIRWorld, color_process);
plugInFrame.add(panelLWIRWorld); plugInFrame.add(panelLWIRWorld);
} }
...@@ -5665,6 +5666,12 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -5665,6 +5666,12 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
return; return;
//JTabbedTest //JTabbedTest
// End of buttons code // End of buttons code
} else if (label.equals("Show mice")) {
DEBUG_LEVEL = MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
ImagePlus imp_src = WindowManager.getCurrentImage();
ImagePlus imp_mice = subtractAverage(imp_src);
imp_mice.show();
} }
} }
...@@ -8443,7 +8450,42 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -8443,7 +8450,42 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
} }
return true; return true;
} }
public static ImagePlus subtractAverage(ImagePlus imp_src) {
ImagePlus imp_rslt = null;
int num_img = imp_src.getStackSize();
int width = imp_src.getWidth();
int height = imp_src.getHeight();
ImageStack stack = imp_src.getStack();
// Simple version - global average
int [] num_pix = new int [width*height];
double [] sum_pix = new double [width*height];
double [][] out_pix = new double [num_img][sum_pix.length];
for (int nslice = 0; nslice < num_img; nslice++) {
float [] fpix = (float[]) stack.getPixels(nslice + 1);
Arrays.fill(out_pix[nslice], Double.NaN);
for (int i = 0; i < fpix.length; i++) if (!Float.isNaN(fpix[i])) {
double d = fpix[i];
out_pix[nslice][i] = d;
sum_pix[i]+= d;
num_pix[i]++;
}
}
for (int i = 0; i < sum_pix.length; i++) {
if (num_pix[i] > 0) {
sum_pix[i] /= num_pix[i];
} else {
sum_pix[i] = Double.NaN;
}
}
for (int nslice = 0; nslice < num_img; nslice++) {
for (int i = 0; i < sum_pix.length; i++) {
out_pix[nslice][i] -= sum_pix[i];
}
}
ImageStack out_stack = ShowDoubleFloatArrays.makeStack(out_pix, width, height);
imp_rslt = new ImagePlus(imp_src.getTitle() + "-motion", out_stack);
return imp_rslt;
}
public ImagePlus selectCLTImage() { public ImagePlus selectCLTImage() {
if (!CLT_PARAMETERS.showJDialog()) if (!CLT_PARAMETERS.showJDialog())
return null; return null;
......
...@@ -114,11 +114,13 @@ public class IntersceneMatchParameters { ...@@ -114,11 +114,13 @@ public class IntersceneMatchParameters {
public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation
public int min_num_orient = 2; // make from parameters, should be >= 1 public int min_num_orient = 2; // make from parameters, should be >= 1
public int min_num_interscene = 2; // make from parameters, should be >= 1 public int min_num_interscene = 2; // make from parameters, should be >= 1
public boolean adjust_imu_orient = false;// adjust IMU misalignment to the camera public boolean adjust_imu_orient = false; // adjust IMU misalignment to the camera
public boolean apply_imu_orient = true; // apply IMU misalignment to the camera if adjusted public boolean apply_imu_orient = true; // apply IMU misalignment to the camera if adjusted
public boolean adjust_gyro = false;// adjust qyro omegas offsets public boolean orient_by_move = false; // use translation data to adjust IMU orientation
public boolean orient_by_rot = true; // use rotation data to adjust IMU orientation
public boolean adjust_gyro = false; // adjust qyro omegas offsets
public boolean apply_gyro = true; // apply adjusted qyro omegas offsets public boolean apply_gyro = true; // apply adjusted qyro omegas offsets
public boolean adjust_accl = false;// adjust IMU velocities scales public boolean adjust_accl = false; // adjust IMU velocities scales
public boolean apply_accl = true; // apply IMU velocities scales public boolean apply_accl = true; // apply IMU velocities scales
public boolean calc_quat_corr = true; // calculate camera orientation correction from predicted by IMS public boolean calc_quat_corr = true; // calculate camera orientation correction from predicted by IMS
...@@ -673,6 +675,10 @@ public class IntersceneMatchParameters { ...@@ -673,6 +675,10 @@ public class IntersceneMatchParameters {
"Adjust IMU misalignment to the camera."); "Adjust IMU misalignment to the camera.");
gd.addCheckbox ("Adjust IMU orientation", this.apply_imu_orient, gd.addCheckbox ("Adjust IMU orientation", this.apply_imu_orient,
"Apply IMU misalignment to the camera if adjusted."); "Apply IMU misalignment to the camera if adjusted.");
gd.addCheckbox ("Use translation for IMU orientation", this.orient_by_move,
"Use translation data to adjust IMU orientation .");
gd.addCheckbox ("Use rotation for IMU orientation", this.orient_by_rot,
"Use rotation data to adjust IMU orientation.");
gd.addCheckbox ("Adjust gyro offsets", this.adjust_gyro, gd.addCheckbox ("Adjust gyro offsets", this.adjust_gyro,
"Adjust qyro omegas offsets."); "Adjust qyro omegas offsets.");
gd.addCheckbox ("Apply gyro offsets", this.apply_gyro, gd.addCheckbox ("Apply gyro offsets", this.apply_gyro,
...@@ -1480,6 +1486,8 @@ public class IntersceneMatchParameters { ...@@ -1480,6 +1486,8 @@ public class IntersceneMatchParameters {
this.min_num_interscene = (int) gd.getNextNumber(); if (min_num_interscene < 1) min_num_interscene = 1; this.min_num_interscene = (int) gd.getNextNumber(); if (min_num_interscene < 1) min_num_interscene = 1;
this.adjust_imu_orient = gd.getNextBoolean(); this.adjust_imu_orient = gd.getNextBoolean();
this.apply_imu_orient = gd.getNextBoolean(); this.apply_imu_orient = gd.getNextBoolean();
this.orient_by_move = gd.getNextBoolean();
this.orient_by_rot = gd.getNextBoolean();
this.adjust_gyro = gd.getNextBoolean(); this.adjust_gyro = gd.getNextBoolean();
this.apply_gyro = gd.getNextBoolean(); this.apply_gyro = gd.getNextBoolean();
this.adjust_accl = gd.getNextBoolean(); this.adjust_accl = gd.getNextBoolean();
...@@ -1925,6 +1933,8 @@ public class IntersceneMatchParameters { ...@@ -1925,6 +1933,8 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"min_num_interscene", this.min_num_interscene+""); // int properties.setProperty(prefix+"min_num_interscene", this.min_num_interscene+""); // int
properties.setProperty(prefix+"adjust_imu_orient", this.adjust_imu_orient+""); // boolean properties.setProperty(prefix+"adjust_imu_orient", this.adjust_imu_orient+""); // boolean
properties.setProperty(prefix+"apply_imu_orient", this.apply_imu_orient+""); // boolean properties.setProperty(prefix+"apply_imu_orient", this.apply_imu_orient+""); // boolean
properties.setProperty(prefix+"orient_by_move", this.orient_by_move+""); // boolean
properties.setProperty(prefix+"orient_by_rot", this.orient_by_rot+""); // boolean
properties.setProperty(prefix+"adjust_gyro", this.adjust_gyro+""); // boolean properties.setProperty(prefix+"adjust_gyro", this.adjust_gyro+""); // boolean
properties.setProperty(prefix+"apply_gyro", this.apply_gyro+""); // boolean properties.setProperty(prefix+"apply_gyro", this.apply_gyro+""); // boolean
properties.setProperty(prefix+"adjust_accl", this.adjust_accl+""); // boolean properties.setProperty(prefix+"adjust_accl", this.adjust_accl+""); // boolean
...@@ -2333,13 +2343,12 @@ public class IntersceneMatchParameters { ...@@ -2333,13 +2343,12 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"min_num_interscene")!=null) this.min_num_interscene=Integer.parseInt(properties.getProperty(prefix+"min_num_interscene")); if (properties.getProperty(prefix+"min_num_interscene")!=null) this.min_num_interscene=Integer.parseInt(properties.getProperty(prefix+"min_num_interscene"));
if (properties.getProperty(prefix+"adjust_imu_orient")!=null) this.adjust_imu_orient=Boolean.parseBoolean(properties.getProperty(prefix+"adjust_imu_orient")); if (properties.getProperty(prefix+"adjust_imu_orient")!=null) this.adjust_imu_orient=Boolean.parseBoolean(properties.getProperty(prefix+"adjust_imu_orient"));
if (properties.getProperty(prefix+"apply_imu_orient")!=null) this.apply_imu_orient=Boolean.parseBoolean(properties.getProperty(prefix+"apply_imu_orient")); if (properties.getProperty(prefix+"apply_imu_orient")!=null) this.apply_imu_orient=Boolean.parseBoolean(properties.getProperty(prefix+"apply_imu_orient"));
if (properties.getProperty(prefix+"orient_by_move")!=null) this.orient_by_move=Boolean.parseBoolean(properties.getProperty(prefix+"orient_by_move"));
if (properties.getProperty(prefix+"orient_by_rot")!=null) this.orient_by_rot=Boolean.parseBoolean(properties.getProperty(prefix+"orient_by_rot"));
if (properties.getProperty(prefix+"adjust_gyro")!=null) this.adjust_gyro=Boolean.parseBoolean(properties.getProperty(prefix+"adjust_gyro")); if (properties.getProperty(prefix+"adjust_gyro")!=null) this.adjust_gyro=Boolean.parseBoolean(properties.getProperty(prefix+"adjust_gyro"));
if (properties.getProperty(prefix+"apply_gyro")!=null) this.apply_gyro=Boolean.parseBoolean(properties.getProperty(prefix+"apply_gyro")); if (properties.getProperty(prefix+"apply_gyro")!=null) this.apply_gyro=Boolean.parseBoolean(properties.getProperty(prefix+"apply_gyro"));
if (properties.getProperty(prefix+"adjust_accl")!=null) this.adjust_accl=Boolean.parseBoolean(properties.getProperty(prefix+"adjust_accl")); if (properties.getProperty(prefix+"adjust_accl")!=null) this.adjust_accl=Boolean.parseBoolean(properties.getProperty(prefix+"adjust_accl"));
if (properties.getProperty(prefix+"apply_accl")!=null) this.apply_accl=Boolean.parseBoolean(properties.getProperty(prefix+"apply_accl")); if (properties.getProperty(prefix+"apply_accl")!=null) this.apply_accl=Boolean.parseBoolean(properties.getProperty(prefix+"apply_accl"));
if (properties.getProperty(prefix+"calc_quat_corr")!=null) this.calc_quat_corr=Boolean.parseBoolean(properties.getProperty(prefix+"calc_quat_corr")); if (properties.getProperty(prefix+"calc_quat_corr")!=null) this.calc_quat_corr=Boolean.parseBoolean(properties.getProperty(prefix+"calc_quat_corr"));
if (properties.getProperty(prefix+"apply_quat_corr")!=null) this.apply_quat_corr=Boolean.parseBoolean(properties.getProperty(prefix+"apply_quat_corr")); if (properties.getProperty(prefix+"apply_quat_corr")!=null) this.apply_quat_corr=Boolean.parseBoolean(properties.getProperty(prefix+"apply_quat_corr"));
if (properties.getProperty(prefix+"use_quat_corr")!=null) this.use_quat_corr=Boolean.parseBoolean(properties.getProperty(prefix+"use_quat_corr")); if (properties.getProperty(prefix+"use_quat_corr")!=null) this.use_quat_corr=Boolean.parseBoolean(properties.getProperty(prefix+"use_quat_corr"));
...@@ -2771,6 +2780,8 @@ public class IntersceneMatchParameters { ...@@ -2771,6 +2780,8 @@ public class IntersceneMatchParameters {
imp.min_num_interscene = this.min_num_interscene; imp.min_num_interscene = this.min_num_interscene;
imp.adjust_imu_orient = this.adjust_imu_orient; imp.adjust_imu_orient = this.adjust_imu_orient;
imp.apply_imu_orient = this.apply_imu_orient; imp.apply_imu_orient = this.apply_imu_orient;
imp.orient_by_move = this.orient_by_move;
imp.orient_by_rot = this.orient_by_rot;
imp.adjust_gyro = this.adjust_gyro; imp.adjust_gyro = this.adjust_gyro;
imp.apply_gyro = this.apply_gyro; imp.apply_gyro = this.apply_gyro;
imp.adjust_accl = this.adjust_accl; imp.adjust_accl = this.adjust_accl;
......
...@@ -414,7 +414,7 @@ public class QuadCLTCPU { ...@@ -414,7 +414,7 @@ public class QuadCLTCPU {
Rotation ims_atr = new Rotation(RotationOrder.YXZ, ErsCorrection.ROT_CONV, Rotation ims_atr = new Rotation(RotationOrder.YXZ, ErsCorrection.ROT_CONV,
ims_xyzatr[nscene][1][0], ims_xyzatr[nscene][1][1], ims_xyzatr[nscene][1][2]); ims_xyzatr[nscene][1][0], ims_xyzatr[nscene][1][1], ims_xyzatr[nscene][1][2]);
Rotation rotation_atr,rotation_atr2; Rotation rotation_atr,rotation_atr2;
if (use_inv) { if (use_inv) { // should not be used
rotation_atr = rot_invert.applyTo(ims_atr); rotation_atr = rot_invert.applyTo(ims_atr);
rotation_atr2 = rotation_atr.applyTo(rot); // applyInverseTo? rotation_atr2 = rotation_atr.applyTo(rot); // applyInverseTo?
} else { } else {
...@@ -464,6 +464,12 @@ public class QuadCLTCPU { ...@@ -464,6 +464,12 @@ public class QuadCLTCPU {
int last_index, int last_index,
int debugLevel int debugLevel
) { ) {
boolean orient_by_move = clt_parameters.imp.orient_by_move; // use translation data to adjust IMU orientation
boolean orient_by_rot = clt_parameters.imp.orient_by_rot; // use rotation data to adjust IMU orientation
if (!orient_by_move && !orient_by_rot) {
System.out.println("Neither translation nor rotation data are enabled to adjust IMU orientation relative to the camera");
return;
}
boolean apply_imu_orient = clt_parameters.imp.apply_imu_orient; // apply IMU misalignment to the camera if adjusted boolean apply_imu_orient = clt_parameters.imp.apply_imu_orient; // apply IMU misalignment to the camera if adjusted
boolean adjust_gyro = clt_parameters.imp.adjust_gyro; // adjust qyro omegas offsets boolean adjust_gyro = clt_parameters.imp.adjust_gyro; // adjust qyro omegas offsets
boolean apply_gyro = clt_parameters.imp.apply_gyro; // apply adjusted qyro omegas offsets boolean apply_gyro = clt_parameters.imp.apply_gyro; // apply adjusted qyro omegas offsets
...@@ -490,7 +496,12 @@ public class QuadCLTCPU { ...@@ -490,7 +496,12 @@ public class QuadCLTCPU {
int quat_lma_mode = QuaternionLma.MODE_XYZQ; // MODE_XYZ4Q3; // MODE_XYZQ; // MODE_XYZQ_LOCAL; // 4; // 3; // 2; // 1; int quat_lma_mode = QuaternionLma.MODE_XYZQ; // MODE_XYZ4Q3; // MODE_XYZQ; // MODE_XYZQ_LOCAL; // 4; // 3; // 2; // 1;
int debug_lev = debugLevel; // 3; int debug_lev = debugLevel; // 3;
double avg_z = quadCLTs[ref_index].getAverageZ(true); // in meters double avg_z = quadCLTs[ref_index].getAverageZ(true); // in meters
double translation_weight = 0.0; // 1.0 / (avg_z + 1.0); double translation_weight = 1.0 / (avg_z + 1.0);
if (!orient_by_move) {
translation_weight = 0.0;
} else if (!orient_by_rot) {
translation_weight = 1.0;
}
double [][][] rotated_xyzatr = QuadCLT.rotateImsToCameraXYZ( double [][][] rotated_xyzatr = QuadCLT.rotateImsToCameraXYZ(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quat_lma_mode, // int quat_lma_mode, quat_lma_mode, // int quat_lma_mode,
......
...@@ -224,7 +224,7 @@ public class QuaternionLma { ...@@ -224,7 +224,7 @@ public class QuaternionLma {
//MODE_XYZQ //MODE_XYZQ
N = vect_x.length; N = vect_x.length;
this.mode = mode; this.mode = mode;
samples = 3+ quat0.length; samples = 3 + quat0.length;
samples_x = 7; samples_x = 7;
pure_weight = 1.0 - reg_w; pure_weight = 1.0 - reg_w;
int extra_samples = (reg_w > 0) ? quat0.length:0; // (quat0.length < 4)? 0:REGLEN; int extra_samples = (reg_w > 0) ? quat0.length:0; // (quat0.length < 4)? 0:REGLEN;
......
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