Commit 30330dd5 authored by Andrey Filippov's avatar Andrey Filippov

Intermediate, not all tested, updated line time for Boson

parent 8406092c
......@@ -7386,7 +7386,7 @@ List calibration
if (subCam.pixelSize < 5.0) {
subCam.pixelSize=3.638E-5;
} else if (distortionCalibrationData.eyesisCameraParameters.getSensorWidth(numSensor) == 640){ // Boson
subCam.lineTime = 2.7778e-05; // 12um pixel, Boson
subCam.lineTime = 3.2552e-05; // 2.7778e-05; // 12um pixel, Boson
} else {
subCam.lineTime = 7.8e-05; // 12um pixel, Lepton (may7 be wrong)
}
......
......@@ -16383,7 +16383,7 @@ public class PixelMapping {
if (this.pixelSize < 5.0) {
this.lineTime = 3.638E-5;
} else if (this.pixelCorrectionWidth == 640){ // Boson
this.lineTime = 2.7778e-05; // 12um pixel, Boson
this.lineTime = 3.2552e-05; // 2.7778e-05; // 12um pixel, Boson
} else {
this.lineTime = 7.8e-05; // 12um pixel, Lepton (may7 be wrong)
}
......
......@@ -1148,7 +1148,7 @@ import ij.gui.GenericDialog;
gd.addNumericField("Camera roll, positive CW looking to the target",subCam.psi, 5,9,"degrees");
gd.addNumericField("Lens focal length", subCam.focalLength, 5,8,"mm");
gd.addNumericField("Sensor pixel period", subCam.pixelSize, 5,8,"um");
gd.addNumericField("Sensor line time (us): 36.38 5MPix, 27.778 Boson, 78(?) Lepton ", (1E6*subCam.lineTime), 5,8,"us");
gd.addNumericField("Sensor line time (us): 36.38 5MPix, 32.552 Boson, 78(?) Lepton ", (1E6*subCam.lineTime), 5,8,"us");
gd.addNumericField("Distortion radius (half width)", subCam.distortionRadius, 6,8,"mm");
gd.addNumericField("Distortion A8 (r^8)", subCam.distortionA8, 8,10,"");
gd.addNumericField("Distortion A7 (r^7)", subCam.distortionA7, 8,10,"");
......@@ -1448,7 +1448,7 @@ import ij.gui.GenericDialog;
if (eyesisSubCameras[nstation][ncam].pixelSize < 5.0) {
eyesisSubCameras[nstation][ncam].lineTime = 3.638E-5;
} else if (eyesisSubCameras[nstation][ncam].sensorWidth == 640){ // Boson
eyesisSubCameras[nstation][ncam].lineTime = 2.7778e-05; // 12um pixel, Boson
eyesisSubCameras[nstation][ncam].lineTime = 3.2552e-05; // 2.7778e-05; // 12um pixel, Boson
} else {
eyesisSubCameras[nstation][ncam].lineTime = 7.8e-05; // 12um pixel, Lepton (may be wrong)
}
......
......@@ -5088,7 +5088,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
QUAD_CLT_AUX.geometryCorrection.showRig();// show_fine_corr("aux");
System.out.println("=== IMS ===");
QUAD_CLT_AUX.showQuatCorr();
System.out.println("=== IMU ===");
QUAD_CLT_AUX.showPimuOffsets();
@SuppressWarnings("unused")
QuadCLT dbg_QUAD_CLT = QUAD_CLT;
@SuppressWarnings("unused")
......
......@@ -219,30 +219,18 @@ public class ErsCorrection extends GeometryCorrection {
private double [][] ers_atr; // azimuth-tilt-roll per scan line
private double [][] ers_atr_dt; // angular velocities per scan line. It is now actually 2*omega!
/*
static final double ERS_MIN_DISPARITY = 1.0E-6; // to avoid disparity == 0.0 in division
private double limitedReciprocal(double d) {
if (d > ERS_MIN_DISPARITY) return 1/0/d;
if (d < -ERS_MIN_DISPARITY) return 1/0/d;
if (d > 0) return 1.0/ERS_MIN_DISPARITY;
return -1.0/ERS_MIN_DISPARITY;
}
public static final int [] DP_XYZR_INDICES = {DP_DSX,DP_DSY,DP_DSZ,DP_DSRL};
public static final int [] DP_AT_INDICES = {DP_DSAZ,DP_DSTL};
public static final int [] DP_ATT_ERS_INDICES = {DP_DSVAZ,DP_DSVTL};
*/
public static boolean [] getParamSelect(
boolean use_XY,
boolean use_AT,
boolean use_ERS) {
boolean use_ERS,
boolean use_ERS_tilt) {
boolean [] param_select = new boolean[DP_NUM_PARS];
for (int i:DP_ZR_INDICES) param_select[i] = true;
if (use_XY) for (int i:DP_XY_INDICES) param_select[i] = true;
if (use_AT) for (int i:DP_AT_INDICES) param_select[i] = true;
if (use_ERS) for (int i:DP_ATT_ERS_INDICES) param_select[i] = true;
// if (use_ERS) for (int i:DP_ATT_ERS_INDICES) param_select[i] = true;
if (use_ERS) param_select[DP_DSVAZ] = true;
if (use_ERS && use_ERS_tilt) param_select[DP_DSVTL] = true;
return param_select;
}
public static double [] getParamRegWeights(
......
......@@ -4658,7 +4658,9 @@ public class OpticalFlow {
boolean calc_quat_corr = clt_parameters.imp.calc_quat_corr; // calculate camera orientation correction from predicted by IMS
// apply_quat_corr used inside getGroundIns() - used when generating output
// boolean apply_quat_corr = clt_parameters.imp.apply_quat_corr; // apply camera orientation correction from predicted by IMS
boolean use_ims_rotation = clt_parameters.imp.use_quat_corr; // use internally
boolean use_ims_rotation = clt_parameters.imp.use_quat_corr; // use internally (probably deprecated
boolean inertial_only = clt_parameters.imp.inertial_only; // use internally
boolean generate_egomotion = clt_parameters.imp.generate_egomotion; // generate egomotion table (image-based and ims)
boolean generate_mapped = clt_parameters.imp.generate_mapped &&
(gen_seq_mono_color[0] || gen_seq_mono_color[1]); // generate sequences - Tiff and/or video
......@@ -4989,7 +4991,8 @@ public class OpticalFlow {
if (center_reference) {
es1 = Interscene.setInitialOrientationsCenterIms(
clt_parameters, // final CLTParameters clt_parameters,
use_ims_rotation, // final boolean compensate_ims_rotation,
use_ims_rotation, // final boolean compensate_ims_rotation,
inertial_only, // final boolean inertial_only,
min_num_scenes, // int min_num_scenes,
colorProcParameters, // final ColorProcParameters colorProcParameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
......@@ -5016,7 +5019,8 @@ public class OpticalFlow {
} else if (ims_use) {
earliest_scene = Interscene.setInitialOrientationsIms(
clt_parameters, // final CLTParameters clt_parameters,
use_ims_rotation, // final boolean compensate_ims_rotation,
use_ims_rotation, // final boolean compensate_ims_rotation,
inertial_only, // final boolean inertial_only,
min_num_scenes, // int min_num_scenes,
colorProcParameters, // final ColorProcParameters colorProcParameters,
quadCLTs, // final QuadCLT[] quadCLTs, //
......@@ -5125,8 +5129,6 @@ public class OpticalFlow {
// just in case that orientations were calculated before:
// earliest_scene = getEarliestScene(quadCLTs);
// double [][] combo_dsn_final = null;
// below ref_index is not necessary the last (fix all where it is supposed to be the last
ErsCorrection ers_reference = quadCLTs[ref_index].getErsCorrection(); // only used in ml_export
while (!reuse_video && ((quadCLTs[ref_index].getNumOrient() < min_num_orient) || (quadCLTs[ref_index].getNumAccum() < min_num_interscene))) {
......@@ -5134,21 +5136,13 @@ public class OpticalFlow {
((quadCLTs[ref_index].getNumAccum() < quadCLTs[ref_index].getNumOrient())||
(quadCLTs[ref_index].getNumOrient() >= min_num_orient))) {
boolean done_sfm = false;
int mb_gain_index_depth = clt_parameters.imp.mb_gain_index_depth; // depth map refine pass (SfM) to switch to full mb_max_gain from mb_max_gain_inter
if (quadCLTs[ref_index].getNumAccum() > 0) {
double mb_max_gain = clt_parameters.imp.mb_max_gain;
if (quadCLTs[ref_index].getNumOrient() < (min_num_orient - 1)) {
if (quadCLTs[ref_index].getNumOrient() < mb_gain_index_depth) { // (min_num_orient - 1)) {
mb_max_gain = clt_parameters.imp.mb_max_gain_inter;
}
/*
done_sfm = StructureFromMotion.sfmPair_ref_debug(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs[ref_index], // final QuadCLT ref_scene,
quadCLTs[earliest_scene], // final QuadCLT scene,
mb_max_gain, // double mb_max_gain,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel)
*/
// int num_avg_pairs = 16; // number of scene pairs to average
int num_avg_pairs = clt_parameters.imp.sfm_num_pairs; // number of scene pairs to average
if (num_avg_pairs > ((last_index - earliest_scene)/2)) {
num_avg_pairs = (last_index - earliest_scene)/2;
......@@ -5162,7 +5156,7 @@ public class OpticalFlow {
// }
QuadCLT[][][] scenes_seq_pairs = new QuadCLT[3][num_avg_pairs][2];
int ref_index_mod1 = Math.max(ref_index, earliest_scene + num_avg_pairs - 1);
int ref_index_mod2 = Math.min(ref_index, last_index);
int ref_index_mod2 = Math.min(ref_index, last_index-num_avg_pairs + 1);
// TODO: calculate horizontal offset and compare with sfm_min_base
for (int i = 0; i < num_avg_pairs; i++) {
......@@ -5186,28 +5180,11 @@ public class OpticalFlow {
combo_dsn_final = sfm_dsn;
done_sfm = true;
}
/*
for (int num_seq = 0; num_seq < scenes_seq_pairs.length; num_seq++) {
double [][] sfm_dsn = StructureFromMotion.sfmPair(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs[ref_index], // final QuadCLT ref_scene,
scenes_seq_pairs[num_seq], // scenes_pairs, // final QuadCLT [][] scenes_pairs,
mb_max_gain, // double mb_max_gain,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel)
if (sfm_dsn != null) {
combo_dsn_final = sfm_dsn;
done_sfm = true;
}
}
*/
}
if (!done_sfm) { // first pass or sfm failed
// should skip scenes w/o orientation 06/29/2022
combo_dsn_final = intersceneExport( // result indexed by COMBO_DSN_TITLES, COMBO_DSN_INDX_***
clt_parameters, // CLTParameters clt_parameters,
// ers_reference, // ErsCorrection ers_reference,
ref_index, // int ref_index,
quadCLTs, // QuadCLT [] scenes,
colorProcParameters, // ColorProcParameters colorProcParameters,
......@@ -5260,12 +5237,6 @@ public class OpticalFlow {
}
}
// on last pass use final max MB correction same as for render (mb_max_gain - typical =5.0),
// for earlier - mb_max_gain_inter (which may be smaller - typical = 2.0)
double mb_max_gain = clt_parameters.imp.mb_max_gain;
if (quadCLTs[ref_index].getNumOrient() < (min_num_orient - 1)) {
mb_max_gain = clt_parameters.imp.mb_max_gain_inter;
}
// TODO: move to config
// boolean freeze_xy_pull = true; // false; // true; // debugging freezing xy to xy_pull
......@@ -5274,7 +5245,14 @@ public class OpticalFlow {
double avg_rlen = clt_parameters.imp.avg_len; // 3.0;
boolean readjust_xy_ims = true; // false;
double reg_weight_xy = 10.0; // 1.0; // 10.0; // 0.05; // TODO: find out reasonable values
boolean disable_ers = (quadCLTs[ref_index].getNumOrient() < 2); // first orient - no ERS!
int mb_ers_index = clt_parameters.imp.mb_ers_index;
int mb_ers_y_index = clt_parameters.imp.mb_ers_y_index;
int mb_gain_index_pose = clt_parameters.imp.mb_gain_index_pose; // pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter
boolean disable_ers = (quadCLTs[ref_index].getNumOrient() < mb_ers_index);
boolean disable_ers_y = (quadCLTs[ref_index].getNumOrient() < mb_ers_y_index);
boolean ers_from_ims = true; // false; // change later
int ers_mode = 0; // keep
// with IMS it is already set during initial orientation. In non-IMS mode
......@@ -5287,10 +5265,18 @@ public class OpticalFlow {
if (debugLevel > -3) {
System.out.println("ers_mode="+ers_mode);
}
// on last pass use final max MB correction same as for render (mb_max_gain - typical =5.0),
// for earlier - mb_max_gain_inter (which may be smaller - typical = 2.0)
double mb_max_gain = clt_parameters.imp.mb_max_gain;
if (quadCLTs[ref_index].getNumOrient() < mb_gain_index_pose) { // (min_num_orient - 1)) {
mb_max_gain = clt_parameters.imp.mb_max_gain_inter;
}
earliest_scene = Interscene.reAdjustPairsLMAInterscene( // after combo dsi is available and preliminary poses are known
clt_parameters, // CLTParameters clt_parameters,
mb_max_gain, // double mb_max_gain,
disable_ers, // boolean disable_ers,
disable_ers_y, // boolean disable_ers_y,
configured_lma, // boolean configured_lma,
lpf_xy, // boolean lpf_xy, // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables
avg_rlen, // double avg_rlen,
......
......@@ -193,6 +193,7 @@ public class QuadCLTCPU {
public Did_gps_pos did_gps1_ubx_pos = null;
public String ims_last_path = null;
public double [] quat_corr = null; // correction for IMS camera frame to actual camera frame (for reference frames)
public double [][] pimu_offsets = new double[2][3]; // linear and angular velocities offsets to DID_PIMU outputs (subtract from IMU data)
// public boolean quat_corr_active = false; // correction for IMS camera frame to actual camera frame (for reference frames)
// latest (or any? first also?) scene in a sequence has a timestamp of the reference scene
......@@ -211,6 +212,14 @@ public class QuadCLTCPU {
public void setQuatCorr(double[] quat) {
quat_corr = quat;
}
public double [][] getPimuOffsets() {
return pimu_offsets;
}
public void setPimuOffsets(double[][] offsets) {
pimu_offsets = offsets;
}
/**
* Refine scene poses (now only linear) from currently adjusted poses
......@@ -415,16 +424,19 @@ public class QuadCLTCPU {
/**
* Get linear and angular velocities (camera frame) from
* this scene IMS data
* this scene IMS/IMU data
* Omegas come from DID_PIMU, but linear velocities - from the DID_INS2 as DID_PIMU.vel
* seems not to be preintegrated, but are accelerations, not velocities
*
* Reorders [0][0] and [0][1], because A - around Y, T - around X, R - around Z
* @param clt_parameters configuration parameters (including
* scales from IMS to linear for linear and angular velocities
* @param scale if true, multiply by scales from he configuration parameters)
* @param pimu_offsets linear and angular velocities offsets - subtract from IMU outputs
* @return linear and angular velocities in camera frame
*/
protected double [][] getDxyzatrIms(
CLTParameters clt_parameters,
boolean scale) {
CLTParameters clt_parameters,
final double [][] pimu_offsets) {
double [] ims_ortho = clt_parameters.imp.ims_ortho;
double [] ims_mount_atr = clt_parameters.imp.getImsMountATR(); // converts to radians
double [] quat_ims_cam = Imx5.quaternionImsToCam(
......@@ -437,10 +449,10 @@ public class QuadCLTCPU {
double [] cam_datr = Imx5.applyQuaternionTo(quat_ims_cam, omegas, false);
// a (around Y),t (around X), r (around Z)
double [][] dxyzatr = new double [][] {cam_dxyz,{cam_datr[1],cam_datr[0],cam_datr[2]}};
if (scale) {
if (pimu_offsets != null) {
for (int i = 0; i < 3; i++) {
dxyzatr[0][i]*=clt_parameters.imp.ims_scale_xyz[i];
dxyzatr[1][i]*=clt_parameters.imp.ims_scale_atr[i];
dxyzatr[0][i] -= pimu_offsets[0][i];
dxyzatr[1][i] -= pimu_offsets[0][i];
}
}
return dxyzatr;
......@@ -452,18 +464,18 @@ public class QuadCLTCPU {
* @param clt_parameters configuration parameters (including
* scales from IMS to linear for linear and angular velocities
* @param quadCLTs array of scenes with IMS data loaded
* @param scale if true, multiply by scales from he configuration parameters)
* @param pimu_offsets - corrections to velocities and omegas, subtract from the raw IMU outputs
* @return linear and angular velocities in camera frame for each scene that has IMS data
*/
public static double [][][] getDxyzatrPIMU(
CLTParameters clt_parameters,
QuadCLT[] quadCLTs,
boolean scale) {
final double [][] pimu_offsets){
double [][][] dxyzatr = new double [quadCLTs.length][][];
for (int i = 0; i < quadCLTs.length; i++) if (quadCLTs[i] != null) {
dxyzatr[i] = quadCLTs[i].getDxyzatrIms(
clt_parameters,
scale);
pimu_offsets);
}
return dxyzatr;
}
......@@ -473,8 +485,8 @@ public class QuadCLTCPU {
final QuadCLT[] quadCLTs,
final int ref_index,
final int early_index,
final int last_index,
final double [][] offsets // null - will not subtract from velocities
final int last_index//,
// final double [][] pimu_offsets // null - will not subtract from velocities
){
boolean renormalize = true;
double [] timestamps = new double [quadCLTs.length];
......@@ -484,16 +496,18 @@ public class QuadCLTCPU {
double [][][] dxyzatr = getDxyzatrPIMU(
clt_parameters,
quadCLTs,
false);
if (offsets != null) {
quadCLTs[ref_index].getPimuOffsets());
/*
if (pimu_offsets != null) {
for (int nscene = early_index; nscene <= last_index; nscene++) {
for (int i = 0; i < offsets.length; i++) {
for (int j = 0; j < offsets[0].length; j++) {
dxyzatr[nscene][i][j] -= offsets[i][j];
for (int i = 0; i < pimu_offsets.length; i++) {
for (int j = 0; j < pimu_offsets[0].length; j++) {
dxyzatr[nscene][i][j] -= pimu_offsets[i][j];
}
}
}
}
*/
double [][][] xyzatr = new double [quadCLTs.length][][];
xyzatr[ref_index] = new double [2][3];
for (int dir = -1; dir <= 1; dir += 2) {
......@@ -4303,7 +4317,11 @@ public class QuadCLTCPU {
if (this.quat_corr != null) {
properties.setProperty(prefix+"quat_corr", IntersceneMatchParameters.doublesToString(this.quat_corr));
}
if (this.pimu_offsets != null) {
properties.setProperty(prefix+"pimu_offsets_lin", IntersceneMatchParameters.doublesToString(this.pimu_offsets[0]));
properties.setProperty(prefix+"pimu_offsets_ang", IntersceneMatchParameters.doublesToString(this.pimu_offsets[1]));
}
return properties;
......@@ -4473,6 +4491,12 @@ public class QuadCLTCPU {
if (properties.getProperty(prefix+"quat_corr")!=null) {
this.quat_corr= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"quat_corr"),4);
}
if (properties.getProperty(prefix+"pimu_offsets_lin")!=null) {
this.pimu_offsets[0]= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"pimu_offsets_lin"),3);
}
if (properties.getProperty(prefix+"pimu_offsets_ang")!=null) {
this.pimu_offsets[1]= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"pimu_offsets_ang"),3);
}
}
......@@ -10062,7 +10086,23 @@ public class QuadCLTCPU {
System.out.println("No IMS orientation correction is defined");
}
}
public void showPimuOffsets() {
showPimuOffsets(getPimuOffsets());
}
public static void showPimuOffsets(double [][] pimu_offsets) {
if (pimu_offsets != null) {
System.out.println("Linear velocities offsets (m/s) = ["+pimu_offsets[0][0]+", "+
pimu_offsets[0][1]+", "+pimu_offsets[0][2]+"]");
System.out.println("Angular velocities offsets (rad/s) = ["+
pimu_offsets[1][0]+", " + pimu_offsets[1][1]+", "+ + pimu_offsets[1][2]+"]");
} else {
System.out.println("No PIMU offsets are defined");
}
}
public boolean editExtrinsicCorr() // not used in lwir
{
if (geometryCorrection == null){
......
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