Commit b36a0561 authored by Andrey Filippov's avatar Andrey Filippov

Cleaning up, debugging blue sky

parent 02a4440e
......@@ -385,6 +385,7 @@ public class CLTParameters {
public double photo_offs = 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
public boolean photo_debug = false;// Generate images and text
public boolean photo_each_debug = false;// Debug after Blue Sky
public double tex_disp_adiffo = 0.10; // 0.35; // 0.3; disparity absolute tolerance to connect in ortho directions
public double tex_disp_rdiffo = 0.08; // 0.12; // 0.1; disparity relative tolerance to connect in ortho directions
......@@ -448,6 +449,8 @@ public class CLTParameters {
public double maxZ = 20000; // maximal distance to far object
public boolean limitZ = true; // limit Z, if false - remove triangle
public double infinityDistance = 10000; // Distance to generate backdrop (0 - use regular backdrop)
public double min_from_inf = 500; // farthest non-infinity closer than infinity
public int min_bgnd_tiles = 10; // Minimal number of background tiles to generate background
public boolean gltf_emissive = false; // true; // Use emissive textures
......@@ -1487,6 +1490,7 @@ public class CLTParameters {
properties.setProperty(prefix+"photo_offs_set", this.photo_offs_set+""); // int
properties.setProperty(prefix+"photo_offs", this.photo_offs+""); // double
properties.setProperty(prefix+"photo_debug", this.photo_debug+""); // boolean
properties.setProperty(prefix+"photo_each_debug", this.photo_each_debug+""); // boolean
properties.setProperty(prefix+"tex_disp_adiffo", this.tex_disp_adiffo+""); // double
properties.setProperty(prefix+"tex_disp_rdiffo", this.tex_disp_rdiffo+""); // double
......@@ -1551,6 +1555,7 @@ public class CLTParameters {
properties.setProperty(prefix+"limitZ", this.limitZ+"");
properties.setProperty(prefix+"infinityDistance", this.infinityDistance +"");
properties.setProperty(prefix+"min_from_inf", this.min_from_inf +"");
properties.setProperty(prefix+"min_bgnd_tiles", this.min_bgnd_tiles+"");
properties.setProperty(prefix+"gltf_emissive", this.gltf_emissive+"");
......@@ -2467,6 +2472,7 @@ public class CLTParameters {
if (properties.getProperty(prefix+"photo_offs_set")!=null) this.photo_offs_set=Integer.parseInt(properties.getProperty(prefix+"photo_offs_set"));
if (properties.getProperty(prefix+"photo_offs")!=null) this.photo_offs=Double.parseDouble(properties.getProperty(prefix+"photo_offs"));
if (properties.getProperty(prefix+"photo_debug")!=null) this.photo_debug=Boolean.parseBoolean(properties.getProperty(prefix+"photo_debug"));
if (properties.getProperty(prefix+"photo_each_debug")!=null) this.photo_each_debug=Boolean.parseBoolean(properties.getProperty(prefix+"photo_each_debug"));
if (properties.getProperty(prefix+"tex_disp_adiffo")!=null) this.tex_disp_adiffo=Double.parseDouble(properties.getProperty(prefix+"tex_disp_adiffo"));
if (properties.getProperty(prefix+"tex_disp_rdiffo")!=null) this.tex_disp_rdiffo=Double.parseDouble(properties.getProperty(prefix+"tex_disp_rdiffo"));
......@@ -2530,6 +2536,7 @@ public class CLTParameters {
if (properties.getProperty(prefix+"limitZ")!=null) this.limitZ=Boolean.parseBoolean(properties.getProperty(prefix+"limitZ"));
if (properties.getProperty(prefix+"infinityDistance")!=null) this.infinityDistance=Double.parseDouble(properties.getProperty(prefix+"infinityDistance"));
if (properties.getProperty(prefix+"min_from_inf")!=null) this.min_from_inf=Double.parseDouble(properties.getProperty(prefix+"min_from_inf"));
if (properties.getProperty(prefix+"min_bgnd_tiles")!=null) this.min_bgnd_tiles=Integer.parseInt(properties.getProperty(prefix+"min_bgnd_tiles"));
if (properties.getProperty(prefix+"gltf_emissive")!=null) this.gltf_emissive=Boolean.parseBoolean(properties.getProperty(prefix+"gltf_emissive"));
......@@ -3600,7 +3607,9 @@ public class CLTParameters {
"Target weighted (by scales) average offset.");
gd.addCheckbox ("Debug photometric calibration", this.photo_debug,
"Generate debug images an text output.");
gd.addCheckbox ("Debug photometric calibration 'each'", this.photo_each_debug,
"Generate debug images after Blue Sky.");
//
gd.addTab ("3D", "3D reconstruction");
gd.addMessage ("Meshes clustering for texture generation");
gd.addNumericField("Ortho tolerance absolute", this.tex_disp_adiffo, 5,7,"pix",
......@@ -3726,6 +3735,8 @@ public class CLTParameters {
gd.addNumericField("Distance to a backdrop", this.infinityDistance,8,8,"m",
"Distance to generate backdrop (0 - use regular backdrop).");
gd.addNumericField("Minimal distance from backdrop", this.min_from_inf,8,8,"m",
"Minimal distance of the fartest object from backdrop to be resolved.");
gd.addNumericField("Minimal background tiles", this.min_bgnd_tiles, 0,4,"",
"Minimal number of background tiles to generate background.");
......@@ -4827,6 +4838,7 @@ public class CLTParameters {
this.photo_offs_set = (int) gd.getNextNumber();
this.photo_offs = gd.getNextNumber();
this.photo_debug = gd.getNextBoolean();
this.photo_each_debug = gd.getNextBoolean();
this.tex_disp_adiffo = gd.getNextNumber();
this.tex_disp_rdiffo = gd.getNextNumber();
......@@ -4891,6 +4903,7 @@ public class CLTParameters {
this.limitZ= gd.getNextBoolean();
this.infinityDistance= gd.getNextNumber();
this.min_from_inf= gd.getNextNumber();
this.min_bgnd_tiles= (int) gd.getNextNumber();
this.gltf_emissive= gd.getNextBoolean();
......
......@@ -572,6 +572,10 @@ public class TexturedModel {
final int tilesX,
int debugLevel_in)
{
if ((debugLevel_in > -2) && is_sky_cluster) {
System.out.println("buildTileCluster(): processing sky clusterm cluster_list.size()="+cluster_list.size());
}
final int dbg_tile = -2410; // 858; // -3868; // 28+48*80;
// final int num_layers = disparity_layers.length;
final int tiles = source_disparity.length;
......@@ -1417,6 +1421,9 @@ public class TexturedModel {
}
// next_seed_tile_layer is now {tile, layer}
final boolean is_sky_cluster = (next_seed_tile_layer[1] == blue_sky_layer) && blue_sky[next_seed_tile_layer[0]];
if ((debugLevel > -2) && is_sky_cluster) {
System.out.println("clusterizeFgBg(): processing sky clusterm cluster_list.size()="+cluster_list.size());
}
double [] cluster_initial_disparity = buildInitialCluster(
disparity_layers, // final double [][] disparity_layers, // should not have same tile disparity on multiple layers
seams_layers, // final int [][] seams_layers,
......@@ -1655,7 +1662,7 @@ public class TexturedModel {
final boolean showTri = !batch_mode && (debugLevel > -1) && (clt_parameters.show_triangles);
final boolean disp_hires_tri = !batch_mode && clt_parameters.tex_disp_hires_tri;
final int dbg_scale_mesh = clt_parameters.tex_dbg_scale_mesh; // 4; // <=0 - do not show
/// final double min_non_inf = 0.01; // relative to infinity disparity
final int sky_layer = 0; // source disparity layer that contains "blue sky"
......@@ -1668,6 +1675,7 @@ public class TexturedModel {
return false; // not used in lwir
}
double infinity_disparity = ref_scene.getGeometryCorrection().getDisparityFromZ(clt_parameters.infinityDistance);
double min_obj_disparity = ref_scene.getGeometryCorrection().getDisparityFromZ(clt_parameters.infinityDistance-clt_parameters.min_from_inf);
X3dOutput x3dOutput = null;
WavefrontExport wfOutput = null;
ArrayList<TriMesh> tri_meshes = null;
......@@ -1683,17 +1691,17 @@ public class TexturedModel {
System.out.println("As there was a problem with (wrong?) blue sky setting strength to 0.0001");
combo_dsn_final = null;
}
if (combo_dsn_final == null) {
combo_dsn_final =scenes[ref_index].readDoubleArrayFromModelDirectory(
"-INTER-INTRA-LMA", // String suffix,
0, // int num_slices, // (0 - all)
null); // int [] wh);
if (combo_dsn_final == null) { // does not set scene.dsi from file !!!
combo_dsn_final =scenes[ref_index].restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky
}
boolean [] sky_tiles = new boolean[combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_BLUE_SKY].length];
boolean [] sky_invert = new boolean[combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_BLUE_SKY].length];
int num_sky_tiles = 0;
for (int i = 0; i < sky_tiles.length; i++) {
sky_tiles[i] = combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_BLUE_SKY][i] > 0.0;
sky_invert[i] = !sky_tiles[i]; // not used
num_sky_tiles += sky_tiles[i]? 1: 0;
}
if (debugLevel > -2) {
System.out.println("output3d(): num_sky_tiles="+num_sky_tiles);
}
// re-load , should create quadCLTs[ref_index].dsi
double [][] dls_fg = {
......@@ -1703,18 +1711,19 @@ public class TexturedModel {
};
// currently conditionInitialDS() zeroes disparity for blue_sky. TODO: allow some FG over blue_sky?
// gets Blue Sky from scene.dsi , not from the file!
double [][] ds_fg = OpticalFlow.conditionInitialDS(
true, // boolean use_conf, // use configuration parameters, false - use following
true, // boolean use_conf, // use configuration parameters, false - use following
clt_parameters, // CLTParameters clt_parameters,
dls_fg, // double [][] dls
scenes[ref_index], // QuadCLT scene,
dls_fg, // double [][] dls
scenes[ref_index], // QuadCLT scene,
debugLevel); // int debug_level)
double [][] dls_bg = {
combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_DISP_BG].clone(),
combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_LMA_BG].clone(),
combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_STRENGTH_BG].clone()
};
for (int i = 0; i < sky_tiles.length; i++) if (Double.isNaN(dls_bg[0][i])){
for (int i = 0; i < dls_bg[0].length; i++) if (Double.isNaN(dls_bg[0][i])){
dls_bg[0][i] = dls_fg[0][i];
dls_bg[1][i] = dls_fg[1][i];
dls_bg[2][i] = dls_fg[2][i];
......@@ -1726,11 +1735,37 @@ public class TexturedModel {
scenes[ref_index], // QuadCLT scene,
debugLevel); // int debug_level)
double[][] ds_fg_bg = {ds_fg[0], ds_bg[0].clone()};
for (int i = 0; i < sky_tiles.length; i++) {
for (int i = 0; i < dls_bg[0].length; i++) {
if (Math.abs(ds_fg_bg[1][i]-ds_fg_bg[0][i]) < tex_fg_bg) {
ds_fg_bg[1][i] = Double.NaN;
}
}
if (debugLevel > -2) {
System.out.println("Limiting non-infinity objects' disparity to "+min_obj_disparity+
", infinity_disparity = "+infinity_disparity);
}
for (int nl = 0; nl < ds_fg_bg.length; nl++) {
for (int i = 0; i < dls_bg[nl].length; i++) {
if ((nl != sky_layer) || !sky_tiles[i]) {
if (ds_fg_bg[nl][i] < min_obj_disparity) {
ds_fg_bg[nl][i] = min_obj_disparity;
}
}
}
}
if (debugLevel > -2) { // was > 0
String [] dbg_titles = {"FG","BG","BS"};
double [][] dbg_img = {ds_fg_bg[0], ds_fg_bg[1],combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_BLUE_SKY]};
ShowDoubleFloatArrays.showArrays(
dbg_img,
tilesX,
dbg_img[0].length/tilesX,
true,
ref_scene.getImageName()+"-disparity_layers",
dbg_titles);
}
// Create data for consolidated textures (multiple texture segments combined in same "passes"
TileCluster [] tileClusters = clusterizeFgBg( // wrong result type, not decided
tilesX, // final int tilesX,
......@@ -1951,7 +1986,9 @@ public class TexturedModel {
boolean [] scan_selected = tileClusters[nslice].getSubSelected(sub_i); // limited to cluster bounds
int [] scan_border_int = tileClusters[nslice].getSubBorderInt(sub_i); // limited to cluster bounds
int max_border = tileClusters[nslice].getBorderIntMax();
boolean is_sky = tileClusters[nslice].isSky();
double min_disparity = is_sky? infinity_disparity : min_obj_disparity;
// skipping averaging disparity for a whole cluster (needs strength and does not seem to be useful)
try {
if (alpha == null) {
......@@ -2008,7 +2045,7 @@ public class TexturedModel {
((dbg_mesh_imgs != null) ? dbg_mesh_imgs[nslice]:null), // double [] tri_img, //
dbg_scaled_width, // int tri_img_width,
// FIXME: make a separate parameter:
infinity_disparity, // 0.25 * clt_parameters.bgnd_range, // 0.3
infinity_disparity, //min_disparity, // infinity_disparity, // 0.25 * clt_parameters.bgnd_range, // 0.3
clt_parameters.grow_disp_max, // other_range, // 2.0 'other_range - difference from the specified (*_CM)
clt_parameters.maxDispTriangle,
clt_parameters.maxZtoXY, // double maxZtoXY, // 10.0. <=0 - do not use
......@@ -3663,7 +3700,8 @@ public class TexturedModel {
sky_pixels, // final double [] data,
null, // final boolean [] prohibit,
sky_pixels_bounds.width, // int width,
3 * Math.min(sky_pixels_bounds.width,sky_pixels_bounds.height) / 2, // 16, // final int grow,
// 3 * Math.min(sky_pixels_bounds.width,sky_pixels_bounds.height) / 2, // 16, // final int grow,
2 * Math.max(sky_pixels_bounds.width,sky_pixels_bounds.height), // 16, // final int grow,
0.7, // double diagonal_weight, // relative to ortho
100, // int num_passes,
0.01, // final double max_rchange, // = 0.01
......
......@@ -8687,6 +8687,9 @@ ImageDtt.startAndJoin(threads);
Arrays.fill(all_nan, Double.NaN);
return all_nan;
}
if (davg2 == 0) {
davg2 = 1; // for sky with disparity ==0
}
final double fdavg = davg;
final double max_change = Math.abs(davg2 * max_rchange);
......
......@@ -209,10 +209,15 @@ public class LwirWorld {
double cold_scale = clt_parameters.imp.cold_scale;
double sky_seed = clt_parameters.imp.sky_seed;
double lma_seed = clt_parameters.imp.lma_seed;
double seed_temp = clt_parameters.imp.seed_temp;
int sky_shrink = clt_parameters.imp.sky_shrink;
int sky_bottleneck = clt_parameters.imp.sky_bottleneck;
int sky_reexpand_extra = clt_parameters.imp.sky_reexpand_extra;
int seed_rows = clt_parameters.imp.seed_rows;
double max_disparity = clt_parameters.imp.max_disparity;
double max_disparity_strength=clt_parameters.imp.max_disparity_strength;
double sky_lim = clt_parameters.imp.sky_lim;
double lim_temp = clt_parameters.imp.lim_temp;
int sky_expand_extra = clt_parameters.imp.sky_expand_extra;
double min_strength = clt_parameters.imp.min_strength;
int lowest_sky_row = clt_parameters.imp.lowest_sky_row;
......@@ -366,13 +371,19 @@ public class LwirWorld {
System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLTs[ref_index].getPhotometricScene());
quadCLTs[ref_index].setQuadClt(); // just in case ?
}
QuadCLT dbg_scene = clt_parameters.imp.save_debug_images? quadCLTs[ref_index]: null; // use to save debug images if not null
quadCLTs[ref_index].setBlueSky (
max_disparity,
max_disparity_strength,
sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this
lma_seed,
seed_temp, //double seed_temp, // 0.5; // seed colder that this point between min and max temp
sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this
lim_temp, // double lim_temp, // 0.5; // sky colder that this point between min and max temp
sky_shrink, // int sky_shrink, // = 4;
sky_expand_extra, // int sky_expand_extra, // = 100; // 1?
sky_bottleneck, //int sky_bottleneck, //
sky_bottleneck, //int sky_bottleneck, //
sky_reexpand_extra, //int sky_reexpand_extra, // 9; re-expand after bottleneck in addition to how it was shrank
cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence
cold_frac, // = 0.005; // this and lower will scale fom by cold_scale
hot_frac, // = 0.9; // this and above will scale fom by 1.0
......@@ -390,6 +401,7 @@ public class LwirWorld {
dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread,
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread,
dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val,
dbg_scene, // QuadCLT dbg_scene, // use to save debug images if not null
batch_mode? -1: 1); /// debugLevel); // int debugLevel)
if (ran_photo_each) {
double [] blue_sky = quadCLTs[ref_index].getDoubleBlueSky();
......@@ -464,13 +476,19 @@ public class LwirWorld {
if (dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null) {
System.out.println("DSI_MAIN file has old format and does not have spread data, will recalculate.");
} else {
QuadCLT dbg_scene = clt_parameters.imp.save_debug_images? quadCLTs[ref_index]: null; // use to save debug images if not null
quadCLTs[ref_index].setBlueSky (
max_disparity,
max_disparity_strength,
sky_seed, // double sky_seed, // = 7.0; // start with product of strength by diff_second below this
lma_seed, // 2.0; // seed - disparity_lma limit
sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this
seed_temp, //double seed_temp, // 0.5; // seed colder that this point between min and max temp
sky_lim, // double sky_lim, // = 15.0; // then expand to product of strength by diff_second below this
lim_temp, // double lim_temp, // 0.5; // sky colder that this point between min and max temp
sky_shrink, // int sky_shrink, // = 4;
sky_expand_extra, // int sky_expand_extra, // = 100; // 1?
sky_bottleneck, //int sky_bottleneck, //
sky_reexpand_extra, //int sky_reexpand_extra, // 9; re-expand after bottleneck in addition to how it was shrank
cold_scale, // = 0.2; // <=1.0. 1.0 - disables temperature dependence
cold_frac, // = 0.005; // this and lower will scale fom by cold_scale
hot_frac, // = 0.9; // this and above will scale fom by 1.0
......@@ -488,12 +506,12 @@ public class LwirWorld {
dsi[TwoQuadCLT.DSI_SPREAD_AUX], // double [] spread,
dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], //double [] disp_lma,
dsi[TwoQuadCLT.DSI_AVGVAL_AUX],// double [] avg_val,
dbg_scene, // QuadCLT dbg_scene, // use to save debug images if not null
debugLevel); // int debugLevel)
}
}
} // while (blue_sky == null)
/* */
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment