Loading src/main/java/com/elphel/imagej/tileprocessor/ErsCorrection.java +8 −4 Original line number Diff line number Diff line Loading @@ -220,18 +220,22 @@ public class ErsCorrection extends GeometryCorrection { private double [][] ers_atr_dt; // angular velocities per scan line. It is now actually 2*omega! public static boolean [] getParamSelect( boolean use_Z, boolean use_R, boolean use_XY, boolean use_AT, boolean use_ERS, boolean use_ERS_tilt) { boolean use_ERS_tilt, boolean use_ERS_roll) { boolean [] param_select = new boolean[DP_NUM_PARS]; boolean use_ERS_roll = use_ERS && use_ERS_tilt; for (int i:DP_ZR_INDICES) param_select[i] = true; // for (int i:DP_ZR_INDICES) param_select[i] = true; if (use_Z || use_XY) param_select[DP_DSZ] = true; if (use_R || use_AT) param_select[DP_DSRL] = 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) param_select[DP_DSVAZ] = true; if (use_ERS && use_ERS_tilt) param_select[DP_DSVTL] = true; if (use_ERS_roll) param_select[DP_DSVRL] = true; if (use_ERS && use_ERS_roll) param_select[DP_DSVRL] = true; return param_select; } Loading src/main/java/com/elphel/imagej/tileprocessor/Interscene.java +97 −20 Original line number Diff line number Diff line Loading @@ -322,7 +322,30 @@ public class Interscene { start_ref_pointers[0] = start_ref_pointers1[0]; return earliest_scene2; // cent_index; } if (generate_egomotion) { String ego_path = quadCLTs[cent_index].getX3dDirectory()+Prefs.getFileSeparator()+ quadCLTs[ref_index].getImageName()+ "-ego-preinvert-"+quadCLTs[cent_index].getNumOrient()+".csv"; String ego_comment = null; Interscene.generateEgomotionTable( clt_parameters, // CLTParameters clt_parameters, quadCLTs, // QuadCLT [] quadCLTs, cent_index,// ref_indx, earliest_scene, // int earliest_scene, ego_path, // String path, ego_comment); // String comment); if (debugLevel> -3) { System.out.println("Egomotion table saved to "+ego_path); } } // invert first half, reference to the cent_index, add to cent_index map, generate ref_index ponter and cent_index, if (debugLevel > -3) { System.out.println("pre invertInitialOrientation(): ref_index "+ref_index+", cent_index="+ cent_index+", last_index="+". readjust="+readjust+"\n"); } invertInitialOrientation( clt_parameters, // final CLTParameters clt_parameters, Loading @@ -335,6 +358,24 @@ public class Interscene { ref_index, // final int ref_old, // original ref_index (normally == last_index) earliest_scene2, //final int earliest_index// first to process debugLevel); // final int debugLevel if (generate_egomotion) { String ego_path = quadCLTs[cent_index].getX3dDirectory()+Prefs.getFileSeparator()+ quadCLTs[ref_index].getImageName()+ "-ego-afterinvert-"+quadCLTs[cent_index].getNumOrient()+".csv"; String ego_comment = null; Interscene.generateEgomotionTable( clt_parameters, // CLTParameters clt_parameters, quadCLTs, // QuadCLT [] quadCLTs, cent_index,// ref_indx, earliest_scene, // int earliest_scene, ego_path, // String path, ego_comment); // String comment); if (debugLevel> -3) { System.out.println("Egomotion table saved to "+ego_path); } } String cent_ts = quadCLTs[cent_index].getImageName(); // write config for both ref_index and cent_index scenes // ErsCorrection ers_reference = quadCLTs[ref_index].getErsCorrection(); Loading Loading @@ -425,12 +466,18 @@ public class Interscene { } return 0; } else { // if (readjust) { boolean lma_use_Z = clt_parameters.imp.lma_use_Z; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables boolean lma_use_R = clt_parameters.imp.lma_use_R; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables boolean[] param_select = ErsCorrection.getParamSelect( // ZR - always lma_use_Z, // boolean use_Z, lma_use_R, // boolean use_R, true, // boolean use_XY false, // boolean use_AT, false, // boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; false); // boolean use_ERS_tilt); false, // boolean use_ERS_tilt); false );// boolean use_ERS_roll); double maximal_series_rms = 0.0; double [][][] scenes_xyzatr = new double [last_index+1][][]; double [][][] dxyzatr_dt = new double [last_index+1][][]; Loading Loading @@ -761,12 +808,20 @@ public class Interscene { double max_zoom_diff = clt_parameters.imp.max_zoom_diff; boolean fpn_skip = clt_parameters.imp.fpn_skip; // if false - fail as before boolean fpn_rematch = clt_parameters.imp.fpn_rematch; // if false - keep previous boolean lma_use_Z = clt_parameters.imp.lma_use_Z; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables boolean lma_use_R = clt_parameters.imp.lma_use_R; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables if (debugLevel > -3) { System.out.println("setInitialOrientationsIms(): lma_use_Z="+lma_use_Z+", lma_use_R="+lma_use_R); } boolean[] param_select = ErsCorrection.getParamSelect( // ZR - always true, // boolean use_XY false, // boolean use_AT, lma_use_Z, // boolean use_Z, lma_use_R, // boolean use_R, true, // boolean use_XY, May change with oorient preference false, // boolean use_AT, May change with oorient preference false, // boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; false); // boolean use_ERS_tilt); false, // boolean use_ERS_tilt); false); // boolean use_ERS_roll); int [] fail_reason = new int[1]; // null or int[1]: 0 - OK, 2 - LMA, 3 - min, 4 - max for (int scene_index = ref_index - 1; scene_index >= 0 ; scene_index--) { Loading Loading @@ -1815,8 +1870,12 @@ public class Interscene { public static int reAdjustPairsLMAInterscene( // after combo dgi is available and preliminary poses are known CLTParameters clt_parameters, double mb_max_gain, boolean use_Z, boolean use_R, boolean disable_ers, boolean disable_ers_y, boolean disable_ers_r, boolean lma_xyzatr, boolean configured_lma, boolean lpf_xy, // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables double avg_rlen, Loading @@ -1833,16 +1892,20 @@ public class Interscene { int debugLevel) { System.out.println("reAdjustPairsLMAInterscene(): using mb_max_gain="+mb_max_gain+ ", disable_ers="+disable_ers+", disable_ers_y="+disable_ers_y); boolean freeze_xy_pull = true; // false; // true; // debugging freezing xy to xy_pull boolean copy_pull_current = false; // true; boolean restore_imu = false; // restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl ", disable_ers="+disable_ers+", disable_ers_y="+disable_ers_y+ ", use_Z="+use_Z+", use_R="+use_R); boolean freeze_xy_pull = clt_parameters.imp.freeze_xy_pull; // true; // false; // true; // debugging freezing xy to xy_pull boolean copy_pull_current = clt_parameters.imp.copy_pull_current; //false; // true; boolean restore_imu = clt_parameters.imp.restore_imu; //false; // restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl boolean[] param_select = configured_lma? clt_parameters.ilp.ilma_lma_select : ErsCorrection.getParamSelect( true, // !freeze_xy_pull && (!readjust_xy_ims || (reg_weight_xy != 0)), // false only in mode c): freeze X,Y// boolean use_XY true, // readjust_xy_ims || lpf_xy, // boolean use_AT, lma_xyzatr || use_Z, // boolean use_Z, lma_xyzatr || use_R, // boolean use_R, lma_xyzatr || ( !freeze_xy_pull && (!readjust_xy_ims || (reg_weight_xy != 0))), // false only in mode c): freeze X,Y// boolean use_XY lma_xyzatr || ( readjust_xy_ims || lpf_xy), // boolean use_AT, !disable_ers, //boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; !disable_ers_y); // boolean use_ERS_tilt); !disable_ers_y, // boolean use_ERS_tilt, !disable_ers_r); // boolean use_ERS_roll); final double [] param_regweights = configured_lma? clt_parameters.ilp.ilma_regularization_weights : ErsCorrection.getParamRegWeights( (freeze_xy_pull? 0.0: reg_weight_xy)); // double reg_weight, Loading Loading @@ -1996,10 +2059,13 @@ public class Interscene { } } param_select = ErsCorrection.getParamSelect( true, // boolean use_Z, true, // boolean use_R, true, // boolean use_XY true, // boolean use_AT, false, // boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; false); // boolean use_ERS_tilt); false, // boolean use_ERS_tilt); false); // boolean use_ERS_roll); } // optionally filter by averaging and "IMU" (actually current dxyzatr_dt). Loading Loading @@ -5118,7 +5184,18 @@ public class Interscene { sb.append(nscene+"\t"+timestamp); if (use_processed) { double [] nan3 = new double[] {Double.NaN, Double.NaN,Double.NaN}; double [][] nan23 = new double[][] {nan3,nan3}; if (scenes_xyzatr[nscene] != null) { if (scenes_xyzatr[nscene][0] == null) scenes_xyzatr[nscene][0]= nan3; if (scenes_xyzatr[nscene][1] == null) scenes_xyzatr[nscene][1]= nan3; if (dxyzatr_dt[nscene]== null) dxyzatr_dt[nscene] = nan23; if (dxyzatr_dt[nscene][0] == null) dxyzatr_dt[nscene][0]= nan3; if (dxyzatr_dt[nscene][0] == null) dxyzatr_dt[nscene][0]= nan3; if (scenes_xyzatr_dt[nscene]== null) scenes_xyzatr_dt[nscene] = nan23; if (scenes_xyzatr_dt[nscene][0] == null) scenes_xyzatr_dt[nscene][0]= nan3; if (scenes_xyzatr_dt[nscene][0] == null) scenes_xyzatr_dt[nscene][0]= nan3; // x,y,z - scene position in reference scene frame (reference scene is all 0-s) sb.append("\t"+scenes_xyzatr[nscene][0][0]+"\t"+scenes_xyzatr[nscene][0][1]+"\t"+scenes_xyzatr[nscene][0][2]); // a,tilt,roll - scene orientation in reference scene frame (reference scene is all 0-s) Loading src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java +109 −9 Original line number Diff line number Diff line Loading @@ -370,7 +370,7 @@ public class IntersceneMatchParameters { public double max_zoom_diff = 0; // for down-views when changing altitude (0 - ignore) public boolean fpn_skip = true; // skip too close scenes (false - abort, previous behavior) public boolean fpn_rematch = true; // match fpn-failed scenes to later scenes with larger difference public boolean refine_invert = true; // Refine with LMA while inverting relative poses from other reference public boolean refine_invert = false; // Refine with LMA while inverting relative poses from other reference // Remove moving objects (goal is not to detect slightest movement, but to improve pose matching public boolean mov_en = true; // enable detection/removal of the moving objects during pose matching Loading Loading @@ -413,11 +413,27 @@ public class IntersceneMatchParameters { public double mb_tau = 0.008; // time constant, sec public double mb_max_gain = 5.0; // motion blur maximal gain (if more - move second point more than a pixel public double mb_max_gain_inter = 2.0; // same for interscene correlation for pose adjustment // TODO: move next parameters elsewhere - they are not the motion blur ones. public int mb_gain_index_pose = 5; // pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter public int mb_gain_index_depth = 5; // depth map refine pass (SfM) to switch to full mb_max_gain from mb_max_gain_inter public int mb_ers_index = 2; // pose readjust pass to enable ERS public int mb_ers_index = 3; // pose readjust pass to enable ERS public int mb_ers_y_index = 3; // pose readjust pass to enable ERS in vertical (Y) direction - it competes with SfM public int mb_ers_r_index = 3; // pose readjust pass to enable ERS in vertical (Y) direction - it competes with SfM public int mb_all_index = 4; // simultaneously LMA-adjust XYZATR plus optional angular ERS public boolean mb_pref_orient = true; // rely on IMU orientation before position public boolean lma_use_Z = true; // LMA adjust Z public boolean lma_use_R = true; // LMA adjust R // FIXME: some of the following parameters will be modified or removed public boolean configured_lma = false; public boolean freeze_xy_pull = true; // false; // true; // debugging freezing xy to xy_pull public boolean copy_pull_current = false; // true; public boolean restore_imu = false; // restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl public boolean lpf_xy = false; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables public boolean readjust_xy_ims = true; // false; public double reg_weight_xy = 0; // 10.0; // 1.0; // 10.0; // 0.05; // TODO: find out reasonable values public boolean stereo_merge = true; public int stereo_gap = 32; // pixels between right and left frames Loading Loading @@ -1186,7 +1202,8 @@ public class IntersceneMatchParameters { "Maximal gain for motion blur correction (if needed more for 1 pixel, increase offset). Will be forced fro the last adjustment"); gd.addNumericField("Maximal gain pose", this.mb_max_gain_inter, 5,7,"x", "Maximal gain for motion blur correction during interscene correlation. Will be used for all but the last adjustment."); gd.addTab("LMA sequence","Interscene LMA sequence control"); gd.addMessage("Parameters for control of the LMA pose adjustment sequence"); gd.addNumericField("Pose readjust number for full mb_gain", this.mb_gain_index_pose, 0,3,"", "Pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter."); gd.addNumericField("Depth map refine number for full mb_gain",this.mb_gain_index_depth, 0,3,"", Loading @@ -1195,6 +1212,34 @@ public class IntersceneMatchParameters { "Pose readjust pass to enable ERS."); gd.addNumericField("Pose readjust number to enable tilt ERS LMA",this.mb_ers_y_index, 0,3,"", "Pose readjust pass to enable ERS in vertical (Y) direction - it competes with SfM."); gd.addNumericField("Pose readjust number to enable roll ERS LMA",this.mb_ers_r_index, 0,3,"", "Pose readjust pass to enable ERS roll adjustment."); gd.addNumericField("Pose readjust number to enable all XYZATR",this.mb_all_index, 0,3,"", "Enables 6 DOF adjustment for one pass, ERS parameters adjusted separately above."); gd.addCheckbox ("Rely on IMS orientation before position", this.mb_pref_orient, "First use IMS orientation, later use IMS position. If false - reverse order."); gd.addCheckbox ("LMA adjust Z", this.lma_use_Z, "Always adjust Z (altitude) when running interscene LMA. False - same as X and Y."); gd.addCheckbox ("LMA adjust roll", this.lma_use_R, "Always adjust roll when running interscene LMA. False - same as Azimuth and Tilt."); gd.addMessage ("Other Interscene LMA parameters to be modified/replaced/removed"); gd.addCheckbox ("Use configuration LMA parameters", this.configured_lma, "Use configuration LMA parameters, disregard onther parameters that influence LMA parameters."); gd.addCheckbox ("Freeze XY pull", this.freeze_xy_pull, "Freeze XY target values, approach with smaller steps if needed ."); gd.addCheckbox ("Copy pull values to current", this.copy_pull_current, "Replace current (start) values with the \"pull\" ones."); gd.addCheckbox ("Restore ERS to IMU velocities", this.restore_imu, "restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl."); gd.addCheckbox ("LPF X and Y", this.lpf_xy, "LPF x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables - what?."); gd.addCheckbox ("Readjust XY from IMS", this.readjust_xy_ims, "Readjust X,Y from IMS linear/angular and full X,Y movement."); gd.addNumericField("LMA regularization weight", this.reg_weight_xy, 5,7,"", "Regularization weight for LMA"); gd.addTab("Stereo/Video","Parameters for stereo video generation"); Loading Loading @@ -1609,11 +1654,24 @@ public class IntersceneMatchParameters { this.mb_tau = gd.getNextNumber(); this.mb_max_gain = gd.getNextNumber(); this.mb_max_gain_inter = gd.getNextNumber(); this.mb_gain_index_pose = (int) gd.getNextNumber(); this.mb_gain_index_depth =(int) gd.getNextNumber(); this.mb_ers_index = (int) gd.getNextNumber(); this.mb_ers_y_index = (int) gd.getNextNumber(); this.mb_ers_r_index = (int) gd.getNextNumber(); this.mb_all_index = (int) gd.getNextNumber(); this.mb_pref_orient = gd.getNextBoolean(); this.lma_use_Z = gd.getNextBoolean(); this.lma_use_R = gd.getNextBoolean(); this.configured_lma = gd.getNextBoolean(); this.freeze_xy_pull = gd.getNextBoolean(); this.copy_pull_current = gd.getNextBoolean(); this.restore_imu = gd.getNextBoolean(); this.lpf_xy = gd.getNextBoolean(); this.readjust_xy_ims = gd.getNextBoolean(); this.reg_weight_xy = gd.getNextNumber(); if (stereo_views.length > 0) { int i = gd.getNextChoiceIndex(); Loading Loading @@ -2030,8 +2088,22 @@ public class IntersceneMatchParameters { properties.setProperty(prefix+"mb_gain_index_pose", this.mb_gain_index_pose+""); // int properties.setProperty(prefix+"mb_gain_index_depth", this.mb_gain_index_depth+""); // int properties.setProperty(prefix+"mb_ers_index", this.mb_ers_index+""); // int properties.setProperty(prefix+"mb_ers_y_index", this.mb_ers_y_index+""); // int properties.setProperty(prefix+"mb_ers_r_index", this.mb_ers_r_index+""); // int properties.setProperty(prefix+"mb_all_index", this.mb_all_index+""); // int properties.setProperty(prefix+"mb_pref_orient", this.mb_pref_orient+""); // boolean properties.setProperty(prefix+"lma_use_Z", this.lma_use_Z+""); // boolean properties.setProperty(prefix+"lma_use_R", this.lma_use_R+""); // boolean properties.setProperty(prefix+"configured_lma", this.configured_lma+""); // boolean properties.setProperty(prefix+"freeze_xy_pull", this.freeze_xy_pull+""); // boolean properties.setProperty(prefix+"copy_pull_current", this.copy_pull_current+""); // boolean properties.setProperty(prefix+"restore_imu", this.restore_imu+""); // boolean properties.setProperty(prefix+"lpf_xy", this.lpf_xy+""); // boolean properties.setProperty(prefix+"readjust_xy_ims", this.readjust_xy_ims+""); // boolean properties.setProperty(prefix+"reg_weight_xy", this.reg_weight_xy+""); // double properties.setProperty(prefix+"stereo_merge", this.stereo_merge+""); // boolean properties.setProperty(prefix+"stereo_gap", this.stereo_gap+""); // int Loading Loading @@ -2409,8 +2481,22 @@ public class IntersceneMatchParameters { if (properties.getProperty(prefix+"mb_gain_index_pose")!=null) this.mb_gain_index_pose=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_pose")); if (properties.getProperty(prefix+"mb_gain_index_depth")!=null) this.mb_gain_index_depth=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_depth")); if (properties.getProperty(prefix+"mb_ers_index")!=null) this.mb_ers_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_index")); if (properties.getProperty(prefix+"mb_ers_y_index")!=null) this.mb_ers_y_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_y_index")); if (properties.getProperty(prefix+"mb_ers_r_index")!=null) this.mb_ers_r_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_r_index")); if (properties.getProperty(prefix+"mb_all_index")!=null) this.mb_all_index=Integer.parseInt(properties.getProperty(prefix+"mb_all_index")); if (properties.getProperty(prefix+"mb_pref_orient")!=null) this.mb_pref_orient=Boolean.parseBoolean(properties.getProperty(prefix+"mb_pref_orient")); if (properties.getProperty(prefix+"lma_use_Z")!=null) this.lma_use_Z=Boolean.parseBoolean(properties.getProperty(prefix+"lma_use_Z")); if (properties.getProperty(prefix+"lma_use_R")!=null) this.lma_use_R=Boolean.parseBoolean(properties.getProperty(prefix+"lma_use_R")); if (properties.getProperty(prefix+"configured_lma")!=null) this.configured_lma=Boolean.parseBoolean(properties.getProperty(prefix+"configured_lma")); if (properties.getProperty(prefix+"freeze_xy_pull")!=null) this.freeze_xy_pull=Boolean.parseBoolean(properties.getProperty(prefix+"freeze_xy_pull")); if (properties.getProperty(prefix+"copy_pull_current")!=null) this.copy_pull_current=Boolean.parseBoolean(properties.getProperty(prefix+"copy_pull_current")); if (properties.getProperty(prefix+"restore_imu")!=null) this.restore_imu=Boolean.parseBoolean(properties.getProperty(prefix+"restore_imu")); if (properties.getProperty(prefix+"lpf_xy")!=null) this.lpf_xy=Boolean.parseBoolean(properties.getProperty(prefix+"lpf_xy")); if (properties.getProperty(prefix+"readjust_xy_ims")!=null) this.readjust_xy_ims=Boolean.parseBoolean(properties.getProperty(prefix+"readjust_xy_ims")); if (properties.getProperty(prefix+"reg_weight_xy")!=null) this.reg_weight_xy=Double.parseDouble(properties.getProperty(prefix+"reg_weight_xy")); if (properties.getProperty(prefix+"stereo_merge")!=null) this.stereo_merge=Boolean.parseBoolean(properties.getProperty(prefix+"stereo_merge")); if (properties.getProperty(prefix+"stereo_gap")!=null) this.stereo_gap=Integer.parseInt(properties.getProperty(prefix+"stereo_gap")); Loading Loading @@ -2798,8 +2884,22 @@ public class IntersceneMatchParameters { imp.mb_gain_index_pose = this.mb_gain_index_pose; imp.mb_gain_index_depth = this.mb_gain_index_depth; imp.mb_ers_index = this.mb_ers_index; imp.mb_ers_y_index = this.mb_ers_y_index; imp.mb_ers_r_index = this.mb_ers_r_index; imp.mb_all_index = this.mb_all_index; imp.mb_pref_orient = this.mb_pref_orient; imp.lma_use_Z = this.lma_use_Z; imp.lma_use_R = this.lma_use_R; imp.configured_lma = this.configured_lma; imp.freeze_xy_pull = this.freeze_xy_pull; imp.copy_pull_current = this.copy_pull_current; imp.restore_imu = this.restore_imu; imp.lpf_xy = this.lpf_xy; imp.readjust_xy_ims = this.readjust_xy_ims; imp.reg_weight_xy = this.reg_weight_xy; imp.stereo_merge = this.stereo_merge; imp.stereo_gap = this.stereo_gap; Loading Loading
src/main/java/com/elphel/imagej/tileprocessor/ErsCorrection.java +8 −4 Original line number Diff line number Diff line Loading @@ -220,18 +220,22 @@ public class ErsCorrection extends GeometryCorrection { private double [][] ers_atr_dt; // angular velocities per scan line. It is now actually 2*omega! public static boolean [] getParamSelect( boolean use_Z, boolean use_R, boolean use_XY, boolean use_AT, boolean use_ERS, boolean use_ERS_tilt) { boolean use_ERS_tilt, boolean use_ERS_roll) { boolean [] param_select = new boolean[DP_NUM_PARS]; boolean use_ERS_roll = use_ERS && use_ERS_tilt; for (int i:DP_ZR_INDICES) param_select[i] = true; // for (int i:DP_ZR_INDICES) param_select[i] = true; if (use_Z || use_XY) param_select[DP_DSZ] = true; if (use_R || use_AT) param_select[DP_DSRL] = 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) param_select[DP_DSVAZ] = true; if (use_ERS && use_ERS_tilt) param_select[DP_DSVTL] = true; if (use_ERS_roll) param_select[DP_DSVRL] = true; if (use_ERS && use_ERS_roll) param_select[DP_DSVRL] = true; return param_select; } Loading
src/main/java/com/elphel/imagej/tileprocessor/Interscene.java +97 −20 Original line number Diff line number Diff line Loading @@ -322,7 +322,30 @@ public class Interscene { start_ref_pointers[0] = start_ref_pointers1[0]; return earliest_scene2; // cent_index; } if (generate_egomotion) { String ego_path = quadCLTs[cent_index].getX3dDirectory()+Prefs.getFileSeparator()+ quadCLTs[ref_index].getImageName()+ "-ego-preinvert-"+quadCLTs[cent_index].getNumOrient()+".csv"; String ego_comment = null; Interscene.generateEgomotionTable( clt_parameters, // CLTParameters clt_parameters, quadCLTs, // QuadCLT [] quadCLTs, cent_index,// ref_indx, earliest_scene, // int earliest_scene, ego_path, // String path, ego_comment); // String comment); if (debugLevel> -3) { System.out.println("Egomotion table saved to "+ego_path); } } // invert first half, reference to the cent_index, add to cent_index map, generate ref_index ponter and cent_index, if (debugLevel > -3) { System.out.println("pre invertInitialOrientation(): ref_index "+ref_index+", cent_index="+ cent_index+", last_index="+". readjust="+readjust+"\n"); } invertInitialOrientation( clt_parameters, // final CLTParameters clt_parameters, Loading @@ -335,6 +358,24 @@ public class Interscene { ref_index, // final int ref_old, // original ref_index (normally == last_index) earliest_scene2, //final int earliest_index// first to process debugLevel); // final int debugLevel if (generate_egomotion) { String ego_path = quadCLTs[cent_index].getX3dDirectory()+Prefs.getFileSeparator()+ quadCLTs[ref_index].getImageName()+ "-ego-afterinvert-"+quadCLTs[cent_index].getNumOrient()+".csv"; String ego_comment = null; Interscene.generateEgomotionTable( clt_parameters, // CLTParameters clt_parameters, quadCLTs, // QuadCLT [] quadCLTs, cent_index,// ref_indx, earliest_scene, // int earliest_scene, ego_path, // String path, ego_comment); // String comment); if (debugLevel> -3) { System.out.println("Egomotion table saved to "+ego_path); } } String cent_ts = quadCLTs[cent_index].getImageName(); // write config for both ref_index and cent_index scenes // ErsCorrection ers_reference = quadCLTs[ref_index].getErsCorrection(); Loading Loading @@ -425,12 +466,18 @@ public class Interscene { } return 0; } else { // if (readjust) { boolean lma_use_Z = clt_parameters.imp.lma_use_Z; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables boolean lma_use_R = clt_parameters.imp.lma_use_R; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables boolean[] param_select = ErsCorrection.getParamSelect( // ZR - always lma_use_Z, // boolean use_Z, lma_use_R, // boolean use_R, true, // boolean use_XY false, // boolean use_AT, false, // boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; false); // boolean use_ERS_tilt); false, // boolean use_ERS_tilt); false );// boolean use_ERS_roll); double maximal_series_rms = 0.0; double [][][] scenes_xyzatr = new double [last_index+1][][]; double [][][] dxyzatr_dt = new double [last_index+1][][]; Loading Loading @@ -761,12 +808,20 @@ public class Interscene { double max_zoom_diff = clt_parameters.imp.max_zoom_diff; boolean fpn_skip = clt_parameters.imp.fpn_skip; // if false - fail as before boolean fpn_rematch = clt_parameters.imp.fpn_rematch; // if false - keep previous boolean lma_use_Z = clt_parameters.imp.lma_use_Z; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables boolean lma_use_R = clt_parameters.imp.lma_use_R; // true; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables if (debugLevel > -3) { System.out.println("setInitialOrientationsIms(): lma_use_Z="+lma_use_Z+", lma_use_R="+lma_use_R); } boolean[] param_select = ErsCorrection.getParamSelect( // ZR - always true, // boolean use_XY false, // boolean use_AT, lma_use_Z, // boolean use_Z, lma_use_R, // boolean use_R, true, // boolean use_XY, May change with oorient preference false, // boolean use_AT, May change with oorient preference false, // boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; false); // boolean use_ERS_tilt); false, // boolean use_ERS_tilt); false); // boolean use_ERS_roll); int [] fail_reason = new int[1]; // null or int[1]: 0 - OK, 2 - LMA, 3 - min, 4 - max for (int scene_index = ref_index - 1; scene_index >= 0 ; scene_index--) { Loading Loading @@ -1815,8 +1870,12 @@ public class Interscene { public static int reAdjustPairsLMAInterscene( // after combo dgi is available and preliminary poses are known CLTParameters clt_parameters, double mb_max_gain, boolean use_Z, boolean use_R, boolean disable_ers, boolean disable_ers_y, boolean disable_ers_r, boolean lma_xyzatr, boolean configured_lma, boolean lpf_xy, // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables double avg_rlen, Loading @@ -1833,16 +1892,20 @@ public class Interscene { int debugLevel) { System.out.println("reAdjustPairsLMAInterscene(): using mb_max_gain="+mb_max_gain+ ", disable_ers="+disable_ers+", disable_ers_y="+disable_ers_y); boolean freeze_xy_pull = true; // false; // true; // debugging freezing xy to xy_pull boolean copy_pull_current = false; // true; boolean restore_imu = false; // restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl ", disable_ers="+disable_ers+", disable_ers_y="+disable_ers_y+ ", use_Z="+use_Z+", use_R="+use_R); boolean freeze_xy_pull = clt_parameters.imp.freeze_xy_pull; // true; // false; // true; // debugging freezing xy to xy_pull boolean copy_pull_current = clt_parameters.imp.copy_pull_current; //false; // true; boolean restore_imu = clt_parameters.imp.restore_imu; //false; // restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl boolean[] param_select = configured_lma? clt_parameters.ilp.ilma_lma_select : ErsCorrection.getParamSelect( true, // !freeze_xy_pull && (!readjust_xy_ims || (reg_weight_xy != 0)), // false only in mode c): freeze X,Y// boolean use_XY true, // readjust_xy_ims || lpf_xy, // boolean use_AT, lma_xyzatr || use_Z, // boolean use_Z, lma_xyzatr || use_R, // boolean use_R, lma_xyzatr || ( !freeze_xy_pull && (!readjust_xy_ims || (reg_weight_xy != 0))), // false only in mode c): freeze X,Y// boolean use_XY lma_xyzatr || ( readjust_xy_ims || lpf_xy), // boolean use_AT, !disable_ers, //boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; !disable_ers_y); // boolean use_ERS_tilt); !disable_ers_y, // boolean use_ERS_tilt, !disable_ers_r); // boolean use_ERS_roll); final double [] param_regweights = configured_lma? clt_parameters.ilp.ilma_regularization_weights : ErsCorrection.getParamRegWeights( (freeze_xy_pull? 0.0: reg_weight_xy)); // double reg_weight, Loading Loading @@ -1996,10 +2059,13 @@ public class Interscene { } } param_select = ErsCorrection.getParamSelect( true, // boolean use_Z, true, // boolean use_R, true, // boolean use_XY true, // boolean use_AT, false, // boolean use_ERS);//clt_parameters.ilp.ilma_lma_select; false); // boolean use_ERS_tilt); false, // boolean use_ERS_tilt); false); // boolean use_ERS_roll); } // optionally filter by averaging and "IMU" (actually current dxyzatr_dt). Loading Loading @@ -5118,7 +5184,18 @@ public class Interscene { sb.append(nscene+"\t"+timestamp); if (use_processed) { double [] nan3 = new double[] {Double.NaN, Double.NaN,Double.NaN}; double [][] nan23 = new double[][] {nan3,nan3}; if (scenes_xyzatr[nscene] != null) { if (scenes_xyzatr[nscene][0] == null) scenes_xyzatr[nscene][0]= nan3; if (scenes_xyzatr[nscene][1] == null) scenes_xyzatr[nscene][1]= nan3; if (dxyzatr_dt[nscene]== null) dxyzatr_dt[nscene] = nan23; if (dxyzatr_dt[nscene][0] == null) dxyzatr_dt[nscene][0]= nan3; if (dxyzatr_dt[nscene][0] == null) dxyzatr_dt[nscene][0]= nan3; if (scenes_xyzatr_dt[nscene]== null) scenes_xyzatr_dt[nscene] = nan23; if (scenes_xyzatr_dt[nscene][0] == null) scenes_xyzatr_dt[nscene][0]= nan3; if (scenes_xyzatr_dt[nscene][0] == null) scenes_xyzatr_dt[nscene][0]= nan3; // x,y,z - scene position in reference scene frame (reference scene is all 0-s) sb.append("\t"+scenes_xyzatr[nscene][0][0]+"\t"+scenes_xyzatr[nscene][0][1]+"\t"+scenes_xyzatr[nscene][0][2]); // a,tilt,roll - scene orientation in reference scene frame (reference scene is all 0-s) Loading
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java +109 −9 Original line number Diff line number Diff line Loading @@ -370,7 +370,7 @@ public class IntersceneMatchParameters { public double max_zoom_diff = 0; // for down-views when changing altitude (0 - ignore) public boolean fpn_skip = true; // skip too close scenes (false - abort, previous behavior) public boolean fpn_rematch = true; // match fpn-failed scenes to later scenes with larger difference public boolean refine_invert = true; // Refine with LMA while inverting relative poses from other reference public boolean refine_invert = false; // Refine with LMA while inverting relative poses from other reference // Remove moving objects (goal is not to detect slightest movement, but to improve pose matching public boolean mov_en = true; // enable detection/removal of the moving objects during pose matching Loading Loading @@ -413,11 +413,27 @@ public class IntersceneMatchParameters { public double mb_tau = 0.008; // time constant, sec public double mb_max_gain = 5.0; // motion blur maximal gain (if more - move second point more than a pixel public double mb_max_gain_inter = 2.0; // same for interscene correlation for pose adjustment // TODO: move next parameters elsewhere - they are not the motion blur ones. public int mb_gain_index_pose = 5; // pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter public int mb_gain_index_depth = 5; // depth map refine pass (SfM) to switch to full mb_max_gain from mb_max_gain_inter public int mb_ers_index = 2; // pose readjust pass to enable ERS public int mb_ers_index = 3; // pose readjust pass to enable ERS public int mb_ers_y_index = 3; // pose readjust pass to enable ERS in vertical (Y) direction - it competes with SfM public int mb_ers_r_index = 3; // pose readjust pass to enable ERS in vertical (Y) direction - it competes with SfM public int mb_all_index = 4; // simultaneously LMA-adjust XYZATR plus optional angular ERS public boolean mb_pref_orient = true; // rely on IMU orientation before position public boolean lma_use_Z = true; // LMA adjust Z public boolean lma_use_R = true; // LMA adjust R // FIXME: some of the following parameters will be modified or removed public boolean configured_lma = false; public boolean freeze_xy_pull = true; // false; // true; // debugging freezing xy to xy_pull public boolean copy_pull_current = false; // true; public boolean restore_imu = false; // restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl public boolean lpf_xy = false; // lpf x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables public boolean readjust_xy_ims = true; // false; public double reg_weight_xy = 0; // 10.0; // 1.0; // 10.0; // 0.05; // TODO: find out reasonable values public boolean stereo_merge = true; public int stereo_gap = 32; // pixels between right and left frames Loading Loading @@ -1186,7 +1202,8 @@ public class IntersceneMatchParameters { "Maximal gain for motion blur correction (if needed more for 1 pixel, increase offset). Will be forced fro the last adjustment"); gd.addNumericField("Maximal gain pose", this.mb_max_gain_inter, 5,7,"x", "Maximal gain for motion blur correction during interscene correlation. Will be used for all but the last adjustment."); gd.addTab("LMA sequence","Interscene LMA sequence control"); gd.addMessage("Parameters for control of the LMA pose adjustment sequence"); gd.addNumericField("Pose readjust number for full mb_gain", this.mb_gain_index_pose, 0,3,"", "Pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter."); gd.addNumericField("Depth map refine number for full mb_gain",this.mb_gain_index_depth, 0,3,"", Loading @@ -1195,6 +1212,34 @@ public class IntersceneMatchParameters { "Pose readjust pass to enable ERS."); gd.addNumericField("Pose readjust number to enable tilt ERS LMA",this.mb_ers_y_index, 0,3,"", "Pose readjust pass to enable ERS in vertical (Y) direction - it competes with SfM."); gd.addNumericField("Pose readjust number to enable roll ERS LMA",this.mb_ers_r_index, 0,3,"", "Pose readjust pass to enable ERS roll adjustment."); gd.addNumericField("Pose readjust number to enable all XYZATR",this.mb_all_index, 0,3,"", "Enables 6 DOF adjustment for one pass, ERS parameters adjusted separately above."); gd.addCheckbox ("Rely on IMS orientation before position", this.mb_pref_orient, "First use IMS orientation, later use IMS position. If false - reverse order."); gd.addCheckbox ("LMA adjust Z", this.lma_use_Z, "Always adjust Z (altitude) when running interscene LMA. False - same as X and Y."); gd.addCheckbox ("LMA adjust roll", this.lma_use_R, "Always adjust roll when running interscene LMA. False - same as Azimuth and Tilt."); gd.addMessage ("Other Interscene LMA parameters to be modified/replaced/removed"); gd.addCheckbox ("Use configuration LMA parameters", this.configured_lma, "Use configuration LMA parameters, disregard onther parameters that influence LMA parameters."); gd.addCheckbox ("Freeze XY pull", this.freeze_xy_pull, "Freeze XY target values, approach with smaller steps if needed ."); gd.addCheckbox ("Copy pull values to current", this.copy_pull_current, "Replace current (start) values with the \"pull\" ones."); gd.addCheckbox ("Restore ERS to IMU velocities", this.restore_imu, "restore imu omega-az and omega-tl, freeze ERS, adjust X,Y,Z,Az,Tl,Rl."); gd.addCheckbox ("LPF X and Y", this.lpf_xy, "LPF x and y, re-adjust X,Y,Z,A,T,R with pull for X,Y. Disables - what?."); gd.addCheckbox ("Readjust XY from IMS", this.readjust_xy_ims, "Readjust X,Y from IMS linear/angular and full X,Y movement."); gd.addNumericField("LMA regularization weight", this.reg_weight_xy, 5,7,"", "Regularization weight for LMA"); gd.addTab("Stereo/Video","Parameters for stereo video generation"); Loading Loading @@ -1609,11 +1654,24 @@ public class IntersceneMatchParameters { this.mb_tau = gd.getNextNumber(); this.mb_max_gain = gd.getNextNumber(); this.mb_max_gain_inter = gd.getNextNumber(); this.mb_gain_index_pose = (int) gd.getNextNumber(); this.mb_gain_index_depth =(int) gd.getNextNumber(); this.mb_ers_index = (int) gd.getNextNumber(); this.mb_ers_y_index = (int) gd.getNextNumber(); this.mb_ers_r_index = (int) gd.getNextNumber(); this.mb_all_index = (int) gd.getNextNumber(); this.mb_pref_orient = gd.getNextBoolean(); this.lma_use_Z = gd.getNextBoolean(); this.lma_use_R = gd.getNextBoolean(); this.configured_lma = gd.getNextBoolean(); this.freeze_xy_pull = gd.getNextBoolean(); this.copy_pull_current = gd.getNextBoolean(); this.restore_imu = gd.getNextBoolean(); this.lpf_xy = gd.getNextBoolean(); this.readjust_xy_ims = gd.getNextBoolean(); this.reg_weight_xy = gd.getNextNumber(); if (stereo_views.length > 0) { int i = gd.getNextChoiceIndex(); Loading Loading @@ -2030,8 +2088,22 @@ public class IntersceneMatchParameters { properties.setProperty(prefix+"mb_gain_index_pose", this.mb_gain_index_pose+""); // int properties.setProperty(prefix+"mb_gain_index_depth", this.mb_gain_index_depth+""); // int properties.setProperty(prefix+"mb_ers_index", this.mb_ers_index+""); // int properties.setProperty(prefix+"mb_ers_y_index", this.mb_ers_y_index+""); // int properties.setProperty(prefix+"mb_ers_r_index", this.mb_ers_r_index+""); // int properties.setProperty(prefix+"mb_all_index", this.mb_all_index+""); // int properties.setProperty(prefix+"mb_pref_orient", this.mb_pref_orient+""); // boolean properties.setProperty(prefix+"lma_use_Z", this.lma_use_Z+""); // boolean properties.setProperty(prefix+"lma_use_R", this.lma_use_R+""); // boolean properties.setProperty(prefix+"configured_lma", this.configured_lma+""); // boolean properties.setProperty(prefix+"freeze_xy_pull", this.freeze_xy_pull+""); // boolean properties.setProperty(prefix+"copy_pull_current", this.copy_pull_current+""); // boolean properties.setProperty(prefix+"restore_imu", this.restore_imu+""); // boolean properties.setProperty(prefix+"lpf_xy", this.lpf_xy+""); // boolean properties.setProperty(prefix+"readjust_xy_ims", this.readjust_xy_ims+""); // boolean properties.setProperty(prefix+"reg_weight_xy", this.reg_weight_xy+""); // double properties.setProperty(prefix+"stereo_merge", this.stereo_merge+""); // boolean properties.setProperty(prefix+"stereo_gap", this.stereo_gap+""); // int Loading Loading @@ -2409,8 +2481,22 @@ public class IntersceneMatchParameters { if (properties.getProperty(prefix+"mb_gain_index_pose")!=null) this.mb_gain_index_pose=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_pose")); if (properties.getProperty(prefix+"mb_gain_index_depth")!=null) this.mb_gain_index_depth=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_depth")); if (properties.getProperty(prefix+"mb_ers_index")!=null) this.mb_ers_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_index")); if (properties.getProperty(prefix+"mb_ers_y_index")!=null) this.mb_ers_y_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_y_index")); if (properties.getProperty(prefix+"mb_ers_r_index")!=null) this.mb_ers_r_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_r_index")); if (properties.getProperty(prefix+"mb_all_index")!=null) this.mb_all_index=Integer.parseInt(properties.getProperty(prefix+"mb_all_index")); if (properties.getProperty(prefix+"mb_pref_orient")!=null) this.mb_pref_orient=Boolean.parseBoolean(properties.getProperty(prefix+"mb_pref_orient")); if (properties.getProperty(prefix+"lma_use_Z")!=null) this.lma_use_Z=Boolean.parseBoolean(properties.getProperty(prefix+"lma_use_Z")); if (properties.getProperty(prefix+"lma_use_R")!=null) this.lma_use_R=Boolean.parseBoolean(properties.getProperty(prefix+"lma_use_R")); if (properties.getProperty(prefix+"configured_lma")!=null) this.configured_lma=Boolean.parseBoolean(properties.getProperty(prefix+"configured_lma")); if (properties.getProperty(prefix+"freeze_xy_pull")!=null) this.freeze_xy_pull=Boolean.parseBoolean(properties.getProperty(prefix+"freeze_xy_pull")); if (properties.getProperty(prefix+"copy_pull_current")!=null) this.copy_pull_current=Boolean.parseBoolean(properties.getProperty(prefix+"copy_pull_current")); if (properties.getProperty(prefix+"restore_imu")!=null) this.restore_imu=Boolean.parseBoolean(properties.getProperty(prefix+"restore_imu")); if (properties.getProperty(prefix+"lpf_xy")!=null) this.lpf_xy=Boolean.parseBoolean(properties.getProperty(prefix+"lpf_xy")); if (properties.getProperty(prefix+"readjust_xy_ims")!=null) this.readjust_xy_ims=Boolean.parseBoolean(properties.getProperty(prefix+"readjust_xy_ims")); if (properties.getProperty(prefix+"reg_weight_xy")!=null) this.reg_weight_xy=Double.parseDouble(properties.getProperty(prefix+"reg_weight_xy")); if (properties.getProperty(prefix+"stereo_merge")!=null) this.stereo_merge=Boolean.parseBoolean(properties.getProperty(prefix+"stereo_merge")); if (properties.getProperty(prefix+"stereo_gap")!=null) this.stereo_gap=Integer.parseInt(properties.getProperty(prefix+"stereo_gap")); Loading Loading @@ -2798,8 +2884,22 @@ public class IntersceneMatchParameters { imp.mb_gain_index_pose = this.mb_gain_index_pose; imp.mb_gain_index_depth = this.mb_gain_index_depth; imp.mb_ers_index = this.mb_ers_index; imp.mb_ers_y_index = this.mb_ers_y_index; imp.mb_ers_r_index = this.mb_ers_r_index; imp.mb_all_index = this.mb_all_index; imp.mb_pref_orient = this.mb_pref_orient; imp.lma_use_Z = this.lma_use_Z; imp.lma_use_R = this.lma_use_R; imp.configured_lma = this.configured_lma; imp.freeze_xy_pull = this.freeze_xy_pull; imp.copy_pull_current = this.copy_pull_current; imp.restore_imu = this.restore_imu; imp.lpf_xy = this.lpf_xy; imp.readjust_xy_ims = this.readjust_xy_ims; imp.reg_weight_xy = this.reg_weight_xy; imp.stereo_merge = this.stereo_merge; imp.stereo_gap = this.stereo_gap; Loading