Commit 2d5052a0 authored by Andrey Filippov's avatar Andrey Filippov

Before isolating image dimensions and zoom from map instance

parent af6220a8
......@@ -6182,7 +6182,8 @@ public class OpticalFlow {
}
}
double terr_rthrsh_abv = clt_parameters.imp.terr_rthrsh_abv;
if (export_CT) {
double [][][] ct_scans = new double [(int) Math.ceil((ct_max-ct_min)/ct_step) + 1][][];
boolean ok_ct = TexturedModel.output3d( // quadCLTs have same image name, and everything else
......@@ -6199,6 +6200,7 @@ public class OpticalFlow {
ct_step, // final double ct_step,
ct_expand, // final int ct_expand,
false, // final boolean terrain_mode,
terr_rthrsh_abv, // final double terrain_threshold, // in disparity so may depend on average, sfm, etc.
null, // final double [][] hdr_render_size, // { hdr_whs[3],hdr_x0y0[2]}; save/use rendering parameters
false, // final boolean hdr_render_slave,// use rendering parameters (to match other mode)
updateStatus, // final boolean updateStatus,
......@@ -6233,7 +6235,7 @@ public class OpticalFlow {
}
}
// debugging 3D model
// 3D model
int [] whs = new int[3];
double [] x0y0 = new double[2];
double [][] hdr_render_size = new double[2][];
......@@ -6252,6 +6254,7 @@ public class OpticalFlow {
0, // final double ct_step,
0, // final int ct_expand,
false, // final boolean terrain_mode,
terr_rthrsh_abv, // final double terrain_threshold, // in disparity so may depend on average, sfm, etc.
hdr_render_size, // final double [][] hdr_render_size, // { hdr_whs[3],hdr_x0y0[2]}; save/use rendering parameters
false, // final boolean hdr_render_slave,// use rendering parameters (to match other mode)
updateStatus, // final boolean updateStatus,
......@@ -6273,7 +6276,8 @@ public class OpticalFlow {
0, // final double ct_min,
0, // final double ct_step,
0, // final int ct_expand,
true, // final boolean terrain_mode,
true, // final boolean terrain_mode,
terr_rthrsh_abv, // final double terrain_threshold, // in disparity so may depend on average, sfm, etc.
hdr_render_size, // final double [][] hdr_render_size, // { hdr_whs[3],hdr_x0y0[2]}; save/use rendering parameters
hdr_render_slave, // final boolean hdr_render_slave,// use rendering parameters (to match other mode)
updateStatus, // final boolean updateStatus,
......
......@@ -1714,6 +1714,7 @@ public class QuadCLTCPU {
int num_refine,
double frac_above,
double frac_below,
double [] plane, // null or double [3] - will return {tiltX,tiltY,average}
String debug_title) {
final double [] plane_disparity = new double [disparity.length];
final int num_bins = 1024;
......@@ -1757,6 +1758,11 @@ public class QuadCLTCPU {
tilesX, // final int width,
center_xy); // final double [] xy0)
}
if (plane != null) {
plane[0] = plane_tiles[0];
plane[1] = plane_tiles[1];
plane[2] = plane_tiles[2];
}
for (int nTile = 0; nTile < disparity.length; nTile++) {
int tileX = nTile % tilesX;
......
......@@ -2436,7 +2436,9 @@ public class TexturedModel {
final double [] flat,
final double threshold_above,
final int expand,
final int width){
final boolean flat_border,
final int width,
boolean [] dbg_mask){
final int height = disparity.length/width;
double [] terrain_disparity = disparity.clone();
boolean [] above_terrain = new boolean [disparity.length];
......@@ -2451,11 +2453,32 @@ public class TexturedModel {
for (int i = 0; i <above_terrain.length; i++) if (above_terrain[i]){
terrain_disparity[i] = Double.NaN;
}
}
if (flat_border) {
for (int h = 0; h < height; h+=height-1) {
for (int w = 0; w < width; w++) {
int indx = h*width+w;
if (Double.isNaN(terrain_disparity[indx])) {
terrain_disparity[indx] = flat[indx];
}
}
}
for (int w = 0; w < width; w+= width-1) {
for (int h = 0; h < height; h++) {
int indx = h*width+w;
if (Double.isNaN(terrain_disparity[indx])) {
terrain_disparity[indx] = flat[indx];
}
}
}
}
OrthoMap.fillNaNs(
terrain_disparity, // double [] data,
tn, // TileNeibs tn,
3); // int min_neibs)
if (dbg_mask != null) {
System.arraycopy(above_terrain, 0, dbg_mask, 0, dbg_mask.length);
}
return terrain_disparity;
}
......@@ -2569,6 +2592,7 @@ public class TexturedModel {
final double ct_step,
final int ct_expand_in,
final boolean terrain_mode,
final double terr_rthrsh_abv, // relative to average disparity so may depend sfm, etc.
final double [][] hdr_render_size, // { hdr_whs[3],hdr_x0y0[2]}; save/use rendering parameters
final boolean hdr_render_slave,// use rendering parameters (to match other mode)
final boolean updateStatus,
......@@ -2662,6 +2686,17 @@ public class TexturedModel {
final double gsmth_str_bump = clt_parameters.gsmth_str_bump ; // 0.5; // enable bumps above level stronger than this
final double gsmth_str_dip = clt_parameters.gsmth_str_dip ; // 0.55; // enable dips below level stronger than this
final double rmse_above = clt_parameters.imp.terr_rmse_above; //1.0; // from average
final double rmse_below = clt_parameters.imp.terr_rmse_below; //1.0; // from average, // positive value
final int num_refine = clt_parameters.imp.terr_num_refine; //5;
final double frac_above = clt_parameters.imp.terr_frac_above; //0.4;
final double frac_below = clt_parameters.imp.terr_frac_below; // 0.3;
final boolean flat_border = clt_parameters.imp.terr_flat_brd; // when filling NaN, replace NaN border tiles with flat ground
final int expand_above = clt_parameters.imp.terr_expand; // 4; // 2;
final boolean save_terrain = clt_parameters.imp.terr_save & terrain_mode; // save debug data in model directory
// final int ref_index = scenes.length - 1;
final QuadCLT ref_scene = scenes[ref_index];
final TileProcessor tp = ref_scene.getTileProcessor();
......@@ -2832,15 +2867,9 @@ public class TexturedModel {
}
}
double [] smooth_ground = null;
double rmse_above = 1.0; // from average
double rmse_below = 1.0; // from average, // positive value
int num_refine = 5;
double frac_above = 0.4;
double frac_below = 0.3;
double [] flat_ground = null;
final double threshold_above = 0.05;
final int expand_above = 4; // 2;
// final double threshold_above = 0.03;
if (gsmth_enable && (!has_sfm || gsmth_sfm_gnd)) {
smooth_ground = scenes[ref_index].getSmoothGround(
......@@ -2848,6 +2877,7 @@ public class TexturedModel {
has_sfm, // boolean sfm_mode,
debugLevel);
String title_flat = (show_bs_debug)? (ref_scene.getImageName()+"-dbg_flat"):null ;
double [] plane = new double[3];
flat_ground = scenes[ref_index].getFlatGround(
smooth_ground, // double [] disparity,
rmse_above, //double rmse_above, // from average
......@@ -2855,8 +2885,9 @@ public class TexturedModel {
num_refine, // int num_refine,
frac_above, // double frac_above,
frac_below, // double frac_below,
plane, // double [] plane, // null or double [3] - will return {tiltX,tiltY,average}
title_flat); // String debug_title)
double threshold_above = plane[2] * terr_rthrsh_abv;
if (smooth_ground != null) {
if (has_sfm && gsmth_sfm_deviate) {
mixed_flat = true;
......@@ -2888,26 +2919,45 @@ public class TexturedModel {
for (int i = 0; i < single_disparity.length; i++) if (ss_fg_bg_common[1][i] > ss_fg_bg_common[0][i]) {
single_disparity[i] = ds_fg_bg_common[1][i];
}
boolean [] terr_mask = (save_terrain || show_bs_debug) ? (new boolean [ single_disparity.length]):null;
double [] terrain_disparity = getTerrainDisparity(
single_disparity, // final double [] disparity, // maybe already filtered from smooth (combined, allow strong deviations)
flat_ground, // final double [] flat,
threshold_above, // final double threshold_above,
expand_above, // final int expand,
tilesX); // final int width) ;
flat_ground, // final double [] flat,
threshold_above, // final double threshold_above,
expand_above, // final int expand,
flat_border, // final boolean flat_border,
tilesX, // final int width) ;
terr_mask); // boolean [] dbg_mask);
if (show_bs_debug) {
String [] dbg_titles = {"FG","BG","FG_LMA", "BG_LMA", "GND", "FLAT", "SINGLE", "TERRAIN", "FS", "BS"};
if (save_terrain || show_bs_debug) {
String [] dbg_titles = {"FG","BG","FG_LMA", "BG_LMA", "GND", "FLAT", "SINGLE", "TERRAIN", "TERR-MASK", "FS", "BS"};
double [] terr_dbg = new double [terr_mask.length];
for (int i = 0; i < terr_dbg.length; i++) {
terr_dbg[i] = terr_mask[i]? 10: Double.NaN;
}
double [][] dbg_img = {
ds_fg_bg_common[0], ds_fg_bg_common[1], dls_fg[1], dls_bg[1],
smooth_ground, flat_ground, single_disparity, terrain_disparity,
smooth_ground, flat_ground, single_disparity, terrain_disparity,terr_dbg,
ss_fg_bg_common[0], ss_fg_bg_common[1]}; // here BG==FG
String dbg_suffix = String.format("-fg-bg-disparity_strength-LMA-GND-FLAT_th%.4f",threshold_above);
if (show_bs_debug) {
ShowDoubleFloatArrays.showArrays(
dbg_img,
tilesX,
dbg_img[0].length/tilesX,
true,
ref_scene.getImageName()+"-fg-bg-disparity_strength-LMA-GND-FLAT",
ref_scene.getImageName()+dbg_suffix,
dbg_titles);
}
if (save_terrain) {
scenes[ref_index].saveDoubleArrayInModelDirectory(
dbg_suffix, // String suffix,
dbg_titles, // String [] labels, // or null
dbg_img, // double [][] data,
tilesX, // int width, // int tilesX,
tilesY); // int height, // int tilesY,
}
}
scenes[ref_index].setSmoothGround( // was in the end
clt_parameters, // CLTParameters clt_parameters,
......
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