Commit 1517acca authored by Andrey Filippov's avatar Andrey Filippov

implemented/tested terrain layer in *-INTER-INTRA-LMA.tiff

parent e64fe051
...@@ -76,7 +76,7 @@ import ij.plugin.filter.GaussianBlur; ...@@ -76,7 +76,7 @@ import ij.plugin.filter.GaussianBlur;
public class OpticalFlow { public class OpticalFlow {
public static String [] COMBO_DSN_TITLES = {"disp", "strength","disp_lma","num_valid","change", public static String [] COMBO_DSN_TITLES = {"disp", "strength","disp_lma","num_valid","change",
"disp_bg", "strength_bg","disp_lma_bg","change_bg","disp_fg","disp_bg_all","blue_sky","sfm_gain", "ground"}; "disp_bg", "strength_bg","disp_lma_bg","change_bg","disp_fg","disp_bg_all","blue_sky","sfm_gain", "ground","terrain"};
public static int COMBO_DSN_INDX_DISP = 0; // cumulative disparity (from CM or POLY), FG public static int COMBO_DSN_INDX_DISP = 0; // cumulative disparity (from CM or POLY), FG
public static int COMBO_DSN_INDX_STRENGTH = 1; // strength, FG public static int COMBO_DSN_INDX_STRENGTH = 1; // strength, FG
public static int COMBO_DSN_INDX_LMA = 2; // masked copy from 0 - cumulative disparity public static int COMBO_DSN_INDX_LMA = 2; // masked copy from 0 - cumulative disparity
...@@ -91,6 +91,7 @@ public class OpticalFlow { ...@@ -91,6 +91,7 @@ public class OpticalFlow {
public static int COMBO_DSN_INDX_BLUE_SKY = 11; // Detected featureless infinity (sky) public static int COMBO_DSN_INDX_BLUE_SKY = 11; // Detected featureless infinity (sky)
public static int COMBO_DSN_INDX_SFM_GAIN = 12; // SfM disparity gain pixel/pixel public static int COMBO_DSN_INDX_SFM_GAIN = 12; // SfM disparity gain pixel/pixel
public static int COMBO_DSN_INDX_GROUND = 13; // Smooth ground surface w/o vegetation public static int COMBO_DSN_INDX_GROUND = 13; // Smooth ground surface w/o vegetation
public static int COMBO_DSN_INDX_TERRAIN = 14; // Smooth ground surface w/o vegetation
// move to Interscene class? // move to Interscene class?
// interscene adjustments failure reasons. // interscene adjustments failure reasons.
...@@ -5858,6 +5859,7 @@ public class OpticalFlow { ...@@ -5858,6 +5859,7 @@ public class OpticalFlow {
} }
imp_scenes_pair[nstereo]= renderSceneSequence( imp_scenes_pair[nstereo]= renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.um_mono, // boolean um_mono,
fov_tiles, // Rectangle fov_tiles, fov_tiles, // Rectangle fov_tiles,
mode3d, // int mode3d, mode3d, // int mode3d,
toRGB, // boolean toRGB, toRGB, // boolean toRGB,
...@@ -6285,7 +6287,33 @@ public class OpticalFlow { ...@@ -6285,7 +6287,33 @@ public class OpticalFlow {
System.out.println ("TexturedModel.output3d() -> "+ok_3d+" (terrain only, no vegetation)"); System.out.println ("TexturedModel.output3d() -> "+ok_3d+" (terrain only, no vegetation)");
} }
boolean export_terrain_sequence = true;
if (export_terrain_sequence) {
combo_dsn_final =quadCLTs[ref_index].restoreComboDSI(true);
if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) {
System.out.println ("No terrain data available");
} else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
false, // boolean um_mono,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
1, // int sensor_mask,
scenes_suffix, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
quadCLTs[ref_index].saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain); // imp_scenes); // ImagePlus imp)
}
}
if (export_images) { if (export_images) {
if (combo_dsn_final == null) { if (combo_dsn_final == null) {
...@@ -7320,6 +7348,7 @@ public class OpticalFlow { ...@@ -7320,6 +7348,7 @@ public class OpticalFlow {
public static ImagePlus renderSceneSequence( public static ImagePlus renderSceneSequence(
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean um_mono,
Rectangle fov_tiles, Rectangle fov_tiles,
int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG int mode3d, // for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG
boolean toRGB, boolean toRGB,
...@@ -7333,7 +7362,7 @@ public class OpticalFlow { ...@@ -7333,7 +7362,7 @@ public class OpticalFlow {
int debugLevel) { int debugLevel) {
boolean corr_raw_ers = true; boolean corr_raw_ers = true;
double [] stereo_atr = ZERO3; // maybe later play with rotated camera double [] stereo_atr = ZERO3; // maybe later play with rotated camera
boolean um_mono = clt_parameters.imp.um_mono; // boolean um_mono = clt_parameters.imp.um_mono;
double um_sigma = clt_parameters.imp.um_sigma; double um_sigma = clt_parameters.imp.um_sigma;
double um_weight = clt_parameters.imp.um_weight; double um_weight = clt_parameters.imp.um_weight;
boolean mb_en = clt_parameters.imp.mb_en && (fov_tiles==null) && (mode3d > 0); boolean mb_en = clt_parameters.imp.mb_en && (fov_tiles==null) && (mode3d > 0);
...@@ -7342,7 +7371,7 @@ public class OpticalFlow { ...@@ -7342,7 +7371,7 @@ public class OpticalFlow {
final float fum_weight = (float) um_weight; final float fum_weight = (float) um_weight;
boolean merge_all = clt_parameters.imp.merge_all; boolean merge_all = clt_parameters.imp.merge_all || !um_mono; // no unsharp mask -> terrain->merge_all
if (mode3d < 1) { if (mode3d < 1) {
merge_all = false; merge_all = false;
} }
......
...@@ -1707,6 +1707,26 @@ public class QuadCLTCPU { ...@@ -1707,6 +1707,26 @@ public class QuadCLTCPU {
tilesY); // int height) tilesY); // int height)
} }
public void setTerrain(
CLTParameters clt_parameters,
double [] terrain,
int debugLevel) {
double [][] combo_dsn_final = restoreComboDSI(true); // also sets quadCLTs[ref_index].dsi and blue sky
combo_dsn_final[OpticalFlow.COMBO_DSN_INDX_TERRAIN] = terrain;
String rslt_suffix = "-INTER-INTRA";
rslt_suffix += (clt_parameters.correlate_lma?"-LMA":"-NOLMA");
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
saveDoubleArrayInModelDirectory( // error
rslt_suffix, // String suffix,
OpticalFlow.COMBO_DSN_TITLES, // combo_dsn_titles_full, // null, // String [] labels, // or null
combo_dsn_final, // dbg_data, // double [][] data,
tilesX, // int width,
tilesY); // int height)
}
public double [] getFlatGround( public double [] getFlatGround(
double [] disparity, double [] disparity,
double rmse_above, // from average double rmse_above, // from average
...@@ -2617,12 +2637,14 @@ public class QuadCLTCPU { ...@@ -2617,12 +2637,14 @@ public class QuadCLTCPU {
// System.out.println("dsi== null, use spawnQuadCLT(), restoreFromModel(), ... to set it"); // System.out.println("dsi== null, use spawnQuadCLT(), restoreFromModel(), ... to set it");
return null; return null;
} }
double [][] dls = new double[5][]; // double [][] dls = new double[5][];
double [][] dls = new double[6][];
dls[0] = dsi[isAux()? TwoQuadCLT.DSI_DISPARITY_AUX : TwoQuadCLT.DSI_DISPARITY_MAIN]; dls[0] = dsi[isAux()? TwoQuadCLT.DSI_DISPARITY_AUX : TwoQuadCLT.DSI_DISPARITY_MAIN];
dls[1] = dsi[isAux()? TwoQuadCLT.DSI_DISPARITY_AUX_LMA : TwoQuadCLT.DSI_DISPARITY_MAIN_LMA]; dls[1] = dsi[isAux()? TwoQuadCLT.DSI_DISPARITY_AUX_LMA : TwoQuadCLT.DSI_DISPARITY_MAIN_LMA];
dls[2] = dsi[isAux()? TwoQuadCLT.DSI_STRENGTH_AUX : TwoQuadCLT.DSI_STRENGTH_MAIN]; dls[2] = dsi[isAux()? TwoQuadCLT.DSI_STRENGTH_AUX : TwoQuadCLT.DSI_STRENGTH_MAIN];
dls[3] = dsi[isAux()? TwoQuadCLT.DSI_SFM_GAIN_AUX : TwoQuadCLT.DSI_SFM_GAIN_MAIN]; dls[3] = dsi[isAux()? TwoQuadCLT.DSI_SFM_GAIN_AUX : TwoQuadCLT.DSI_SFM_GAIN_MAIN];
dls[4] = dsi[isAux()? TwoQuadCLT.DSI_GROUND_AUX : TwoQuadCLT.DSI_GROUND_MAIN]; dls[4] = dsi[isAux()? TwoQuadCLT.DSI_GROUND_AUX : TwoQuadCLT.DSI_GROUND_MAIN];
dls[5] = dsi[isAux()? TwoQuadCLT.DSI_TERRAIN_AUX : TwoQuadCLT.DSI_TERRAIN_MAIN];
return dls; return dls;
} }
...@@ -3687,11 +3709,24 @@ public class QuadCLTCPU { ...@@ -3687,11 +3709,24 @@ public class QuadCLTCPU {
this.dsi[is_aux?TwoQuadCLT.DSI_SFM_GAIN_AUX:TwoQuadCLT.DSI_SFM_GAIN_MAIN] = this.dsi[is_aux?TwoQuadCLT.DSI_SFM_GAIN_AUX:TwoQuadCLT.DSI_SFM_GAIN_MAIN] =
combo_dsi[OpticalFlow.COMBO_DSN_INDX_SFM_GAIN]; combo_dsi[OpticalFlow.COMBO_DSN_INDX_SFM_GAIN];
} }
/*
* Was a BUG!
if ((combo_dsi.length > OpticalFlow.COMBO_DSN_INDX_GROUND) && (combo_dsi[OpticalFlow.COMBO_DSN_INDX_GROUND] != null)) { if ((combo_dsi.length > OpticalFlow.COMBO_DSN_INDX_GROUND) && (combo_dsi[OpticalFlow.COMBO_DSN_INDX_GROUND] != null)) {
this.dsi[is_aux?TwoQuadCLT.DSI_SFM_GAIN_AUX:TwoQuadCLT.DSI_SFM_GAIN_MAIN] = this.dsi[is_aux?TwoQuadCLT.DSI_SFM_GAIN_AUX:TwoQuadCLT.DSI_SFM_GAIN_MAIN] =
combo_dsi[OpticalFlow.COMBO_DSN_INDX_GROUND]; combo_dsi[OpticalFlow.COMBO_DSN_INDX_GROUND];
} }
*/
if ((combo_dsi.length > OpticalFlow.COMBO_DSN_INDX_GROUND) && (combo_dsi[OpticalFlow.COMBO_DSN_INDX_GROUND] != null)) {
this.dsi[is_aux?TwoQuadCLT.DSI_GROUND_AUX:TwoQuadCLT.DSI_GROUND_MAIN] =
combo_dsi[OpticalFlow.COMBO_DSN_INDX_GROUND];
}
if ((combo_dsi.length > OpticalFlow.COMBO_DSN_INDX_TERRAIN) && (combo_dsi[OpticalFlow.COMBO_DSN_INDX_TERRAIN] != null)) {
this.dsi[is_aux?TwoQuadCLT.DSI_TERRAIN_AUX:TwoQuadCLT.DSI_TERRAIN_MAIN] =
combo_dsi[OpticalFlow.COMBO_DSN_INDX_TERRAIN];
}
} }
......
...@@ -2928,6 +2928,10 @@ public class TexturedModel { ...@@ -2928,6 +2928,10 @@ public class TexturedModel {
flat_border, // final boolean flat_border, flat_border, // final boolean flat_border,
tilesX, // final int width) ; tilesX, // final int width) ;
terr_mask); // boolean [] dbg_mask); terr_mask); // boolean [] dbg_mask);
scenes[ref_index].setTerrain( // will save terrain as the last slice in INTER-INTRA-LMA
clt_parameters, // CLTParameters clt_parameters,
terrain_disparity, // double [] smooth_ground,
debugLevel); // int debugLevel)
if (save_terrain || show_bs_debug) { if (save_terrain || show_bs_debug) {
String [] dbg_titles = {"FG","BG","FG_LMA", "BG_LMA", "GND", "FLAT", "SINGLE", "TERRAIN", "TERR-MASK", "FS", "BS"}; String [] dbg_titles = {"FG","BG","FG_LMA", "BG_LMA", "GND", "FLAT", "SINGLE", "TERRAIN", "TERR-MASK", "FS", "BS"};
......
...@@ -80,11 +80,14 @@ public class TwoQuadCLT { ...@@ -80,11 +80,14 @@ public class TwoQuadCLT {
public static int DSI_AVGVAL_AUX = 12; public static int DSI_AVGVAL_AUX = 12;
public static int DSI_BLUE_SKY_MAIN = 13; public static int DSI_BLUE_SKY_MAIN = 13;
public static int DSI_BLUE_SKY_AUX = 14; public static int DSI_BLUE_SKY_AUX = 14;
public static int DSI_GROUND_MAIN = 15; // ground surface ignoring vegetation public static int DSI_GROUND_MAIN = 15; // ground surface ignoring vegetation (smooth, has bumps where vegetation is)
public static int DSI_GROUND_AUX = 16; // ground surface ignoring vegetation public static int DSI_GROUND_AUX = 16; // ground surface ignoring vegetation
public static int DSI_SFM_GAIN_MAIN = 17; // SfM disparity gain pixel/pixel, RGB public static int DSI_SFM_GAIN_MAIN = 17; // SfM disparity gain pixel/pixel, RGB
public static int DSI_SFM_GAIN_AUX = 18; // SfM disparity gain pixel/pixel, LWIR public static int DSI_SFM_GAIN_AUX = 18; // SfM disparity gain pixel/pixel, LWIR
public static int DSI_LENGTH = DSI_SFM_GAIN_AUX+1; public static int DSI_TERRAIN_MAIN = 19; // terrain with bumps (vegetation) completely cut off, RGB
public static int DSI_TERRAIN_AUX = 20; // terrain with bumps (vegetation) completely cut off, LWIR
/// public static int DSI_LENGTH = DSI_SFM_GAIN_AUX+1;
public static int DSI_LENGTH = DSI_TERRAIN_AUX+1;
public static String DSI_COMBO_SUFFIX = "-DSI_COMBO"; public static String DSI_COMBO_SUFFIX = "-DSI_COMBO";
public static String DSI_MAIN_SUFFIX = "-DSI_MAIN"; public static String DSI_MAIN_SUFFIX = "-DSI_MAIN";
...@@ -108,7 +111,10 @@ public class TwoQuadCLT { ...@@ -108,7 +111,10 @@ public class TwoQuadCLT {
"ground_main", "ground_main",
"ground_aux", "ground_aux",
"sfm_gain_main", "sfm_gain_main",
"sfm_gain_aux"}; "sfm_gain_aux",
"terrain_main",
"terrain_aux"
};
public long startTime; // start of batch processing public long startTime; // start of batch processing
public long startSetTime; // start of set processing public long startSetTime; // start of set processing
......
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