Commit efe4ede4 authored by Andrey Filippov's avatar Andrey Filippov

LY adjustment for each sequence

parent eeacc90a
......@@ -44,6 +44,15 @@ public class EstimateSceneRange {
return center;
}
public void limitRange(int range) {
int late_lim = center + range/2; // will be symmetrical for odd values
latest = Math.min(latest, late_lim);
int early_lim = latest - range+1;
earliest = Math.max(earliest, early_lim);
earliest_prescan = Math.max(earliest_prescan, earliest);
latest_prescan = Math.min(latest_prescan, latest);
needs_prescan = (earliest_prescan > earliest) || (latest_prescan < latest);
}
public static EstimateSceneRange getPrescanRange(
final CLTParameters clt_parameters,
......@@ -57,7 +66,8 @@ public class EstimateSceneRange {
System.out.println("getPrescanRange(): Will re-evaluate ranges, so new center may be different than"+
" early_scene of the current ref_index");
}
// Will only limit scan around the center, the center location is the same regardless. It is to keep the same
// center reference scene (it can still change caused by LY adjustment?)
boolean lock_position = clt_parameters.imp.lock_position;
int tilesX = quadCLTs[ref_index].getTileProcessor().getTilesX();
int tile_size = quadCLTs[ref_index].getTileProcessor().getTileSize();
......
......@@ -150,6 +150,7 @@ public class Interscene {
*/
public static int setInitialOrientationsCenterIms(
final CLTParameters clt_parameters,
final int operation_mode, // 0 - normal, 1 - prepare for LY field calibration (reduced scenes)
final boolean compensate_ims_rotation, // probably deprecated
final boolean inertial_only,
int min_num_scenes,
......@@ -245,6 +246,7 @@ public class Interscene {
// find earliest, center and last scenes from the average altitude, IMS and max_meters. if it is a limiting factor,
// perform short scan around the center and use SFP to improve disparity before trying to adjust orientations for
// the full scene range
// TODO: apply the same range limit to other modes
EstimateSceneRange prescan_range_center= EstimateSceneRange.getPrescanRange(
clt_parameters, // final CLTParameters clt_parameters,
quadCLTs, // final QuadCLT[] quadCLTs,
......@@ -253,6 +255,13 @@ public class Interscene {
set_channels, // final SetChannels [] set_channels,
batch_mode, // final boolean batch_mode,
debugLevel); // final int debugLevel) {
// Will only limit scan around the center, the center location is the same regardless. It is to keep the same
// center reference scene (it can still change caused by LY adjustment?)
if (operation_mode == OpticalFlow.RESULTS_BUILD_SEQ_LY) {
prescan_range_center.limitRange(clt_parameters.imp.run_ly_scenes);
}
boolean prescan_ok = EstimateSceneRange.scanSfmIMS(
clt_parameters, // final CLTParameters clt_parameters,
prescan_range_center, // EstimateSceneRange estimateSceneRange,
......@@ -316,20 +325,25 @@ public class Interscene {
// set pointers Check here - why reference is not set?
String cent_ts = quadCLTs[cent_index].getImageName();
quadCLTs[latest_scene2].setRefPointer(cent_ts); // write pointer to center scene to reference scene
quadCLTs[latest_scene2].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) // null pointer
quadCLTs[ref_index].setRefPointer(cent_ts); // write pointer to center scene to reference scene
quadCLTs[ref_index].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) // null pointer
null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1);
if (latest_scene2 != ref_index) {
System.out.println("*** setInitialOrientationsCenterIms(): assumed that latest_scene2("+latest_scene2+
") == ref_index ("+ref_index+"), but they are different. Decide what to do - see EstimateSceneRange.getPrescanRange(). ***");
System.out.println("The problem is that the center index will have pointers to the first and last, but the last will not have a pointrer back.");
quadCLTs[ref_index].setRefPointer(cent_ts); // write pointer to center scene to reference scene
quadCLTs[ref_index].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) // null pointer
null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1);
if(operation_mode == OpticalFlow.RESULTS_BUILD_SEQ_LY) {
System.out.println("Using reference scene "+quadCLTs[ref_index].getImageName()+" ("+ref_index+
") even as it does not match latest_scene2="+latest_scene2+
" in LY mode that has shortened sequence for faster adjustment.");
} else {
System.out.println("*** setInitialOrientationsCenterIms(): assumed that latest_scene2("+latest_scene2+
") == ref_index ("+ref_index+"), but they are different. Decide what to do - see EstimateSceneRange.getPrescanRange(). ***");
System.out.println("The problem is that the center index will have pointers to the first and last, but the last will not have a pointrer back. Resolution - using a separate index scene (latest).");
quadCLTs[latest_scene2].setRefPointer(cent_ts); // write pointer to center scene to reference scene
quadCLTs[latest_scene2].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...) // null pointer
null, // String path, // full name with extension or w/o path to use x3d directory
debugLevel+1);
}
}
// Here we a
quadCLTs[cent_index].setFirstLastPointers(quadCLTs[earliest_scene2],quadCLTs[latest_scene2]);// set first/last to center scene
......@@ -350,6 +364,7 @@ public class Interscene {
// TODO: add ref scene itself to the list?
cent_index = setInitialOrientationsIms( // process latest "half"
clt_parameters, // final CLTParameters clt_parameters,
operation_mode, // final int operation_mode, // 0 - normal, 1 - prepare for LY field calibration (reduced scenes)
compensate_ims_rotation, // final boolean compensate_ims_rotation,
inertial_only, // final boolean inertial_only,
min_num_scenes_half, // int min_num_scenes,
......@@ -402,7 +417,7 @@ public class Interscene {
boolean generate_egomotion = clt_parameters.imp.generate_egomotion; // generate egomotion table (image-based and ims)
if (generate_egomotion) {
String ego_path = quadCLTs[ref_index].getX3dDirectory()+Prefs.getFileSeparator()+
String ego_path = quadCLTs[ref_index].getX3dDirectory(true)+Prefs.getFileSeparator()+
quadCLTs[ref_index].getImageName()+
"-ego-first_half.csv";
String ego_comment = null;
......@@ -456,6 +471,7 @@ public class Interscene {
quadCLTs[cent_index].setQuatCorr(quadCLTs[ref_index].getQuatCorr());
int earliest_scene2 = setInitialOrientationsIms( // process earliest "half". Should copy quat_corr from the latest_half build
clt_parameters, // final CLTParameters clt_parameters,
operation_mode, // final int operation_mode, // 0 - normal, 1 - prepare for LY field calibration (reduced scenes)
compensate_ims_rotation, // final boolean compensate_ims_rotation,
inertial_only, // final boolean inertial_only,
min_num_scenes_half, // int min_num_scenes,
......@@ -506,7 +522,7 @@ public class Interscene {
if (generate_egomotion) {
String ego_path = quadCLTs[cent_index].getX3dDirectory()+Prefs.getFileSeparator()+
String ego_path = quadCLTs[cent_index].getX3dDirectory(true)+Prefs.getFileSeparator()+
quadCLTs[ref_index].getImageName()+
"-ego-preinvert-"+quadCLTs[cent_index].getNumOrient()+".csv";
String ego_comment = null;
......@@ -548,7 +564,7 @@ public class Interscene {
// here - calculate quat_corr and update it in ref_index. It will be used to pull to IMU when refining.
if (generate_egomotion) {
String ego_path = quadCLTs[cent_index].getX3dDirectory()+Prefs.getFileSeparator()+
String ego_path = quadCLTs[cent_index].getX3dDirectory(true)+Prefs.getFileSeparator()+
quadCLTs[ref_index].getImageName()+
"-ego-afterinvert-"+quadCLTs[cent_index].getNumOrient()+".csv";
String ego_comment = null;
......@@ -1088,6 +1104,7 @@ public class Interscene {
public static int setInitialOrientationsIms(
final CLTParameters clt_parameters,
final int operation_mode, // 0 - normal, 1 - prepare for LY field calibration (reduced scenes)
final boolean compensate_ims_rotation,
final boolean inertial_only,
int min_num_scenes,
......@@ -1800,6 +1817,7 @@ public class Interscene {
public static int setInitialOrientationsCuas(
final CLTParameters clt_parameters,
final int operation_mode, // 0 - normal, 1 - prepare for LY field calibration (reduced scenes)
final double [][] center_xyzatr, // center_xyzatr[0]=ZERO3 - for this sequence
final QuadCLT center_CLT, // contains center CLT and DSI
final boolean compensate_ims_rotation,
......@@ -2225,7 +2243,7 @@ public class Interscene {
}
if (generate_egomotion) {
String ego_path = center_CLT.getX3dDirectory()+Prefs.getFileSeparator()+
String ego_path = center_CLT.getX3dDirectory(true)+Prefs.getFileSeparator()+
center_CLT.getImageName()+
"-ego-initial-cuas-"+center_CLT.getNumOrient()+".csv";
String ego_comment = null;
......@@ -2411,6 +2429,7 @@ public class Interscene {
public static int setInitialOrientations(
final CLTParameters clt_parameters,
final int operation_mode, // 0 - normal, 1 - prepare for LY field calibration (reduced scenes)
int min_num_scenes,
final ColorProcParameters colorProcParameters,
final QuadCLT[] quadCLTs, //
......
......@@ -318,6 +318,9 @@ public class IntersceneMatchParameters {
public boolean force_ref_dsi = false; // true;
public boolean force_orientations = false;
public boolean run_ly = false; // will return just after LY adjustments, skipping all output generation
public boolean force_ly = false; // calculate field calibration for this series even if it was calibrated earlier
public boolean continue_ly = true; // re-run series after performing LY correction (and rename version subdirectory)
public int run_ly_scenes = 11; // Limit number of scenes to use for LY adjustments
public int run_ly_mode = 3; // +1 - lazy eye, +2 - infinity
public boolean run_ly_ims = false; // adjust infinity (if enabled) using horizontal movement from the IMS
public boolean run_ly_lma = true;
......@@ -1789,6 +1792,13 @@ min_str_neib_fpn 0.35
"Calculate relative poses of each scene camera relative to the reference scene even if the data exists.");
gd.addCheckbox ("Run LY adjustments", this.run_ly,
"Adjust cameras orientations (after building DSI) and exit without generatin result files.");
gd.addCheckbox ("Force LY adjustments", this.force_ly,
"Perform calibration even if it was already done earlier. requires Run LY to be set");
gd.addCheckbox ("Continue after LY adjustments", this.continue_ly,
"Restart series after LY calibration and rename version directory left after orientation for LY.");
gd.addNumericField("Number of LY scenes", this.run_ly_scenes, 0,3,"",
"Limit the number of oriented scenes to calculate and use for LY adjustment.");
gd.addNumericField("LY mode",this.run_ly_mode, 0,3,"", "+1 - Lazy Eye, +2 - infinity");
gd.addCheckbox ("LY infinity from IMS", this.run_ly_ims,
"Use horizontal movement from the IMS to adjust infinity disparity (if enabled above).");
......@@ -3782,6 +3792,9 @@ min_str_neib_fpn 0.35
this.force_ref_dsi = gd.getNextBoolean();
this.force_orientations = gd.getNextBoolean();
this.run_ly = gd.getNextBoolean();
this.force_ly = gd.getNextBoolean();
this.continue_ly = gd.getNextBoolean();
this.run_ly_scenes = (int) gd.getNextNumber();
this.run_ly_mode = ((int) gd.getNextNumber()) & 3;
this.run_ly_ims = gd.getNextBoolean();
this.run_ly_lma = gd.getNextBoolean();
......@@ -5020,6 +5033,9 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"force_ref_dsi", this.force_ref_dsi + ""); // boolean
properties.setProperty(prefix+"force_orientations", this.force_orientations + ""); // boolean
properties.setProperty(prefix+"run_ly", this.run_ly + ""); // boolean
properties.setProperty(prefix+"force_ly", this.force_ly + ""); // boolean
properties.setProperty(prefix+"continue_ly", this.continue_ly + ""); // boolean
properties.setProperty(prefix+"run_ly_scenes", this.run_ly_scenes+""); // int
properties.setProperty(prefix+"run_ly_mode", this.run_ly_mode+""); // int
properties.setProperty(prefix+"run_ly_ims", this.run_ly_ims + ""); // boolean
properties.setProperty(prefix+"run_ly_lma", this.run_ly_lma + ""); // boolean
......@@ -6200,6 +6216,9 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"force_ref_dsi")!=null) this.force_ref_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"force_ref_dsi"));
if (properties.getProperty(prefix+"force_orientations")!=null) this.force_orientations=Boolean.parseBoolean(properties.getProperty(prefix+"force_orientations"));
if (properties.getProperty(prefix+"run_ly")!=null) this.run_ly=Boolean.parseBoolean(properties.getProperty(prefix+"run_ly"));
if (properties.getProperty(prefix+"force_ly")!=null) this.force_ly=Boolean.parseBoolean(properties.getProperty(prefix+"force_ly"));
if (properties.getProperty(prefix+"continue_ly")!=null) this.continue_ly=Boolean.parseBoolean(properties.getProperty(prefix+"continue_ly"));
if (properties.getProperty(prefix+"run_ly_scenes")!=null) this.run_ly_scenes=Integer.parseInt(properties.getProperty(prefix+"run_ly_scenes"));
if (properties.getProperty(prefix+"run_ly_mode")!=null) this.run_ly_mode=Integer.parseInt(properties.getProperty(prefix+"run_ly_mode"));
if (properties.getProperty(prefix+"run_ly_ims")!=null) this.run_ly_ims=Boolean.parseBoolean(properties.getProperty(prefix+"run_ly_ims"));
if (properties.getProperty(prefix+"run_ly_lma")!=null) this.run_ly_lma=Boolean.parseBoolean(properties.getProperty(prefix+"run_ly_lma"));
......@@ -7412,6 +7431,9 @@ min_str_neib_fpn 0.35
imp.force_ref_dsi = this.force_ref_dsi;
imp.force_orientations = this.force_orientations;
imp.run_ly = this.run_ly;
imp.force_ly = this.force_ly;
imp.continue_ly = this.continue_ly;
imp.run_ly_scenes = this.run_ly_scenes;
imp.run_ly_mode = this.run_ly_mode;
imp.run_ly_ims = this.run_ly_ims;
imp.run_ly_lma = this.run_ly_lma;
......
......@@ -902,6 +902,7 @@ public class QuadCLT extends QuadCLTCPU {
// added 12/21
@Deprecated
public void processCLTQuadCorrs( // not used in lwir
CLTParameters clt_parameters,
ColorProcParameters colorProcParameters,
......@@ -3927,7 +3928,7 @@ public class QuadCLT extends QuadCLTCPU {
if (clt_parameters.gen_4_img) { // save 4 JPEG images
// Save as individual JPEG images in the model directory
String x3d_path = getX3dDirectory();
String x3d_path = getX3dDirectory(true);
for (int sub_img = 0; sub_img < imps_RGB.length; sub_img++){
EyesisCorrections.saveAndShow(
imps_RGB[sub_img],
......@@ -4677,7 +4678,7 @@ public class QuadCLT extends QuadCLTCPU {
if (clt_parameters.gen_4_img) { // save 4 JPEG images
// Save as individual JPEG images in the model directory
String x3d_path= quadCLT_main.getX3dDirectory();
String x3d_path= quadCLT_main.getX3dDirectory(true);
for (int sub_img = 0; sub_img < imps_RGB.length; sub_img++){
EyesisCorrections.saveAndShow(
imps_RGB[sub_img],
......
......@@ -3212,7 +3212,7 @@ public class TexturedModel {
EyesisCorrectionParameters.CorrectionParameters correctionsParameters = ref_scene.correctionsParameters;
String x3d_dir = ref_scene.getX3dDirectory();
String x3d_dir = ref_scene.getX3dDirectory(true);
boolean use_png = (jpeg_quality <= 0) || !no_alpha;
if (save_full_textures) { // || !split_textures) {
for (int nslice = 0; nslice < combined_textures.length; nslice++) {
......
......@@ -833,7 +833,7 @@ public class VegetationModel {
return;
}
String dir_state = quadCLTs[ref_index].getX3dDirectory(); // getX3dTopDirectory();
String dir_state = quadCLTs[ref_index].getX3dDirectory(true); // getX3dTopDirectory();
String title_state = quadCLTs[ref_index].getImageName()+"-TERR-VEG-STATE";
vegetationModel.saveState(
dir_state, // String dir,
......
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