Commit 8b5bd41b authored by Andrey Filippov's avatar Andrey Filippov

Updated/tested with center reference

parent a095795c
......@@ -484,7 +484,7 @@ public class CLTParameters {
public boolean generate_bg = true; // Generate background image for 3dmodels
public boolean show_textures = true; // show generated textures
public boolean debug_filters = false;// show intermediate results of filtering
// not used anywhere so far
......@@ -1624,6 +1624,7 @@ public class CLTParameters {
properties.setProperty(prefix+"gmap_crop_extra", this.gmap_crop_extra+""); // int
properties.setProperty(prefix+"gmap_tex_pals", CLTParameters.arr_to_str(this.gmap_tex_pals)); // int[]
properties.setProperty(prefix+"generate_bg", this.generate_bg+"");
properties.setProperty(prefix+"show_textures", this.show_textures+"");
properties.setProperty(prefix+"debug_filters", this.debug_filters+"");
......@@ -2639,6 +2640,7 @@ public class CLTParameters {
if (properties.getProperty(prefix+"gmap_crop_extra")!=null) this.gmap_crop_extra=Integer.parseInt(properties.getProperty(prefix+ "gmap_crop_extra"));// int
if (properties.getProperty(prefix+"gmap_tex_pals")!=null) this.gmap_tex_pals=CLTParameters.str_to_iarr(properties.getProperty(prefix+"gmap_tex_pals"));
if (properties.getProperty(prefix+"generate_bg")!=null) this.generate_bg=Boolean.parseBoolean(properties.getProperty(prefix+"generate_bg"));
if (properties.getProperty(prefix+"show_textures")!=null) this.show_textures=Boolean.parseBoolean(properties.getProperty(prefix+"show_textures"));
if (properties.getProperty(prefix+"debug_filters")!=null) this.debug_filters=Boolean.parseBoolean(properties.getProperty(prefix+"debug_filters"));
......@@ -3900,6 +3902,7 @@ public class CLTParameters {
gd.addMessage ("Earlier 3D generation parameters");
gd.addCheckbox ("Generate background (infinity) image for 3D (not needed for view down)", this.generate_bg);
gd.addCheckbox ("Show generated textures", this.show_textures);
gd.addCheckbox ("show intermediate results of filtering", this.debug_filters);
......@@ -5112,6 +5115,7 @@ public class CLTParameters {
this.gmap_tex_pals = CLTParameters.str_to_iarr(gd.getNextString());
this.generate_bg= gd.getNextBoolean();
this.show_textures= gd.getNextBoolean();
this.debug_filters= gd.getNextBoolean();
this.min_smth= gd.getNextNumber();
......
......@@ -237,6 +237,10 @@ public class ErsCorrection extends GeometryCorrection {
public double [] getCameraATR() {
return camera_atr;
}
public double [][] getErsXYZATR_dt() {
return new double[][] {ers_wxyz_center_dt,ers_watr_center_dt};
}
public double [] getErsXYZ_dt() {
return ers_wxyz_center_dt;
}
......@@ -378,7 +382,7 @@ public class ErsCorrection extends GeometryCorrection {
scenes_poses = new HashMap <String, XyzAtr>();
}
public void removeScene(String timestamp) {
public void removeScene(String timestamp) { // not used
scenes_poses.remove(timestamp);
}
......@@ -393,20 +397,45 @@ public class ErsCorrection extends GeometryCorrection {
return scenes;
}
public void addScene(String timestamp, XyzAtr scene) {
scenes_poses.put(timestamp, scene);
public void addScene(String timestamp) { // will it work?
// scenes_poses.put(timestamp, null);
scenes_poses.remove(timestamp);
}
public void addScene(String timestamp, XyzAtr scene) { // will it work?
if (scene != null) {
scenes_poses.put(timestamp, scene);
} else {
scenes_poses.remove(timestamp);
}
}
public void addScene(String timestamp, double [] xyz, double [] atr) {
scenes_poses.put(timestamp, new XyzAtr(xyz, atr));
}
public void addScene(String timestamp, double [][] xyzatr) {
scenes_poses.put(timestamp, new XyzAtr(xyzatr[0], xyzatr[1]));
}
public void addScene(String timestamp, double [] xyz, double [] atr, double [] ers_xyz_dt, double [] ers_atr_dt) {
scenes_poses.put(timestamp, new XyzAtr(xyz, atr, ers_xyz_dt, ers_atr_dt));
}
public void addScene(String timestamp, double [][] xyzatr, double [][] ers_xyzatr_dt) {
scenes_poses.put(timestamp, new XyzAtr(xyzatr[0], xyzatr[1], ers_xyzatr_dt[0], ers_xyzatr_dt[1]));
}
//not used
public void addScene(String timestamp, double [] xyz, double [] atr, double [] ers_xyz_dt, double [] ers_atr_dt, double [] ers_xyz_d2t, double [] ers_atr_d2t) {
scenes_poses.put(timestamp, new XyzAtr(xyz, atr, ers_xyz_dt, ers_atr_dt, ers_xyz_d2t, ers_atr_d2t));
}
public void addScene(String timestamp, double [][] xyzatr, double [][] ers_xyzatr_dt, double [][] ers_xyzatr_d2t) {
scenes_poses.put(timestamp, new XyzAtr(
xyzatr[0], xyzatr[1],
ers_xyzatr_dt[0], ers_xyzatr_dt[1],
ers_xyzatr_d2t[0], ers_xyzatr_d2t[1]));
}
public String getEarliestScene() {
return Collections.min(scenes_poses.keySet());
......@@ -419,7 +448,10 @@ public class ErsCorrection extends GeometryCorrection {
public double[][] getSceneXYZATR(String timestamp) {
XyzAtr scene = scenes_poses.get(timestamp);
if (scene == null) return null;
if (scene == null) {
// if timestamp.equals()
return null;
}
return scene.getXYZATR();
}
public double[] getSceneXYZ(String timestamp) {
......@@ -432,6 +464,14 @@ public class ErsCorrection extends GeometryCorrection {
if (scene == null) return null;
return scene.getATR();
}
public double[][] getSceneErsXYZATR_dt(String timestamp) {
XyzAtr scene = scenes_poses.get(timestamp);
if (scene == null) return null;
return scene.getErsXYZATR_dt();
}
public double[] getSceneErsXYZ_dt(String timestamp) {
XyzAtr scene = scenes_poses.get(timestamp);
if (scene == null) return null;
......
......@@ -763,7 +763,7 @@ public class IntersceneLma {
final double [] full_vector = getFullVector(vector);
final ErsCorrection ers_ref = reference_QuadClt.getErsCorrection();
final ErsCorrection ers_scene = scene_QuadClt.getErsCorrection();
final double [] scene_xyz = new double[3];;
final double [] scene_xyz = new double[3];
final double [] scene_atr = new double[3];
final double [] reference_xyz = new double[3]; // will stay 0
final double [] reference_atr = new double[3]; // will stay 0
......@@ -786,6 +786,10 @@ public class IntersceneLma {
scene_atr[i] = full_vector[ErsCorrection.DP_DSAZ + i];
scene_xyz[i] = full_vector[ErsCorrection.DP_DSX + i];
}
if (Double.isNaN(scene_xyz[0])) {
System.out.println("getFxDerivs(): scene_xyz[0]=NaN");
System.out.println();
}
ers_scene.setupERS();
ers_ref.setupERS();
final Matrix [] reference_matrices_inverse = ErsCorrection.getInterRotDeriveMatrices(
......
......@@ -52,6 +52,7 @@ public class IntersceneMatchParameters {
ims_mount_atr[1] * Math.PI/180,
ims_mount_atr[2] * Math.PI/180};
}
public boolean center_reference = false;
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
......@@ -161,7 +162,8 @@ public class IntersceneMatchParameters {
//------------
// Sky detection/filtering
public boolean sky_recalc = false; // force blue sky recalculation even if it exists
public boolean sky_extract = true; // do not try to extract blue sky
public boolean sky_recalc = false; // force blue sky recalculation even if it exists
public double sky_highest_min = -50; // lowest absolute value should not be higher (requires photometric)
public double cold_frac = 0.005; // this and lower will scale fom by cold_scale
public double hot_frac = 0.9; // this and above will scale fom by 1.0
......@@ -444,6 +446,8 @@ public class IntersceneMatchParameters {
gd.addTab ("Scene Series", "Processing series of scenes and multi-series sets");
gd.addMessage ("Build series options");
gd.addCheckbox ("Use center scene as a reference", this.center_reference,
"True for mapping with post-processing. If false, use the last scene as a reference (driving).");
gd.addCheckbox ("Force reference scene DSI calculation", this.force_ref_dsi,
"Calculate reference scene DSI even if the file exists.");
gd.addCheckbox ("Force egomotion calculation", this.force_orientations,
......@@ -657,6 +661,8 @@ public class IntersceneMatchParameters {
gd.addTab("Sky","Featureless sky areas detection and filtering (LWIR only)");
gd.addMessage ("Temperature-related filtering (requires photometric calibration)");
gd.addCheckbox ("Try blue sky calculation/use", this.sky_extract,
"Disable if no sky will appear in the image (such as for down-pointed camera).");
gd.addCheckbox ("Force blue sky recalculation", this.sky_recalc,
"Recalculate blue sky even if it already exists.");
gd.addNumericField("High limit of the scene coldest tile", this.sky_highest_min, 5,7,"",
......@@ -1108,6 +1114,7 @@ public class IntersceneMatchParameters {
this.ims_mount_xyz = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 3);
this.sfm_use = gd.getNextBoolean();
this.sfm_min_base = gd.getNextNumber();
this.center_reference = gd.getNextBoolean();
this.force_ref_dsi = gd.getNextBoolean();
this.force_orientations = gd.getNextBoolean();
this.run_ly = gd.getNextBoolean();
......@@ -1203,6 +1210,7 @@ public class IntersceneMatchParameters {
this.strong_strength = gd.getNextNumber();
this.weak_strength = gd.getNextNumber();
this.sky_extract = gd.getNextBoolean();
this.sky_recalc = gd.getNextBoolean();
this.sky_highest_min = gd.getNextNumber();
this.cold_frac = gd.getNextNumber();
......@@ -1461,6 +1469,7 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"ims_mount_xyz", IntersceneMatchParameters.doublesToString(this.ims_mount_xyz));
properties.setProperty(prefix+"sfm_use", this.sfm_use + ""); // boolean
properties.setProperty(prefix+"sfm_min_base", this.sfm_min_base+""); // double
properties.setProperty(prefix+"center_reference", this.center_reference + ""); // boolean
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
......@@ -1563,6 +1572,7 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"strong_strength", this.strong_strength+""); // double
properties.setProperty(prefix+"weak_strength", this.weak_strength+""); // double
properties.setProperty(prefix+"sky_extract", this.sky_extract+""); // boolean
properties.setProperty(prefix+"sky_recalc", this.sky_recalc+""); // boolean
properties.setProperty(prefix+"sky_highest_min", this.sky_highest_min+""); // double
properties.setProperty(prefix+"cold_frac", this.cold_frac+""); // double
......@@ -1774,6 +1784,7 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"ims_mount_xyz")!=null) this.ims_mount_xyz= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"ims_mount_xyz"),3);
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+"center_reference")!=null) this.center_reference=Boolean.parseBoolean(properties.getProperty(prefix+"center_reference"));
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"));
......@@ -1881,6 +1892,7 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"strong_strength")!=null) this.strong_strength=Double.parseDouble(properties.getProperty(prefix+"strong_strength"));
if (properties.getProperty(prefix+"weak_strength")!=null) this.weak_strength=Double.parseDouble(properties.getProperty(prefix+"weak_strength"));
if (properties.getProperty(prefix+"sky_extract")!=null) this.sky_extract=Boolean.parseBoolean(properties.getProperty(prefix+"sky_extract"));
if (properties.getProperty(prefix+"sky_recalc")!=null) this.sky_recalc=Boolean.parseBoolean(properties.getProperty(prefix+"sky_recalc"));
if (properties.getProperty(prefix+"sky_highest_min")!=null) this.sky_highest_min=Double.parseDouble(properties.getProperty(prefix+"sky_highest_min"));
if (properties.getProperty(prefix+"cold_frac")!=null) this.cold_frac=Double.parseDouble(properties.getProperty(prefix+"cold_frac"));
......@@ -2114,6 +2126,7 @@ public class IntersceneMatchParameters {
imp.ims_mount_xyz = this.ims_mount_xyz.clone();
imp.sfm_use = this.sfm_use;
imp.sfm_min_base = this.sfm_min_base;
imp.center_reference = this.center_reference;
imp.force_ref_dsi = this.force_ref_dsi;
imp.force_orientations = this.force_orientations;
imp.run_ly = this.run_ly;
......@@ -2212,6 +2225,7 @@ public class IntersceneMatchParameters {
imp.strong_strength = this.strong_strength;
imp.weak_strength = this.weak_strength;
imp.sky_extract = this.sky_extract;
imp.sky_recalc = this.sky_recalc;
imp.sky_highest_min = this.sky_highest_min;
imp.cold_frac = this.cold_frac;
......
......@@ -2447,6 +2447,7 @@ public class TexturedModel {
final QuadCLT parameter_scene, // to use for rendering parameters in multi-series sequences
// if null - use reference scene
QuadCLT [] scenes,
final int ref_index,
double [][] combo_dsn_final, // null OK, will read file
final boolean updateStatus,
final int debugLevel)
......@@ -2512,7 +2513,7 @@ public class TexturedModel {
final boolean tex_um_fixed = clt_parameters.tex_um_fixed; // imp.mono_fixed; // true; // normalize to fixed range when converting to 8 bits
final double tex_um_range = clt_parameters.tex_um_range; // imp.mono_range; // 500.0; // monochrome full-scale range (+/- half)
final int ref_index = scenes.length - 1;
// final int ref_index = scenes.length - 1;
final QuadCLT ref_scene = scenes[ref_index];
final TileProcessor tp = ref_scene.getTileProcessor();
......
......@@ -144,6 +144,10 @@ public class XyzAtr {
atr[2] = d[2];
}
public double [][] getErsXYZATR_dt() {
return new double [][] {ers_xyz_dt, ers_atr_dt};
}
public double [] getErsXYZ_dt() {
return ers_xyz_dt;
}
......
......@@ -340,6 +340,13 @@ public class LwirWorld {
quadCLTs[ref_index].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
quadCLTs[ref_index].preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
clt_parameters,
// adding these parameters for more flexibility in accuracy/speed
clt_parameters.gr_max_clust_radius, //int gr_max_clust_radius,
clt_parameters.disp_scan_start, // double disp_scan_start,
clt_parameters.disp_scan_step, // double disp_scan_step,
clt_parameters.disp_scan_count, // double disp_scan_count,
false, // boolean no_bg_generate,
false, // boolean no_lma,
debayerParameters,
colorProcParameters,
rgbParameters,
......
package com.elphel.imagej.tileprocessor.sfm;
class SfmCorr{
double sfm_gain;
double [] corr_ind = null; // {disparity, strength}
double sfm_gain = 0;
double [] corr_ind = null; // {disparity, strength}
double [] corr_neib = null; // {disparity, strength}
}
......@@ -643,7 +643,7 @@ public class StructureFromMotion {
tilesY,
true,
"sfm_corr-"+scene_pairs[num_pairs-1][1].getImageName()+"-"+
scene_pairs[0][0].getImageName()+"-"+num_pairs,
scene_pairs[0][0].getImageName()+"-"+num_pairs+"-"+String.format("%02d", ntry),
dbg_titles);
}
......@@ -862,6 +862,9 @@ public class StructureFromMotion {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < accum_PD.length; nTile = ai.getAndIncrement()) {
// if (nTile==4600) {
// System.out.println("getSfmCorr(): nTile="+nTile);
// }
if ((disp_corr[0][nTile] != null) || (use_neibs && (disp_corr[1][nTile] != null) )) {
sfmCorr[nTile] = new SfmCorr();
double [] sxy = dpXYddisp_avg[nTile];
......@@ -1007,19 +1010,47 @@ public class StructureFromMotion {
debugLevel); // int debug_level)
}
}
// remove tiles from both that are null for any
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < ref_pXpYD.length; nTile = ai.getAndIncrement())
if (ref_pXpYD[nTile] != null){
boolean undefined = false;
for (int nscene = 0; nscene < scenes.length; nscene++) {
if (scenes_pXpYD[nscene][nTile] == null) {
undefined=true;
break;
}
}
if (undefined) {
for (int nscene = 0; nscene < scenes.length; nscene++) {
scenes_pXpYD[nscene][nTile] = null;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
tp_tasks_ref = // were used only for the FPN removal
Interscene.setReferenceGPU (
clt_parameters, // CLTParameters clt_parameters,
ref_scene, // QuadCLT ref_scene,
ref_disparity, // double [] ref_disparity, // null or alternative reference disparity
ref_pXpYD, // double [][] ref_pXpYD,
null, // reliable_ref, // final boolean [] selection, // may be null, if not null do not process unselected tiles
margin, // final int margin,
clt_parameters, // CLTParameters clt_parameters,
scenes[0], // ref_scene, // QuadCLT ref_scene,
null, // ref_disparity, // double [] ref_disparity, // null or alternative reference disparity
scenes_pXpYD[0], // ref_pXpYD, // double [][] ref_pXpYD,
null, // reliable_ref, // final boolean [] selection, // may be null, if not null do not process unselected tiles
margin, // final int margin,
// motion blur compensation
mb_tau, // double mb_tau, // 0.008; // time constant, sec
mb_max_gain, // double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
mb_vectors_scenes[0], // mb_vectors_ref, // double [][] mb_vectors, // now [2][ntiles];
debugLevel); // int debugLevel)
mb_tau, // double mb_tau, // 0.008; // time constant, sec
mb_max_gain, // double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
mb_vectors_scenes[0],// mb_vectors_ref, // double [][] mb_vectors, // now [2][ntiles];
debugLevel); // int debugLevel)
// is it needed here?
scenes[0].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
......
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