Commit aba8d2ec authored by Andrey Filippov's avatar Andrey Filippov

Working on IMS-to-camera matching

parent 0c188f13
This diff is collapsed.
This diff is collapsed.
...@@ -92,6 +92,16 @@ public class IntersceneMatchParameters { ...@@ -92,6 +92,16 @@ public class IntersceneMatchParameters {
public int imsv_num_iter = 20; public int imsv_num_iter = 20;
public double []imsv_xyz = {0,0,1}; public double []imsv_xyz = {0,0,1};
public double imsq_scale_quat = 0.5; // scale applied quternion. 0 - keep old IMS-to-camera correction, 1 - use the new one
public double imsq_reg_weight = 0.95;// regularization weight to force small rotations for collinear 3d trajectories vectors
public double imsq_lambda = 0.1;
public double imsq_lambda_scale_good=0.5;
public double imsq_lambda_scale_bad= 8.0;
public double imsq_lambda_max = 100;
public double imsq_rms_diff = 0.00001;
public int imsq_num_iter = 20;
public boolean sfm_use = true; // use SfM to improve depth map public boolean sfm_use = true; // use SfM to improve depth map
public double sfm_min_base = 0.6; // 2.0; // use SfM if baseline exceeds this public double sfm_min_base = 0.6; // 2.0; // use SfM if baseline exceeds this
public double sfm_min_gain = 2.0; // 5.0; // Minimal SfM gain to apply SfM to the depth map public double sfm_min_gain = 2.0; // 5.0; // Minimal SfM gain to apply SfM to the depth map
...@@ -1423,6 +1433,24 @@ min_str_neib_fpn 0.35 ...@@ -1423,6 +1433,24 @@ min_str_neib_fpn 0.35
gd.addStringField ("Average vertical direction", IntersceneMatchParameters.doublesToString(this.imsv_xyz), 80, gd.addStringField ("Average vertical direction", IntersceneMatchParameters.doublesToString(this.imsv_xyz), 80,
"Calculated vertical direction."); "Calculated vertical direction.");
gd.addMessage ("IMS to camera rotation quaternion fitting");
gd.addNumericField("Scale rotations", this.imsq_scale_quat, 6,8,"",
"0 - keep old IMS-to-camera angular correction, 1.0 - replace with the new rotation.");
gd.addNumericField("Regularization weight for collinearity mitigation", this.imsq_reg_weight, 3,5,"",
"Add cost for large rotation angles needed when both IMS and camera trajectories are almost straight lines.");
gd.addNumericField("LMA lambda", this.imsq_lambda, 6,8,"",
"Initial value of the LMA lambda");
gd.addNumericField("Scale lambda after successful LMA iteration", this.imsq_lambda_scale_good, 3,5,"",
"Scale lambda (reduce) if the new RMSE is lower than the previous one.");
gd.addNumericField("Scale lambda after failed LMA iteration", this.imsq_lambda_scale_bad, 3,5,"",
"Scale lambda (increase) if the new RMSE is higher than the previous one.");
gd.addNumericField("Maximal value of lambda to try", this.imsq_lambda_max, 2,7,"",
"Fail LMA if the result is still worse than before parameters were updates.");
gd.addNumericField("Minimal relative RMSE improvement", this.imsq_rms_diff, 8,10,"",
"Exit LMA iterations if relative RMSE improvement drops below this value.");
gd.addNumericField("Maximal number of LMA iterations", this.imsq_num_iter, 0,3,"",
"A hard limit on LMA iterations.");
gd.addTab ("SfM", "Structure from Motion to improve depth map for the lateral views"); gd.addTab ("SfM", "Structure from Motion to improve depth map for the lateral views");
gd.addCheckbox ("Use SfM", this.sfm_use, gd.addCheckbox ("Use SfM", this.sfm_use,
"Use SfM for the depth map enhancement for laterally moving camera."); "Use SfM for the depth map enhancement for laterally moving camera.");
...@@ -3407,6 +3435,14 @@ min_str_neib_fpn 0.35 ...@@ -3407,6 +3435,14 @@ min_str_neib_fpn 0.35
this.imsv_num_iter = (int) gd.getNextNumber(); this.imsv_num_iter = (int) gd.getNextNumber();
this.imsv_xyz = IntersceneMatchParameters.StringToDoubles(gd.getNextString(), imsv_xyz); this.imsv_xyz = IntersceneMatchParameters.StringToDoubles(gd.getNextString(), imsv_xyz);
this.imsq_scale_quat = gd.getNextNumber();
this.imsq_reg_weight = gd.getNextNumber();
this.imsq_lambda = gd.getNextNumber();
this.imsq_lambda_scale_good = gd.getNextNumber();
this.imsq_lambda_scale_bad = gd.getNextNumber();
this.imsq_lambda_max = gd.getNextNumber();
this.imsq_rms_diff = gd.getNextNumber();
this.imsq_num_iter = (int) gd.getNextNumber();
this.sfm_use = gd.getNextBoolean(); this.sfm_use = gd.getNextBoolean();
this.sfm_min_base = gd.getNextNumber(); this.sfm_min_base = gd.getNextNumber();
...@@ -4590,6 +4626,15 @@ min_str_neib_fpn 0.35 ...@@ -4590,6 +4626,15 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"imsv_num_iter", this.imsv_num_iter+""); // int properties.setProperty(prefix+"imsv_num_iter", this.imsv_num_iter+""); // int
properties.setProperty(prefix+"imsv_xyz", IntersceneMatchParameters.doublesToString(this.imsv_xyz)); properties.setProperty(prefix+"imsv_xyz", IntersceneMatchParameters.doublesToString(this.imsv_xyz));
properties.setProperty(prefix+"imsq_scale_quat", this.imsq_scale_quat+""); // double
properties.setProperty(prefix+"imsq_reg_weight", this.imsq_reg_weight+""); // double
properties.setProperty(prefix+"imsq_lambda", this.imsq_lambda+""); // double
properties.setProperty(prefix+"imsq_lambda_scale_good", this.imsq_lambda_scale_good+""); // double
properties.setProperty(prefix+"imsq_lambda_scale_bad", this.imsq_lambda_scale_bad+""); // double
properties.setProperty(prefix+"imsq_lambda_max", this.imsq_lambda_max+""); // double
properties.setProperty(prefix+"imsq_rms_diff", this.imsq_rms_diff+""); // double
properties.setProperty(prefix+"imsq_num_iter", this.imsq_num_iter+""); // int
properties.setProperty(prefix+"sfm_use", this.sfm_use + ""); // boolean properties.setProperty(prefix+"sfm_use", this.sfm_use + ""); // boolean
properties.setProperty(prefix+"sfm_min_base", this.sfm_min_base+""); // double properties.setProperty(prefix+"sfm_min_base", this.sfm_min_base+""); // double
properties.setProperty(prefix+"sfm_min_gain", this.sfm_min_gain+""); // double properties.setProperty(prefix+"sfm_min_gain", this.sfm_min_gain+""); // double
...@@ -5716,6 +5761,15 @@ min_str_neib_fpn 0.35 ...@@ -5716,6 +5761,15 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"imsv_num_iter")!=null) this.imsv_num_iter=Integer.parseInt(properties.getProperty(prefix+"imsv_num_iter")); if (properties.getProperty(prefix+"imsv_num_iter")!=null) this.imsv_num_iter=Integer.parseInt(properties.getProperty(prefix+"imsv_num_iter"));
if (properties.getProperty(prefix+"imsv_xyz")!=null) this.imsv_xyz= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"imsv_xyz"),this.imsv_xyz); if (properties.getProperty(prefix+"imsv_xyz")!=null) this.imsv_xyz= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"imsv_xyz"),this.imsv_xyz);
if (properties.getProperty(prefix+"imsq_scale_quat")!=null) this.imsq_scale_quat=Double.parseDouble(properties.getProperty(prefix+"imsq_scale_quat"));
if (properties.getProperty(prefix+"imsq_reg_weight")!=null) this.imsq_reg_weight=Double.parseDouble(properties.getProperty(prefix+"imsq_reg_weight"));
if (properties.getProperty(prefix+"imsq_lambda")!=null) this.imsq_lambda=Double.parseDouble(properties.getProperty(prefix+"imsq_lambda"));
if (properties.getProperty(prefix+"imsq_lambda_scale_good")!=null)this.imsq_lambda_scale_good=Double.parseDouble(properties.getProperty(prefix+"imsq_lambda_scale_good"));
if (properties.getProperty(prefix+"imsq_lambda_scale_bad")!=null) this.imsq_lambda_scale_bad=Double.parseDouble(properties.getProperty(prefix+"imsq_lambda_scale_bad"));
if (properties.getProperty(prefix+"imsq_lambda_max")!=null) this.imsq_lambda_max=Double.parseDouble(properties.getProperty(prefix+"imsq_lambda_max"));
if (properties.getProperty(prefix+"imsq_rms_diff")!=null) this.imsq_rms_diff=Double.parseDouble(properties.getProperty(prefix+"imsq_rms_diff"));
if (properties.getProperty(prefix+"imsq_num_iter")!=null) this.imsq_num_iter=Integer.parseInt(properties.getProperty(prefix+"imsq_num_iter"));
if (properties.getProperty(prefix+"sfm_use")!=null) this.sfm_use=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_use")); if (properties.getProperty(prefix+"sfm_use")!=null) this.sfm_use=Boolean.parseBoolean(properties.getProperty(prefix+"sfm_use"));
if (properties.getProperty(prefix+"sfm_min_base")!=null) this.sfm_min_base=Double.parseDouble(properties.getProperty(prefix+"sfm_min_base")); if (properties.getProperty(prefix+"sfm_min_base")!=null) this.sfm_min_base=Double.parseDouble(properties.getProperty(prefix+"sfm_min_base"));
if (properties.getProperty(prefix+"sfm_min_gain")!=null) this.sfm_min_gain=Double.parseDouble(properties.getProperty(prefix+"sfm_min_gain")); if (properties.getProperty(prefix+"sfm_min_gain")!=null) this.sfm_min_gain=Double.parseDouble(properties.getProperty(prefix+"sfm_min_gain"));
...@@ -6874,6 +6928,15 @@ min_str_neib_fpn 0.35 ...@@ -6874,6 +6928,15 @@ min_str_neib_fpn 0.35
imp.imsv_num_iter = this.imsv_num_iter; imp.imsv_num_iter = this.imsv_num_iter;
imp.imsv_xyz = this.imsv_xyz.clone(); imp.imsv_xyz = this.imsv_xyz.clone();
imp.imsq_scale_quat = this.imsq_scale_quat;
imp.imsq_reg_weight = this.imsq_reg_weight;
imp.imsq_lambda = this.imsq_lambda;
imp.imsq_lambda_scale_good = this.imsq_lambda_scale_good;
imp.imsq_lambda_scale_bad = this.imsq_lambda_scale_bad;
imp.imsq_lambda_max = this.imsq_lambda_max;
imp.imsq_rms_diff = this.imsq_rms_diff;
imp.imsq_num_iter = this.imsq_num_iter;
imp.sfm_use = this.sfm_use; imp.sfm_use = this.sfm_use;
imp.sfm_min_base = this.sfm_min_base; imp.sfm_min_base = this.sfm_min_base;
imp.sfm_min_gain = this.sfm_min_gain; imp.sfm_min_gain = this.sfm_min_gain;
......
...@@ -4169,13 +4169,14 @@ public class OpticalFlow { ...@@ -4169,13 +4169,14 @@ public class OpticalFlow {
System.out.println("buildRefDSI(): Running preExpandCLTQuad3d() for scene "+quadCLT_ref.getImageName()); System.out.println("buildRefDSI(): Running preExpandCLTQuad3d() for scene "+quadCLT_ref.getImageName());
System.out.println("buildRefDSI(): quadCLT_ref.hasNewImageData() -> "+quadCLT_ref.hasNewImageData()); System.out.println("buildRefDSI(): quadCLT_ref.hasNewImageData() -> "+quadCLT_ref.hasNewImageData());
} }
// next probably not needed (was troubleshooting)
quadCLT_ref.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU). Spend several days to find this bug! quadCLT_ref.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU). Spend several days to find this bug!
if (debugLevel > -3) { if (debugLevel > -3) {
//quadCLT_main //quadCLT_main
System.out.println("buildRefDSI():quadCLT_ref.tp.clt_3d_passes.size()="+quadCLT_ref.tp.clt_3d_passes.size()); System.out.println("buildRefDSI(): quadCLT_ref.tp.clt_3d_passes.size()="+quadCLT_ref.tp.clt_3d_passes.size());
System.out.println("buildRefDSI(): suspecting processing *-DSI_MAIN.tiff without loading new images to the GPU, running quadCLT_ref.saveQuadClt(). 12/07/2025"); // System.out.println("buildRefDSI(): suspecting processing *-DSI_MAIN.tiff without loading new images to the GPU, running quadCLT_ref.saveQuadClt(). 12/07/2025");
boolean show_sources = debugLevel > 1000; boolean show_sources = debugLevel > 1000;
if (show_sources) { if (show_sources) {
quadCLT_ref.showImageData(); quadCLT_ref.showImageData();
...@@ -5434,8 +5435,8 @@ public class OpticalFlow { ...@@ -5434,8 +5435,8 @@ public class OpticalFlow {
System.out.println("Egomotion table saved to "+ego_path); System.out.println("Egomotion table saved to "+ego_path);
} }
} }
} else if (ims_use) { } else if (ims_use) { // not center reference
earliest_scene = Interscene.setInitialOrientationsIms( earliest_scene = Interscene.setInitialOrientationsIms( // not center reference !!
clt_parameters, // final CLTParameters clt_parameters, 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, inertial_only, // final boolean inertial_only,
...@@ -5564,20 +5565,25 @@ public class OpticalFlow { ...@@ -5564,20 +5565,25 @@ public class OpticalFlow {
// verify quat_corr is set here from the file
if (ref_index != last_index) { // do that for reference (center) scene again (was for the last scene) if (ref_index != last_index) { // do that for reference (center) scene again (was for the last scene) Why is it needed? Bypass in airplane mode
System.out.println("ref_index != last_index: ref_index="+ref_index+", last_index="+last_index); System.out.println("ref_index != last_index: ref_index="+ref_index+", last_index="+last_index);
// FIXME: Will deal with blue sky later - not needed for drones. // FIXME: Will deal with blue sky later - not needed for drones.
/// ref_blue_sky = quadCLTs[ref_index].getDoubleBlueSky(); /// ref_blue_sky = quadCLTs[ref_index].getDoubleBlueSky();
quadCLTs[ref_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN" ///// maybe just re-read DSI_MAIN?
quadCLTs[ref_index].restoreAnyDSI(debugLevel);
// readDsiMain(); // maybe it is used when not the first time?
/*
quadCLTs[ref_index] = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN" . Will it forget quat_corr?
set_channels[ref_index].set_name, set_channels[ref_index].set_name,
clt_parameters, clt_parameters,
colorProcParameters, // colorProcParameters, //
threadsMax, threadsMax,
debugLevel); debugLevel);
*/
quadCLTs[ref_index].setQuadClt(); // just in case ? quadCLTs[ref_index].setQuadClt(); // just in case ?
/// quadCLTs[ref_index].setBlueSky(ref_blue_sky); //quadCLTs[ref_index].dsi has it /// quadCLTs[ref_index].setBlueSky(ref_blue_sky); //quadCLTs[ref_index].dsi has it
quadCLTs[ref_index].setDSRBG( quadCLTs[ref_index].setDSRBG( // is it needed?
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
threadsMax, // int threadsMax, // maximal number of threads to launch threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus, // boolean updateStatus, updateStatus, // boolean updateStatus,
...@@ -5631,7 +5637,7 @@ public class OpticalFlow { ...@@ -5631,7 +5637,7 @@ public class OpticalFlow {
} }
// FPN here - poses are known // FPN here - poses are known
boolean changed = quadCLT_main.isPhotometricUpdatedAndReset(); // boolean changed = quadCLT_main.isPhotometricUpdatedAndReset();
if ((center_CLT != null) && center_CLT.hasCenterClt()) { // float [] fclt if ((center_CLT != null) && center_CLT.hasCenterClt()) { // float [] fclt
int [] scene_range = new int [] {earliest_scene, last_index}; int [] scene_range = new int [] {earliest_scene, last_index};
double [][][] fpn = CorrectionFPN.cuasSubtractFpn( // returns fpn // null double [][][] fpn = CorrectionFPN.cuasSubtractFpn( // returns fpn // null
...@@ -5849,7 +5855,7 @@ public class OpticalFlow { ...@@ -5849,7 +5855,7 @@ public class OpticalFlow {
disable_ers_y = true; disable_ers_y = true;
disable_ers_r = true; disable_ers_r = true;
lma_xyzatr = false; lma_xyzatr = false;
lma_use_Z = false; // lma_use_Z = false;
lma_use_R = false; lma_use_R = false;
lma_use_XY = true; lma_use_XY = true;
lma_use_AT = false; lma_use_AT = false;
...@@ -6205,32 +6211,36 @@ public class OpticalFlow { ...@@ -6205,32 +6211,36 @@ public class OpticalFlow {
if (calc_quat_corr) { if (calc_quat_corr) {
double [] quat_rms = new double [5]; double [] quat_rms = new double [5];
double [] enu_corr = new double[3]; /// double [] enu_corr = new double[3];
int corr_index = -1; int corr_index = -1;
if ((ref_index >= 0) &&(quadCLTs[ref_index] == master_CLT)) { if ((ref_index >= 0) &&(quadCLTs[ref_index] == master_CLT)) {
corr_index = ref_index; corr_index = ref_index;
} }
double scale_quat = 1.0; // clt_parameters.imp.imsq_scale_quat; // adjust to context
double reg_weight = clt_parameters.imp.imsq_reg_weight; // adjust to context
double [] quatCorr = Interscene.getQuaternionCorrection( double [] quatCorr = Interscene.getQuaternionCorrection(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
scale_quat, // double scale_quat,
reg_weight, // double reg_weight,
quadCLTs, // QuadCLT [] quadCLTs, quadCLTs, // QuadCLT [] quadCLTs,
corr_index, // ref_index, // int ref_index, corr_index, // ref_index, // int ref_index,
master_CLT, // QuadCLT ref_scene, // may be one of quadCLTs or center_CLT master_CLT, // QuadCLT ref_scene, // may be one of quadCLTs or center_CLT
earliest_scene, // int earliest_scene, earliest_scene, // int earliest_scene,
quat_rms, // double [] rms // null or double[2]; quat_rms, // double [] rms // null or double[2];
enu_corr, //double [] enu_corr, null, // enu_corr, //double [] enu_corr,
debugLevel); // int debugLevel debugLevel); // int debugLevel
if (quatCorr != null) { if (quatCorr != null) {
int num_iter = (int) quat_rms[4]; int num_iter = (int) quat_rms[4];
if (debugLevel> -3) { if (debugLevel> -3) {
System.out.println("LMA done on iteration "+num_iter+ System.out.println("LMA done on iteration "+num_iter+
" full RMS="+quat_rms[0]+" ("+quat_rms[2]+"), pure RMS="+quat_rms[1]+" ("+quat_rms[3]+")"); " full RMS="+quat_rms[0]+" ("+quat_rms[2]+"), pure RMS="+quat_rms[1]+" ("+quat_rms[3]+")");
QuadCLTCPU.showQuatCorr(quatCorr,enu_corr); QuadCLTCPU.showQuatCorr(quatCorr,null); // enu_corr);
} }
master_CLT.setQuatCorr(quatCorr); master_CLT.setQuatCorr(quatCorr);
quadCLT_main.setQuatCorr(quatCorr); quadCLT_main.setQuatCorr(quatCorr);
master_CLT.setENUCorrMetric(enu_corr); // master_CLT.setENUCorrMetric(enu_corr);
quadCLT_main.setENUCorrMetric(enu_corr); // quadCLT_main.setENUCorrMetric(enu_corr);
master_CLT.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) master_CLT.saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
null, // String path, // full name with extension or w/o path to use x3d directory null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1); debugLevel+1);
...@@ -6244,7 +6254,7 @@ public class OpticalFlow { ...@@ -6244,7 +6254,7 @@ public class OpticalFlow {
sb.append("compass: quatCorr=["+quatCorr[0]+", "+quatCorr[1]+", "+quatCorr[2]+", "+quatCorr[3]+"]\n"); sb.append("compass: quatCorr=["+quatCorr[0]+", "+quatCorr[1]+", "+quatCorr[2]+", "+quatCorr[3]+"]\n");
sb.append("compass: ATR(rad)=["+corr_angles[0]+", "+corr_angles[1]+", "+corr_angles[2]+"]\n"); sb.append("compass: ATR(rad)=["+corr_angles[0]+", "+corr_angles[1]+", "+corr_angles[2]+"]\n");
sb.append("compass: ATR(deg)=["+corr_degrees[0]+", "+corr_degrees[1]+", "+corr_degrees[2]+"]\n"); sb.append("compass: ATR(deg)=["+corr_degrees[0]+", "+corr_degrees[1]+", "+corr_degrees[2]+"]\n");
sb.append("compass: ENU corr (m)=["+enu_corr[0]+", "+enu_corr[1]+", "+enu_corr[2]+"]\n"); /// sb.append("compass: ENU corr (m)=["+enu_corr[0]+", "+enu_corr[1]+", "+enu_corr[2]+"]\n");
sb.append("------------------------\n\n"); sb.append("------------------------\n\n");
master_CLT.appendStringInModelDirectory(sb.toString(),QuadCLT.IMU_CALIB_LOGS_SUFFIX); // String suffix) master_CLT.appendStringInModelDirectory(sb.toString(),QuadCLT.IMU_CALIB_LOGS_SUFFIX); // String suffix)
if (debugLevel > -3) { if (debugLevel > -3) {
...@@ -7817,7 +7827,9 @@ public class OpticalFlow { ...@@ -7817,7 +7827,9 @@ public class OpticalFlow {
double [][][] scenes_dxyzatr = QuadCLTCPU.getDxyzatrPIMU( // velocities and omegas from IMU double [][][] scenes_dxyzatr = QuadCLTCPU.getDxyzatrPIMU( // velocities and omegas from IMU
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
quadCLTs); // , // QuadCLT[] quadCLTs, quadCLTs, // QuadCLT[] quadCLTs,
null); // quat_corr); // double [] quat_corr,
int num_samples = last_index-earliest_scene + 1; int num_samples = last_index-earliest_scene + 1;
double scene_time = (quadCLTs[last_index].getTimeStamp() - quadCLTs[earliest_scene].getTimeStamp())/(num_samples-1); double scene_time = (quadCLTs[last_index].getTimeStamp() - quadCLTs[earliest_scene].getTimeStamp())/(num_samples-1);
......
...@@ -222,6 +222,7 @@ public class QuadCLTCPU { ...@@ -222,6 +222,7 @@ public class QuadCLTCPU {
public Did_gps_pos did_gps2_pos = null; public Did_gps_pos did_gps2_pos = null;
public Did_gps_pos did_gps1_ubx_pos = null; public Did_gps_pos did_gps1_ubx_pos = null;
public String ims_last_path = null; public String ims_last_path = null;
//quat_corr is additional (to clt_parameters.imp.getImsMountATR()) per-reference frame correction
public double [] quat_corr = null; // correction for IMS camera frame to actual camera frame (for reference frames) public double [] quat_corr = null; // correction for IMS camera frame to actual camera frame (for reference frames)
public double [] enu_corr_metric = null; // GNSS correction - add metrix offset to GNSS of the reference scene public double [] enu_corr_metric = null; // GNSS correction - add metrix offset to GNSS of the reference scene
...@@ -897,6 +898,7 @@ public class QuadCLTCPU { ...@@ -897,6 +898,7 @@ public class QuadCLTCPU {
double [][][] pimu_xyzatr = QuadCLT.integratePIMU( double [][][] pimu_xyzatr = QuadCLT.integratePIMU(
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT[] quadCLTs, quadCLTs, // final QuadCLT[] quadCLTs,
null, // quat_corr, // double [] quat_corr,
ref_index, // final int ref_index, ref_index, // final int ref_index,
null, // double [][][] dxyzatr, null, // double [][][] dxyzatr,
earliest_scene, // final int early_index, earliest_scene, // final int early_index,
...@@ -1233,6 +1235,7 @@ public class QuadCLTCPU { ...@@ -1233,6 +1235,7 @@ public class QuadCLTCPU {
pimu_xyzatr = QuadCLT.integratePIMU( // recalculate to updated if calibration was changed pimu_xyzatr = QuadCLT.integratePIMU( // recalculate to updated if calibration was changed
clt_parameters, // final CLTParameters clt_parameters, clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT[] quadCLTs, quadCLTs, // final QuadCLT[] quadCLTs,
null, // quat_corr, // double [] quat_corr,
ref_index, // final int ref_index, ref_index, // final int ref_index,
null, // double [][][] dxyzatr, null, // double [][][] dxyzatr,
early_index, // final int early_index, early_index, // final int early_index,
...@@ -1532,13 +1535,17 @@ public class QuadCLTCPU { ...@@ -1532,13 +1535,17 @@ public class QuadCLTCPU {
* @return linear and angular velocities in camera frame * @return linear and angular velocities in camera frame
*/ */
protected double [][] getDxyzatrIms( protected double [][] getDxyzatrIms(
CLTParameters clt_parameters) { CLTParameters clt_parameters,
double [] quat_corr) {
final double [][] pimu_offsets = clt_parameters.imp.get_pimu_offs(); final double [][] pimu_offsets = clt_parameters.imp.get_pimu_offs();
double [] ims_ortho = clt_parameters.imp.ims_ortho; double [] ims_ortho = clt_parameters.imp.ims_ortho;
double [] ims_mount_atr = clt_parameters.imp.getImsMountATR(); // converts to radians double [] ims_mount_atr = clt_parameters.imp.getImsMountATR(); // converts to radians
double [] quat_ims_cam = Imx5.quaternionImsToCam( double [] quat_ims_cam = Imx5.quaternionImsToCam(
ims_mount_atr, // new double[] {0, 0.13, 0}, ims_mount_atr, // new double[] {0, 0.13, 0},
ims_ortho); ims_ortho);
if (quat_corr != null) {
quat_ims_cam=Imx5.applyQuaternionToQuaternion(quat_corr, quat_ims_cam, false);
}
double [] double_uvw = did_ins_2.getUvw(); double [] double_uvw = did_ins_2.getUvw();
if ((double_uvw[0] == 0.0) && (double_uvw[1] == 0.0) && (double_uvw[2] == 0.0)) { if ((double_uvw[0] == 0.0) && (double_uvw[1] == 0.0) && (double_uvw[2] == 0.0)) {
double_uvw = did_ins_1.getUvw(); double_uvw = did_ins_1.getUvw();
...@@ -1564,15 +1571,18 @@ public class QuadCLTCPU { ...@@ -1564,15 +1571,18 @@ public class QuadCLTCPU {
* @param clt_parameters configuration parameters (including * @param clt_parameters configuration parameters (including
* scales from IMS to linear for linear and angular velocities * scales from IMS to linear for linear and angular velocities
* @param quadCLTs array of scenes with IMS data loaded * @param quadCLTs array of scenes with IMS data loaded
* @param quat_corr quaternion correction from ims to the camera or null
* @return linear and angular velocities in camera frame for each scene that has IMS data * @return linear and angular velocities in camera frame for each scene that has IMS data
*/ */
public static double [][][] getDxyzatrPIMU( public static double [][][] getDxyzatrPIMU(
CLTParameters clt_parameters, CLTParameters clt_parameters,
QuadCLT[] quadCLTs){ //, QuadCLT[] quadCLTs,
double [] quat_corr){ //,
double [][][] dxyzatr = new double [quadCLTs.length][][]; double [][][] dxyzatr = new double [quadCLTs.length][][];
for (int i = 0; i < quadCLTs.length; i++) if (quadCLTs[i] != null) { for (int i = 0; i < quadCLTs.length; i++) if (quadCLTs[i] != null) {
dxyzatr[i] = quadCLTs[i].getDxyzatrIms( dxyzatr[i] = quadCLTs[i].getDxyzatrIms(
clt_parameters); // clt_parameters, //
quat_corr); // double [] quat_corr,
} }
return dxyzatr; return dxyzatr;
} }
...@@ -1583,6 +1593,7 @@ public class QuadCLTCPU { ...@@ -1583,6 +1593,7 @@ public class QuadCLTCPU {
* linear velocities * linear velocities
* @param clt_parameters configuration parameters * @param clt_parameters configuration parameters
* @param quadCLTs scenes sequence * @param quadCLTs scenes sequence
* @param quat_corr quaternion camera-to-ims correction or null
* @param ref_index reference scene index * @param ref_index reference scene index
* @param dxyzatr local linear and angular velocities * @param dxyzatr local linear and angular velocities
* @param early_index earliest (lowest) scene index in quadCLTs to use * @param early_index earliest (lowest) scene index in quadCLTs to use
...@@ -1592,6 +1603,7 @@ public class QuadCLTCPU { ...@@ -1592,6 +1603,7 @@ public class QuadCLTCPU {
public static double [][][] integratePIMU( public static double [][][] integratePIMU(
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final QuadCLT[] quadCLTs, final QuadCLT[] quadCLTs,
double [] quat_corr,
final int ref_index, final int ref_index,
double [][][] dxyzatr, double [][][] dxyzatr,
final int early_index, final int early_index,
...@@ -1605,7 +1617,9 @@ public class QuadCLTCPU { ...@@ -1605,7 +1617,9 @@ public class QuadCLTCPU {
if (dxyzatr == null) { if (dxyzatr == null) {
dxyzatr = getDxyzatrPIMU( dxyzatr = getDxyzatrPIMU(
clt_parameters, clt_parameters,
quadCLTs); quadCLTs,
quat_corr); // double [] quat_corr,
} }
double [][][] xyzatr = new double [quadCLTs.length][][]; double [][][] xyzatr = new double [quadCLTs.length][][];
xyzatr[ref_index] = new double [2][3]; xyzatr[ref_index] = new double [2][3];
...@@ -4366,6 +4380,40 @@ public class QuadCLTCPU { ...@@ -4366,6 +4380,40 @@ public class QuadCLTCPU {
return null; return null;
} }
public void restoreAnyDSI (
int debugLevel) {
int dsi_result = -1;
int max_length=OpticalFlow.COMBO_DSN_TITLES.length;
if (max_length < TwoQuadCLT.DSI_SLICES.length) {
max_length = TwoQuadCLT.DSI_SLICES.length;
}
double [][] dsi_tmp = new double [max_length][];
for (int i = 0; i <DSI_SUFFIXES.length; i++) {
dsi_result =restoreDSI(
DSI_SUFFIXES[i],
dsi_tmp, //double [][] dsi,
(i < (DSI_SUFFIXES.length -1))); // silent
if (dsi_result >= 0) {
System.out.println ("Using "+getX3dDirectory()+ Prefs.getFileSeparator() + image_name + DSI_SUFFIXES[i] + ".tiff");
if (i < 2) { // DSI format for COMBO_DSN_INDX_* is different,
setDSIFromCombo(dsi_tmp); // reformat
} else {
setDSI(dsi_tmp); // as is
}
break;
}
}
if (dsi_result < 0) {
System.out.println("No DSI data for the scene "+this.getImageName()+", setting this.dsi=null");
setDSI(null);
}
// WAS: restore only if (dsi_result < 0)... else
restoreInterProperties( // restore properties for interscene processing (extrinsics, ers, ...) // get relative poses (98)
null, // String path, // full name with extension or null to use x3d directory
false, // boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics)
debugLevel);
}
public double [][] readComboDSI (boolean silent) { public double [][] readComboDSI (boolean silent) {
double [][] combo_dsi = new double [OpticalFlow.COMBO_DSN_TITLES.length][]; double [][] combo_dsi = new double [OpticalFlow.COMBO_DSN_TITLES.length][];
...@@ -5311,6 +5359,8 @@ public class QuadCLTCPU { ...@@ -5311,6 +5359,8 @@ public class QuadCLTCPU {
} }
// move after restoring properties // move after restoring properties
// try to restore DSI generated from interscene if available, if not use single-scene -DSI_MAIN // try to restore DSI generated from interscene if available, if not use single-scene -DSI_MAIN
restoreAnyDSI(debugLevel);
/*
int dsi_result = -1; int dsi_result = -1;
int max_length=OpticalFlow.COMBO_DSN_TITLES.length; int max_length=OpticalFlow.COMBO_DSN_TITLES.length;
if (max_length < TwoQuadCLT.DSI_SLICES.length) { if (max_length < TwoQuadCLT.DSI_SLICES.length) {
...@@ -5341,7 +5391,7 @@ public class QuadCLTCPU { ...@@ -5341,7 +5391,7 @@ public class QuadCLTCPU {
null, // String path, // full name with extension or null to use x3d directory null, // String path, // full name with extension or null to use x3d directory
false, // boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics) false, // boolean all_properties,// null, // Properties properties, // if null - will only save extrinsics)
debugLevel); debugLevel);
*/
int [] channelFiles = set_channels[0].fileNumber(); int [] channelFiles = set_channels[0].fileNumber();
boolean [][] saturation_imp = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null; boolean [][] saturation_imp = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
double [] scaleExposures = new double[channelFiles.length]; double [] scaleExposures = new double[channelFiles.length];
......
...@@ -96,6 +96,24 @@ public class QuaternionLma { ...@@ -96,6 +96,24 @@ public class QuaternionLma {
return new double [] { c, s*axis[0], s*axis[1], s*axis[2]}; return new double [] { c, s*axis[0], s*axis[1], s*axis[2]};
} }
public double [] getLastFx() {
double [] fx = getFxDerivs(
parameters_vector, // double [] vector,
null, // final double [][] jt, // should be null or initialized with [vector.length][]
-3); // final int debug_level)
return fx;
}
public double [] getX() {
return x_vector;
}
public double [] getY() {
return y_vector;
}
public double [] getW() {
return weights;
}
public void prepareCompassLMA( public void prepareCompassLMA(
double [][] vect_x, // GPS-derived X,Y,Z relative to the reference frame double [][] vect_x, // GPS-derived X,Y,Z relative to the reference frame
double [][] vect_y, // Camera X,Y,Z relative to the reference frame double [][] vect_y, // Camera X,Y,Z relative to the reference frame
......
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