Commit 86106498 authored by Andrey Filippov's avatar Andrey Filippov

Before cleaning up terrain debugging

parent 84bd8cc0
......@@ -340,7 +340,7 @@ public class CLTParameters {
public int lyms_clust_size = 4; // cluster size (same in both directions) for measuring LY data
public double lyms_scene_range = 10.0; // disparity range for non-infinity in the same cluster
public int lyms_min_num_inf = 10; // Minimal number of tiles (in all scenes total) in an infinity cluster
public boolean lyms_show_images = false; // show debug images in LY adjustment mode.
// old fcorr parameters, reuse?
......@@ -1553,6 +1553,9 @@ public class CLTParameters {
properties.setProperty(prefix+"lyms_scene_range", this.lyms_scene_range +"");
properties.setProperty(prefix+"lyms_min_num_inf", this.lyms_min_num_inf +"");
properties.setProperty(prefix+"lyms_show_images", this.lyms_show_images +"");
properties.setProperty(prefix+"corr_magic_scale", this.corr_magic_scale +"");
properties.setProperty(prefix+"corr_select", this.corr_select +"");
......@@ -2608,6 +2611,7 @@ public class CLTParameters {
if (properties.getProperty(prefix+"lyms_clust_size")!=null) this.lyms_clust_size=Integer.parseInt(properties.getProperty(prefix+"lyms_clust_size"));
if (properties.getProperty(prefix+"lyms_scene_range")!=null) this.lyms_scene_range=Double.parseDouble(properties.getProperty(prefix+"lyms_scene_range"));
if (properties.getProperty(prefix+"lyms_min_num_inf")!=null) this.lyms_min_num_inf=Integer.parseInt(properties.getProperty(prefix+"lyms_min_num_inf"));
if (properties.getProperty(prefix+"lyms_show_images")!=null) this.lyms_show_images=Boolean.parseBoolean(properties.getProperty(prefix+"lyms_show_images"));
if (properties.getProperty(prefix+"corr_magic_scale")!=null) this.corr_magic_scale=Double.parseDouble(properties.getProperty(prefix+"corr_magic_scale"));
if (properties.getProperty(prefix+"corr_select")!=null) this.corr_select=Integer.parseInt(properties.getProperty(prefix+"corr_select"));
......@@ -3780,6 +3784,8 @@ public class CLTParameters {
"Disparity range for non-infinity in the same cluster");
gd.addNumericField("Minimal number of infinity tiles", this.lyms_min_num_inf, 0,3,"",
"Minimal number of tiles (in all scenes total) in an infinity cluster");
gd.addCheckbox ("Show LY debug images", this.lyms_show_images,
"Show Lazy Eye debug images.");
gd.addTab ("Initial DSI", "Building initial (single-scene) DSI");
......@@ -5194,6 +5200,7 @@ public class CLTParameters {
this.lyms_clust_size= (int) gd.getNextNumber();
this.lyms_scene_range= gd.getNextNumber();
this.lyms_min_num_inf=(int) gd.getNextNumber();
this.lyms_show_images = gd.getNextBoolean();
this.mismatch_rgb= gd.getNextNumber();
this.mismatch_lwir= gd.getNextNumber();
......
......@@ -23,7 +23,7 @@ import ij.text.TextWindow;
public class GroundPlane {
public static final String GROUND_PLANE_PREFIX = "groundplane";
public double [][] to_ground_xyzatr = null;
public double [] disparity_plane = null;
public double [] disparity_plane = null; // {tiltX, tiltY, offset, fraction_good)
public double frac_good = Double.NaN; // fraction of "ground" tiles used to find local ground plane
public double [] lla = null; // GPS LLA
public double [] quat_enu = null; // IMS orientation quaternion == d2.getQEnu()
......@@ -223,43 +223,12 @@ public class GroundPlane {
final QuadCLT ref_scene,
final double [] gnd_disp, // if not null
final int debugLevel) {
final double gnd_percent_low = 0.01; // discard lowest overliers
final double gnd_percent_high= 0.2; // 0.9; // high ground percentile
final double gnd_max_high_over = 0.1; // 0.5; // pix = make dependent on average disparity?
final int min_good1 = 10; // 50; // minimal good tiles after pass1
final double max_abs_diff = 0.03; // maximal absolute disparity difference from the plane
final double max_rel_diff = 0.03; // 0.1; // maximal relative disparity difference from the plane
final double normal_damping = 0.001; // pull to horizontal if not enough data
final double blur_frac = 0.01; // 0.03
final double weight_frac = 0.3; // multiply weight by w= 1/(1 + (err/k_max_diff)^2)
final int mtile_size = 16;
final double min_ev_rel = 0.3;
final double max_tilt = 0.2;
final double top_percent = 0.5; // remove above 50% center intersection
final int min_macro_tiles = 3;
final boolean [] good_tiles = new boolean[ref_scene.getTilesX()*ref_scene.getTilesY()];
String dbg_title =ref_scene.getImageName()+"-ground tilts";
double [][] to_ground_xyzatr_frac= GroundPlane.getPlaneDualPassMetric( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
double [][] to_ground_xyzatr_frac= getPlaneDualPassMetric( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
clt_parameters, // final CLTParameters clt_parameters,
ref_scene, // final QuadCLT ref_Clt,
gnd_percent_low, // final double gnd_percent_low,
gnd_percent_high, // final double gnd_percent_high,
gnd_max_high_over, // final double gnd_max_high_over,
min_good1, // final int min_good1, // minimal good tiles after pass1
max_abs_diff, // final double max_abs_diff, // maximal absolute disparity difference from the plane
max_rel_diff, // final double max_rel_diff, // maximal relative disparity difference from the plane
blur_frac, // final double blur_frac, // = 0.01; // 0.03
weight_frac, // final double weight_frac, // = 0.3; // multiply weight by w= 1/(1 + (err/k_max_diff)^2)
mtile_size, // final int mtile_size, // = 16;
min_ev_rel, // final double min_ev_rel, // = 0.3;
max_tilt, // final double max_tilt, // = 0.2;
top_percent, // final double top_percent, // = 0.5; // remove above 50% center intersection
min_macro_tiles, // final int min_macro_tiles, // = 3;
normal_damping, // final double normal_damping,
ref_scene.getTilesX(),// final int width,
good_tiles, // final boolean [] good_tiles, // null or boolean[data.length] // should all be false
gnd_disp, // final double [] gnd_disp, // if not null
......@@ -268,24 +237,34 @@ public class GroundPlane {
if (to_ground_xyzatr_frac == null) {
to_ground_xyzatr_frac = new double [][] {new double[3], new double[3], new double[1]};
}
// To get terrain disparity (until rotation is fixed) use "good_tiles" from getPlaneDualPassMetric and re-calculate ground disparity plane
double [][] to_ground_xyzatr = {to_ground_xyzatr_frac[0],to_ground_xyzatr_frac[1]};
double frac_good = to_ground_xyzatr_frac[2][0];
// Until fixed, run independently
double [] disparity_plane = getDisparityPlaneDualPass( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
// Apply good_tiles mask and find disparity plane
double [] disparity_plane = getDisparityPlaneSinglePass( // returns to_ground_xyzatr (rotated around the ground point nadir of the drone)
clt_parameters, // final CLTParameters clt_parameters,
ref_scene, // final QuadCLT ref_Clt,
ref_scene.getTilesX(),// final int width,
good_tiles, // final boolean [] good_tiles, // null or boolean[data.length] // should all be false
dbg_title+"-disp", // final String dbg_title,
debugLevel); // final int debugLevel)
/*
double [] disparity_plane = getDisparityPlaneDualPass( // returns to_ground_xyzatr (rotated around the ground point nadir of the drone)
clt_parameters, // final CLTParameters clt_parameters,
ref_scene, // final QuadCLT ref_Clt,
gnd_percent_low, // final double gnd_percent_low,
gnd_percent_high, // final double gnd_percent_high,
gnd_max_high_over, // final double gnd_max_high_over,
min_good1, // final int min_good1, // minimal good tiles after pass1
max_abs_diff, // final double max_abs_diff, // maximal absolute disparity difference from the plane
max_rel_diff, // final double max_rel_diff, // maximal relative disparity difference from the plane
normal_damping, // final double normal_damping,
ref_scene.getTilesX(),// final int width,
good_tiles, // final boolean [] good_tiles, // null or boolean[data.length] // should all be false
gnd_disp, // final double [] gnd_disp, // if not null
dbg_title+"-disp", // final String dbg_title,
debugLevel); // final int debugLevel)
*/
return new GroundPlane(
to_ground_xyzatr, // double [][] to_ground_xyzatr,
......@@ -298,29 +277,30 @@ public class GroundPlane {
public static double [][] getPlaneDualPassMetric( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
final CLTParameters clt_parameters,
final QuadCLT ref_Clt,
final double gnd_percent_low,
final double gnd_percent_high,
final double gnd_max_high_over,
final int min_good1, // minimal good tiles after pass1
final double max_abs_diff, // maximal absolute disparity difference from the plane
final double max_rel_diff, // maximal relative disparity difference from the plane
final double blur_frac, // = 0.01; // 0.03
final double weight_frac, // = 0.3; // multiply weight by w= 1/(1 + (err/k_max_diff)^2)
final int mtile_size, // = 16;
final double min_ev_rel, // = 0.3;
final double max_tilt, // = 0.2;
final double top_percent, // = 0.5; // remove above 50% center intersection
final int min_macro_tiles, // = 3;
final double normal_damping,
final int width,
final boolean [] good_tiles, // null or boolean[data.length] // should all be false
final double [] gnd_disp, // if not null
final String dbg_title,
final int debugLevel) {
boolean print_histogram = debugLevel > 0;
final double gnd_percent_low = clt_parameters.imp.fgnd_percent_low; // 0.01; // Discard lowest outliers. Percentile to remove lowest elevation outliers during initial terrain filtering
final double gnd_percent_high= clt_parameters.imp.fgnd_percent_high; // 0.2; // Discard highest outliers. Percentile to remove highest elevation outliers during initial terrain filtering.
final double gnd_max_high_over=clt_parameters.imp.fgnd_max_high_over; // 0.1; // Absolute disparity over lowest. Absolute disparity over lowest. Minimal of this value and the one determined by the highest outliers percentile will be applied. // pix = make dependent on average disparity?
// final int min_good1 = clt_parameters.imp.fgnd_min_good1; //10; // Minimal good tiles in stage 1. Minimal number of remaining tiles after the first stage filtering.
final double max_abs_diff = clt_parameters.imp.fgnd_max_abs_diff; // 0.03; // Absolute disparity from plane. Maximal absolute disparity difference from the stage 1 - found plane (stage2 mask).
final double max_rel_diff = clt_parameters.imp.fgnd_max_rel_diff; // 0.03; // Relative disparity from plane. Maximal relative disparity difference from the stage 1 - found plane (stage2 mask).
final double blur_frac = clt_parameters.imp.fgnd_blur_frac; // 0.01; // Elevation histogram relative sigma. Elevation (relative to the plane) histogram LPF sigma as a fraction of the full range minimal of the absolute and relative above.
final double weight_frac = clt_parameters.imp.fgnd_weight_frac; // 0.3; // Scale outliers from plane weights. Relative to full range disparity from plane to reduce weight twice - multiply remaining tiles weights by w= 1/(1 + (diff_from_plane^2/k_max_diff)^2).
final int mtile_size = clt_parameters.imp.fgnd_mtile_size; //16; // Macrotile size (50% overlapping). Size of the 50%-overlapping square macrotiles (in tiles).
final double min_ev_rel = clt_parameters.imp.fgnd_min_ev_rel; // 0.3; // Minimal macrotile eigenvalues product. Square root of the eigenvalues product. Measure of how well is the macrotile local plane is defined. Fully populated macrotile has it 1.0.
final double max_tilt = clt_parameters.imp.fgnd_max_tilt; // 0.2; // Maximal macrotile tilt. Maximal absolute value of the macrotile plane tilt: z to sqrt (x^2+y^2).
final double top_percent = clt_parameters.imp.fgnd_top_percent; // 0.5; // High elevation outliers percentile. Remove macrotiles that have the highest elevations (measured at the full camera FOV center).
final int min_macro_tiles = clt_parameters.imp.fgnd_min_macro_tiles; // 3; // Minimal number of macrotiles for high outliers. Minimal number of remaining macrotiles before removing high outpliers.
final double normal_damping = clt_parameters.imp.fgnd_normal_damping; // 0.001; // Damping parameter for planes. Pull planes to horizontal when there is not enough data for tilts.
// boolean eig_weight = false;
boolean use_lma = true;
int num_bins = 1000;
......@@ -511,6 +491,10 @@ public class GroundPlane {
dbg_title+"-metric", // final String dbg_title,
debugLevel); // final int debugLevel) {
if (to_ground_xyzatr == null) {
return new double [][] {{0,0,0},{0,0,0},{0}};
}
double [][] macroplanes = getMacroPlanes( // no weights
wxyz, // final double [][] wxyz,
mask3, // final boolean [] mask,
......@@ -532,11 +516,26 @@ public class GroundPlane {
mtile_size, // int mtile_size,
debugLevel); // int debugLevel)
// re-run with updated mask
to_ground_xyzatr = getPlane( // from the camera coordinates to in-plane coordinates
wxyz, // final double [][] wxyz,
use_parallel_proj, // final boolean use_parallel_proj, // for parallel xyz is 0, otherwise - point on the ground under the camera
macro_mask, // mask3, // final boolean [] mask,
weights, // final double [] weight,
width, // final int width,
normal_damping, // final double normal_damping,
dbg_title+"-metric", // final String dbg_title,
debugLevel); // final int debugLevel) {
if (to_ground_xyzatr == null) {
return new double [][] {{0,0,0},{0,0,0},{0}};
}
double [][] macroplanes_weights = getMacroPlanes(
wxyz, // final double [][] wxyz,
mask3, // final boolean [] mask,
weights, // final double [] weight,
true, // final boolean eig_weight, // use weights when calculating eiget values (false - only mask)
true, // final boolean eig_weight, // use weights when calculating eigen values (false - only mask)
width, // final int tilesX,
mtile_size, // final int mtile_size,
normal_damping, // final double normal_damping,
......@@ -570,9 +569,6 @@ public class GroundPlane {
*/
if ((dbg_title != null) || (gnd_disp != null)) {
// expand macrotiles results to match tiles
// rotate ref_disparity and show
double [][] pXpYD_ground = OpticalFlow.transformToScenePxPyD(
null, // final Rectangle full_woi_in, // show larger than sensor WOI (or null) IN TILES
......@@ -692,6 +688,11 @@ public class GroundPlane {
}
}
if (good_tiles != null) {
System.arraycopy(macro_mask, 0, good_tiles, 0, macro_mask.length);
}
ErsCorrection.printVectors(virtual_camera_from_camera); // to_ground_xyzatr_centered);
/// ref_Clt.getErsCorrection().printVectors (to_ground_xyzatr_centered[0], to_ground_xyzatr_centered[1]);
ref_Clt.getErsCorrection().printVectors (virtual_camera_from_camera[0], virtual_camera_from_camera[1]);
......@@ -702,7 +703,7 @@ public class GroundPlane {
// return to_ground_xyzatr_centered;
}
public static boolean []getMaskFromMacro(
public static boolean [] getMaskFromMacro(
boolean [] mask_in,
double [][] macroplanes,
double min_ev_rel,
......@@ -712,7 +713,6 @@ public class GroundPlane {
int tilesX,
int mtile_size,
int debugLevel) {
// int min_macro_tiles = 3;
int num_bins = 100;
double max_tilt2 = max_tilt*max_tilt;
boolean [] mask = mask_in.clone();
......@@ -724,10 +724,31 @@ public class GroundPlane {
int num_macro = 0;
double [] macro_weights = new double [macroplanes.length];
double [] macro_offsets = new double [macroplanes.length];
double sw = 0, swtx=0, swty=0;
for (int mtile = 0; mtile < macroplanes.length; mtile++){
keep_macro[mtile] = macroplanes[mtile] != null;
if (keep_macro[mtile]) {
keep_macro[mtile] = (macroplanes[mtile][1]* macroplanes[mtile][1] + macroplanes[mtile][2]* macroplanes[mtile][2]) < max_tilt2;
keep_macro[mtile] = macroplanes[mtile][3] > min_ev_rel;
}
if (keep_macro[mtile]) {
double w = macroplanes[mtile][3];
double tx = macroplanes[mtile][1];
double ty = macroplanes[mtile][2];
sw += w;
swtx += w * tx;
swty += w * ty;
}
}
if (sw == 0) {
return mask; // all false
}
swtx /= sw;
swty /= sw;
for (int mtile = 0; mtile < macroplanes.length; mtile++){
if (keep_macro[mtile]) {
double tx = macroplanes[mtile][1] - swtx; // tilt from original plane
double ty = macroplanes[mtile][2] - swty;
keep_macro[mtile] = (tx*tx + ty*ty) < max_tilt2;
}
if (keep_macro[mtile]) {
double z = macroplanes[mtile][0];
......@@ -774,16 +795,6 @@ public class GroundPlane {
if (min_x < mtile_half) min_x = 0;
if (max_y > (tilesY-mtile_half)) max_y = tilesY;
if (max_x > (tilesX-mtile_half)) max_x = tilesX;
/*
boolean mask_out = macroplanes[mtile] == null;
if (!mask_out) {
mask_out |= macroplanes[mtile][3] < min_ev_rel;
}
if (!mask_out) {
mask_out |= (macroplanes[mtile][1]* macroplanes[mtile][1] + macroplanes[mtile][2]* macroplanes[mtile][2]) > max_tilt2;
}
if (mask_out) {
*/
if (!keep_macro[mtile]) {
for (int tileY = min_y; tileY < max_y; tileY++) {
for (int tileX = min_x; tileX < max_x; tileX++) {
......@@ -799,22 +810,24 @@ public class GroundPlane {
public static double [] getDisparityPlaneDualPass( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
final CLTParameters clt_parameters,
final QuadCLT ref_Clt,
final double gnd_percent_low,
final double gnd_percent_high,
final double gnd_max_high_over,
final int min_good1, // minimal good tiles after pass1
final double max_abs_diff, // maximal absolute disparity difference from the plane
final double max_rel_diff, // maximal relative disparity difference from the plane
final double normal_damping,
final int width,
final boolean [] good_tiles, // null or boolean[data.length] // should all be false
final double [] gnd_disp, // if not null
final String dbg_title,
final int debugLevel) {
boolean print_histogram = debugLevel > 0;
double blur_frac = 0.01; // 0.03
double weight_frac = 0.3; // multiply weight by w= 1/(1 + (err/k_max_diff)^2)
final double gnd_percent_low = clt_parameters.imp.fgnd_percent_low; // 0.01; // Discard lowest outliers. Percentile to remove lowest elevation outliers during initial terrain filtering
final double gnd_percent_high= clt_parameters.imp.fgnd_percent_high; // 0.2; // Discard highest outliers. Percentile to remove highest elevation outliers during initial terrain filtering.
final double gnd_max_high_over=clt_parameters.imp.fgnd_max_high_over; // 0.1; // Absolute disparity over lowest. Absolute disparity over lowest. Minimal of this value and the one determined by the highest outliers percentile will be applied. // pix = make dependent on average disparity?
// final int min_good1 = clt_parameters.imp.fgnd_min_good1; //10; // Minimal good tiles in stage 1. Minimal number of remaining tiles after the first stage filtering.
final double max_abs_diff = clt_parameters.imp.fgnd_max_abs_diff; // 0.03; // Absolute disparity from plane. Maximal absolute disparity difference from the stage 1 - found plane (stage2 mask).
final double max_rel_diff = clt_parameters.imp.fgnd_max_rel_diff; // 0.03; // Relative disparity from plane. Maximal relative disparity difference from the stage 1 - found plane (stage2 mask).
final double normal_damping = clt_parameters.imp.fgnd_normal_damping; // 0.001; // Damping parameter for planes. Pull planes to horizontal when there is not enough data for tilts.
final double blur_frac = clt_parameters.imp.fgnd_blur_frac; // 0.01; // Elevation histogram relative sigma. Elevation (relative to the plane) histogram LPF sigma as a fraction of the full range minimal of the absolute and relative above.
final double weight_frac = clt_parameters.imp.fgnd_weight_frac; // 0.3; // Scale outliers from plane weights. Relative to full range disparity from plane to reduce weight twice - multiply remaining tiles weights by w= 1/(1 + (diff_from_plane^2/k_max_diff)^2).
boolean use_lma = true;
int num_bins = 1000;
......@@ -942,7 +955,6 @@ public class GroundPlane {
double plane = tilts_stage2[0] * dx + tilts_stage2[1] * dy + tilts_stage2[2];
data_tilted[i] = ref_disparity[i] - plane;
}
// int num_bins2 = 100
double [] hist2 = getHistogram1d(
data_tilted, // double [] data, // may have NaNs
ref_strength, // double [] weights,
......@@ -1004,20 +1016,77 @@ public class GroundPlane {
System.out.println("getPlaneDualPass(): tilts_stage3= null");
return null;
}
return new double [] {tilts_stage3[0],tilts_stage3[1], tilts_stage3[2], 1.0*num_good3/ref_disparity.length};
}
/*
double [] disparity_plane = new double[ref_disparity.length];
/**
* After mask is already defined from matric including macrotiles
* @param clt_parameters
* @param ref_Clt
* @param width
* @param good_tiles
* @param dbg_title
* @param debugLevel
* @return
*/
public static double [] getDisparityPlaneSinglePass( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
final CLTParameters clt_parameters,
final QuadCLT ref_Clt,
final int width,
final boolean [] good_tiles, // null or boolean[data.length] // should all be false
final String dbg_title,
final int debugLevel) {
final double normal_damping = clt_parameters.imp.fgnd_normal_damping; // 0.001; // Damping parameter for planes. Pull planes to horizontal when there is not enough data for tilts.
boolean use_lma = true;
String dbg_title1 = (dbg_title != null) ? (dbg_title + "-stage1") : null;
double [][] dls = ref_Clt.getDLS();
if (dls==null) {
return null;
}
double [][] ds = new double [][] {dls[use_lma?1:0].clone(), dls[2]};
final double [] ref_disparity = ds[0];
final double [] ref_strength = ds[1];
final double inf_disp_ref = ref_Clt.getDispInfinityRef();
if (inf_disp_ref != 0) {
if (debugLevel >-3) {
System.out.println("getDisparityPlaneSinglePass(): applying disparity at infinity correctio, subrtacting "+inf_disp_ref);
}
for (int i = 0; i < ref_disparity.length; i++) {
int x = i % width;
int y = i / width;
double dx = x-xy0[0];
double dy = y-xy0[1];
disparity_plane[i] = tilts_stage3[0] * dx + tilts_stage3[1] * dy + tilts_stage3[2];
ref_disparity[i] -= inf_disp_ref;
}
return disparity_plane;
*/
return new double [] {tilts_stage3[0],tilts_stage3[1], tilts_stage3[2], 1.0*num_good3/ref_disparity.length};
}
final int height = ref_disparity.length / width;
final double [] xy0= {width/2, height/2};
int num_good = 0;
for (int i = 0; i < good_tiles.length; i++) if (good_tiles[i]){
num_good++;
}
double [] tilts = getPlane( // {approx2d[0][0], approx2d[0][1], approx2d[0][2], xy0[0], xy0[1]}; // tiltX, tiltY, offset
ref_disparity, // final double [] data,
good_tiles, // final boolean [] mask,
ref_strength, // final double [] weight,
width, // final int width,
xy0, // final double [] xy0,
normal_damping, // final double normal_damping,
ref_Clt, // final QuadCLT dbg_scene,
dbg_title1); // String dbg_title)
if (tilts == null) {
System.out.println("getDisparityPlaneSinglePass(): tilts_stage1= null");
return null;
}
if (debugLevel >-3) {
System.out.println("getDisparityPlaneSinglePass(): tiltX="+tilts[0]+
" tiltY="+tilts[1]+" offset="+tilts[2]+" fraction good="+(1.0*num_good/ref_disparity.length)+" num_good="+num_good);
}
return new double [] {tilts[0], tilts[1], tilts[2], 1.0*num_good/ref_disparity.length};
}
......@@ -1047,10 +1116,10 @@ public class GroundPlane {
public static double [][] prepareTerrainRender(
final CLTParameters clt_parameters,
final QuadCLT ref_Clt,
final boolean tilted_plane, // if true, use tilted ground plane. If false - use horizontal plane and apply rotation
final double test_bottom,
final int debugLevel) {
boolean use_disparity_plane = debugLevel < 1000; // until fixed with 3D
GroundPlane gp = ref_Clt.getGroundPlane();
if (gp == null) {
System.out.println("prepareTerrainRender(): scene "+ref_Clt.toString()+" GroundPlane == null.");
......@@ -1068,10 +1137,25 @@ public class GroundPlane {
int tilesX = ref_Clt.getTilesX();
int tilesY = ref_Clt.getTilesY();
double [] terrain_plane = new double [tilesX*tilesY];
if (use_disparity_plane) {
if (tilted_plane) {
int [] xy0 = {tilesX/2, tilesY/2};
double inf_disparity = ref_Clt.getDispInfinityRef();
double [] disparity_tilts = gp.getDisparityTilts();
if ((test_bottom >0) && (test_bottom < 1)) {
int y1 = (int) ((terrain_plane.length/tilesX) * test_bottom);
if (disparity_tilts != null) {
for (int i = 0; i < terrain_plane.length; i++) {
int x = i % tilesX;
int y = i / tilesX;
if (y > y1) {
y = y1;
}
double dx = x-xy0[0];
double dy = y-xy0[1];
terrain_plane[i] = disparity_tilts[0] * dx + disparity_tilts[1] * dy + disparity_tilts[2] + inf_disparity;
}
}
} else {
if (disparity_tilts != null) {
for (int i = 0; i < terrain_plane.length; i++) {
int x = i % tilesX;
......@@ -1081,6 +1165,7 @@ public class GroundPlane {
terrain_plane[i] = disparity_tilts[0] * dx + disparity_tilts[1] * dy + disparity_tilts[2] + inf_disparity;
}
}
}
} else {
Arrays.fill(terrain_plane, corrected_disparity); // +0.3); // 260); // 0.256);
}
......@@ -1125,20 +1210,25 @@ public class GroundPlane {
*/
public static double [] getPlaneDualPass( // returns tiltX, tiltY, disp_center, frac_good
final CLTParameters clt_parameters,
final double [] data,
final double [] weights,
final double gnd_percent_low,
final double gnd_percent_high,
final double gnd_max_high_over,
final int min_good1, // minimal good tiles after pass1
final double max_abs_diff, // maximal absolute disparity difference from the plane
final double max_rel_diff, // maximal relative disparity difference from the plane
final double normal_damping,
final int width,
final boolean [] good_tiles, // null or boolean[data.length] // should all be false
final String dbg_title,
final QuadCLT dbg_scene,
final int debugLevel) {
final double gnd_percent_low = clt_parameters.imp.fgnd_percent_low; // 0.01; // Discard lowest outliers. Percentile to remove lowest elevation outliers during initial terrain filtering
final double gnd_percent_high= clt_parameters.imp.fgnd_percent_high; // 0.2; // Discard highest outliers. Percentile to remove highest elevation outliers during initial terrain filtering.
final double gnd_max_high_over=clt_parameters.imp.fgnd_max_high_over; // 0.1; // Absolute disparity over lowest. Absolute disparity over lowest. Minimal of this value and the one determined by the highest outliers percentile will be applied. // pix = make dependent on average disparity?
// final int min_good1 = clt_parameters.imp.fgnd_min_good1; //10; // Minimal good tiles in stage 1. Minimal number of remaining tiles after the first stage filtering.
final double max_abs_diff = clt_parameters.imp.fgnd_max_abs_diff; // 0.03; // Absolute disparity from plane. Maximal absolute disparity difference from the stage 1 - found plane (stage2 mask).
final double max_rel_diff = clt_parameters.imp.fgnd_max_rel_diff; // 0.03; // Relative disparity from plane. Maximal relative disparity difference from the stage 1 - found plane (stage2 mask).
final double normal_damping = clt_parameters.imp.fgnd_normal_damping; // 0.001; // Damping parameter for planes. Pull planes to horizontal when there is not enough data for tilts.
int num_bins = 1000;
String dbg_title1 = (dbg_title != null) ? (dbg_title + "-stage1") : null;
String dbg_title2 = (dbg_title != null) ? (dbg_title + "-stage2") : null;
......@@ -1286,17 +1376,6 @@ public class GroundPlane {
width, // int width, // int tilesX,
data.length/width); // int height, // int tilesY,
/*
ShowDoubleFloatArrays.showArrays(
dbg_img,
width,
height,
true,
dbg_title+"-result",
dbg_titles);
*/
}
return rslt_tilts;
}
......@@ -1403,15 +1482,6 @@ public class GroundPlane {
new double[][] {data,plane,diff,masked,dweight,dmask}, // double [][] data,
width, // int width, // int tilesX,
data.length/width); // int height, // int tilesY,
/*
ShowDoubleFloatArrays.showArrays(
new double[][] {data,plane,diff,masked,dweight,dmask},
width,
data.length/width,
true,
dbg_title,
new String[] {"data","approx","diff","masked","weight","mask"});
*/
}
return new double[] {approx2d[0][0], approx2d[0][1], approx2d[0][2], xy0[0], xy0[1]}; // tiltX, tiltY, offset
......@@ -1603,47 +1673,9 @@ public class GroundPlane {
// It is approximate for small angles. OK for now
double [][] to_ground_xyzatr = ErsCorrection.invertXYZATR(ground_xyzatr);
return to_ground_xyzatr; // from the camera coordinates to in-plane coordinates
/*
double [][] ground_xyzatr1 = new double [][] {{0, 0, z_tilts[0]},{Math.asin(z_tilts[1]), -Math.asin(z_tilts[2]), 0.0}};
double [][] to_ground_xyzatr1 = ErsCorrection.invertXYZATR(ground_xyzatr1);
*/
/*
if (dbg_title != null) {
double [] plane=new double[data.length];
double [] diff=new double[data.length];
double [] dweight = (weight != null) ? weight: new double[data.length];
double [] dmask = new double[data.length];
double [] masked = new double[data.length];
Arrays.fill(masked, Double.NaN);
for (int nPix = 0; nPix < plane.length; nPix++) {
int x = nPix % width;
int y = nPix / width;
double dx = x-xy0[0];
double dy = y-xy0[1];
plane[nPix] = approx2d[0][2]+approx2d[0][0]*dx+approx2d[0][1]*dy;
diff[nPix] = data[nPix]-plane[nPix];
dmask[nPix] = ((mask == null) || Double.isNaN(data[nPix]))? Double.NaN : (mask[nPix]?2:1);
if ((mask == null) || mask[nPix]) {
masked[nPix] = diff[nPix];
}
}
ShowDoubleFloatArrays.showArrays(
new double[][] {data,plane,diff,masked,dweight,dmask},
width,
data.length/width,
true,
dbg_title,
new String[] {"data","approx","diff","masked","weight","mask"});
}
*/
// return new double[] {approx2d[0][0], approx2d[0][1], approx2d[0][2], xy0[0], xy0[1]}; // tiltX, tiltY, offset
}
static double [] getHistogram1d (
double [] data, // may have NaNs
double [] weights,
......@@ -1715,6 +1747,4 @@ public class GroundPlane {
return swd/sw;
}
}
......@@ -3331,7 +3331,7 @@ public class ImageDtt extends ImageDttCPU {
npair); // int num_pair)
if (pair_width < 0.1) {
if (globalDebugLevel > 1) {
System.out.println("pair_width["+npair+"]="+pair_width);
System.out.println("1.pair_width["+npair+"]="+pair_width);
}
} else {
weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
......
......@@ -8858,7 +8858,7 @@ public class ImageDttCPU {
}
}
if (ilayers < 0) { // assuming each defined tile has the same number of layers and non-null layers
System.out.println("corr_partial_dbg(): empty fcorr_data, all nulls");
System.out.println("corr_partial_dbg(): empty fcorr_data, all nulls 1");
return null;
}
......@@ -8935,7 +8935,7 @@ public class ImageDttCPU {
}
if (ilayers < 0) { // assuming each defined tile has the same number of layers and non-null layers
System.out.println("corr_partial_dbg(): empty fcorr_data, all nulls");
System.out.println("corr_partial_dbg(): empty fcorr_data, all nulls 2");
return null;
}
......@@ -16521,7 +16521,7 @@ public class ImageDttCPU {
npair); // int num_pair)
if (pair_width < 0.1) {
if (globalDebugLevel > 1) {
System.out.println("pair_width["+npair+"]="+pair_width);
System.out.println("2.pair_width["+npair+"]="+pair_width);
}
} else {
weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
......
......@@ -3,7 +3,7 @@
** IntersceneMatchParameters - Class for handling multiple configuration parameters
** related to the interscene match
**
** Copyright (C) 2022 Elphel, Inc.
** Copyright (C) 2022-2025 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
......@@ -1052,6 +1052,21 @@ min_str_neib_fpn 0.35
public boolean air_disp_corr = true; // refine disparity offset from IMS movements
public boolean air_disp_corr_save = false; // apply disparity correction to the geometry correction of the master_CLT
// Flat ground detection
public double fgnd_percent_low = 0.01; // Discard lowest outliers. Percentile to remove lowest elevation outliers during initial terrain filtering
public double fgnd_percent_high= 0.2; // Discard highest outliers. Percentile to remove highest elevation outliers during initial terrain filtering.
public double fgnd_max_high_over = 0.1; // Absolute disparity over lowest. Absolute disparity over lowest. Minimal of this value and the one determined by the highest outliers percentile will be applied. // pix = make dependent on average disparity?
public int fgnd_min_good1 = 10; // Minimal good tiles in stage 1. Minimal number of remaining tiles after the first stage filtering.
public double fgnd_max_abs_diff = 0.03; // Absolute disparity from plane. Maximal absolute disparity difference from the stage 1 - found plane (stage2 mask).
public double fgnd_max_rel_diff = 0.03; // Relative disparity from plane. Maximal relative disparity difference from the stage 1 - found plane (stage2 mask).
public double fgnd_blur_frac = 0.01; // Elevation histogram relative sigma. Elevation (relative to the plane) histogram LPF sigma as a fraction of the full range minimal of the absolute and relative above.
public double fgnd_weight_frac = 0.3; // Scale outliers from plane weights. Relative to full range disparity from plane to reduce weight twice - multiply remaining tiles weights by w= 1/(1 + (diff_from_plane^2/k_max_diff)^2).
public int fgnd_mtile_size = 16; // Macrotile size (50% overlapping). Size of the 50%-overlapping square macrotiles (in tiles).
public double fgnd_min_ev_rel = 0.3; // Minimal macrotile eigenvalues product. Square root of the eigenvalues product. Measure of how well is the macrotile local plane is defined. Fully populated macrotile has it 1.0.
public double fgnd_max_tilt = 0.2; // Maximal macrotile tilt. Maximal absolute value of the macrotile plane tilt: z to sqrt (x^2+y^2).
public double fgnd_top_percent = 0.5; // High elevation outliers percentile. Remove macrotiles that have the highest elevations (measured at the full camera FOV center).
public int fgnd_min_macro_tiles = 3; // Minimal number of macrotiles for high outliers. Minimal number of remaining macrotiles before removing high outpliers.
public double fgnd_normal_damping = 0.001; // Damping parameter for planes. Pull planes to horizontal when there is not enough data for tilts.
// TODO: move next parameters elsewhere - they are not the motion blur ones.
public int mb_gain_index_pose = 5; // pose readjust pass to switch to full mb_max_gain from mb_max_gain_inter
......@@ -1766,7 +1781,7 @@ min_str_neib_fpn 0.35
gd.addCheckbox ("LY infinity from IMS", this.run_ly_ims,
"Use horizontal movement from the IMS to adjust infinity disparity (if enabled above).");
gd.addCheckbox ("Use LMA for LY adjustments", this.run_ly_lma,
"Use LMA for LY adjustments.");
"Use LMA for LY adjustments. Should be set!");
gd.addCheckbox ("Fine-match images to IMS timing", this.match_ims_timing,
"Correlate image rotations with IMS ones. Only used when manually matching ims with images (sync lost). Fine-tuning offset by rotations.");
......@@ -1959,7 +1974,7 @@ min_str_neib_fpn 0.35
"Other scene index in a scene sequence (should have a very different angular/linear velocity component)");
gd.addTab("Fiter DSI","Filter DSI before use (interscene fitting, interscene accumulation, ML generation");
gd.addTab("Filter DSI","Filter DSI before use (interscene fitting, interscene accumulation, ML generation");
// gd.addMessage ("Depth map filtering parameters");
gd.addNumericField("Average lowest disparity neighbors", this.num_bottom, 0,3,"",
"Average this number of lowest disparity neighbors (of 8)");
......@@ -3091,6 +3106,39 @@ min_str_neib_fpn 0.35
gd.addCheckbox ("Save disparity correction", this.air_disp_corr_save,
"Save disparity correction with master_CLT parameters.");
gd.addTab("Flat ground", "Flat ground detection");
gd.addMessage ("Stage 1 filtering - finding lowest tiles, accommodating possible tilt with sufficient range");
gd.addNumericField("Discard lowest outliers", this.fgnd_percent_low, 5,7,"x",
"Percentile to remove lowest elevation outliers during initial terrain filtering.");
gd.addNumericField("Discard highest outliers", this.fgnd_percent_high, 5,7,"x",
"Percentile to remove highest elevation outliers during initial terrain filtering.");
gd.addNumericField("Absolute disparity over lowest", this.fgnd_max_high_over, 5,7,"pix",
"Absolute disparity over lowest. Minimal of this value and the one determined by the highest outliers percentile will be applied.");
gd.addNumericField("Minimal good tiles in stage 1", this.fgnd_min_good1, 0,3,"",
"Minimal number of remaining tiles after the first stage filtering.");
gd.addMessage ("Stage 2 filtering - matching all tiles (including removed in stage 1) to the stage 1 plane");
gd.addNumericField("Absolute disparity from plane", this.fgnd_max_abs_diff, 5,7,"pix",
"Maximal absolute disparity difference from the stage 1 - found plane (stage2 mask).");
gd.addNumericField("Relative disparity from plane", this.fgnd_max_rel_diff, 5,7,"x",
"Maximal relative disparity difference from the stage 1 - found plane (stage2 mask).");
gd.addNumericField("Elevation histogram relative sigma", this.fgnd_blur_frac, 5,7,"x",
"Elevation (relative to the plane) histogram LPF sigma as a fraction of the full range minimal of the absolute and relative above.");
gd.addNumericField("Scale outliers from plane weights", this.fgnd_weight_frac, 5,7,"x",
"Relative to full range disparity from plane to reduce weight twice - multiply remaining tiles weights by w= 1/(1 + (diff_from_plane^2/k_max_diff)^2).");
gd.addMessage ("Filtering by local planes intersection with the camera view ray");
gd.addNumericField("Macrotile size (50% overlapping)", this.fgnd_mtile_size, 0,3,"tiles",
"Size of the 50%-overlapping square macrotiles.");
gd.addNumericField("Minimal macrotile eigenvalues product", this.fgnd_min_ev_rel, 5,7,"x",
"Square root of the eigenvalues product. Measure of how well is the macrotile local plane is defined. Fully populated macrotile has it 1.0.");
gd.addNumericField("Maximal macrotile tilt", this.fgnd_max_tilt, 5,7,"x",
"Maximal absolute value of the macrotile plane tilt: z to sqrt (x^2+y^2).");
gd.addNumericField("High elevation outliers percentile", this.fgnd_top_percent, 5,7,"",
"Remove macrotiles that have the highest elevations (measured at the full camera FOV center).");
gd.addNumericField("Minimal number of macrotiles for high outliers", this.fgnd_min_macro_tiles, 0,3,"",
"Minimal number of remaining macrotiles before removing high outpliers.");
gd.addMessage ("Common to all plane fitting");
gd.addNumericField("Damping parameter for planes", this.fgnd_normal_damping, 5,7,"",
"Pull planes to horizontal when there is not enough data for tilts.");
gd.addTab("LMA sequence","Interscene LMA sequence control");
gd.addMessage("Parameters for control of the LMA pose adjustment sequence");
......@@ -4387,6 +4435,21 @@ min_str_neib_fpn 0.35
this.air_sync_ims = gd.getNextBoolean();
this.air_disp_corr = gd.getNextBoolean();
this.air_disp_corr_save = gd.getNextBoolean();
// Flat ground detection
this.fgnd_percent_low = gd.getNextNumber();
this.fgnd_percent_high = gd.getNextNumber();
this.fgnd_max_high_over = gd.getNextNumber();
this.fgnd_min_good1 = (int) gd.getNextNumber();
this.fgnd_max_abs_diff = gd.getNextNumber();
this.fgnd_max_rel_diff = gd.getNextNumber();
this.fgnd_blur_frac = gd.getNextNumber();
this.fgnd_weight_frac = gd.getNextNumber();
this.fgnd_mtile_size = (int) gd.getNextNumber();
this.fgnd_min_ev_rel = gd.getNextNumber();
this.fgnd_max_tilt = gd.getNextNumber();
this.fgnd_top_percent = gd.getNextNumber();
this.fgnd_min_macro_tiles=(int) gd.getNextNumber();
this.fgnd_normal_damping = gd.getNextNumber();
this.mb_gain_index_pose = (int) gd.getNextNumber();
this.mb_gain_index_depth =(int) gd.getNextNumber();
......@@ -5576,6 +5639,21 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"air_disp_corr", this.air_disp_corr+""); // boolean
properties.setProperty(prefix+"air_disp_corr_save", this.air_disp_corr_save+""); // boolean
properties.setProperty(prefix+"fgnd_percent_low", this.fgnd_percent_low+""); // double
properties.setProperty(prefix+"fgnd_percent_high", this.fgnd_percent_high+""); // double
properties.setProperty(prefix+"fgnd_max_high_over", this.fgnd_max_high_over+""); // double
properties.setProperty(prefix+"fgnd_min_good1", this.fgnd_min_good1+""); // int
properties.setProperty(prefix+"fgnd_max_abs_diff", this.fgnd_max_abs_diff+""); // double
properties.setProperty(prefix+"fgnd_max_rel_diff", this.fgnd_max_rel_diff+""); // double
properties.setProperty(prefix+"fgnd_blur_frac", this.fgnd_blur_frac+""); // double
properties.setProperty(prefix+"fgnd_weight_frac", this.fgnd_weight_frac+""); // double
properties.setProperty(prefix+"fgnd_mtile_size", this.fgnd_mtile_size+""); // int
properties.setProperty(prefix+"fgnd_min_ev_rel", this.fgnd_min_ev_rel+""); // double
properties.setProperty(prefix+"fgnd_max_tilt", this.fgnd_max_tilt+""); // double
properties.setProperty(prefix+"fgnd_top_percent", this.fgnd_top_percent+""); // double
properties.setProperty(prefix+"fgnd_min_macro_tiles", this.fgnd_min_macro_tiles+"");// int
properties.setProperty(prefix+"fgnd_normal_damping", this.fgnd_normal_damping+""); // double
properties.setProperty(prefix+"mb_gain_index_pose", this.mb_gain_index_pose+""); // int
properties.setProperty(prefix+"mb_gain_index_depth", this.mb_gain_index_depth+""); // int
......@@ -6748,6 +6826,21 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"air_disp_corr")!=null) this.air_disp_corr=Boolean.parseBoolean(properties.getProperty(prefix+"air_disp_corr"));
if (properties.getProperty(prefix+"air_disp_corr_save")!=null) this.air_disp_corr_save=Boolean.parseBoolean(properties.getProperty(prefix+"air_disp_corr_save"));
if (properties.getProperty(prefix+"fgnd_percent_low")!=null) this.fgnd_percent_low=Double.parseDouble(properties.getProperty(prefix+"fgnd_percent_low"));
if (properties.getProperty(prefix+"fgnd_percent_high")!=null) this.fgnd_percent_high=Double.parseDouble(properties.getProperty(prefix+"fgnd_percent_high"));
if (properties.getProperty(prefix+"fgnd_max_high_over")!=null) this.fgnd_max_high_over=Double.parseDouble(properties.getProperty(prefix+"fgnd_max_high_over"));
if (properties.getProperty(prefix+"fgnd_min_good1")!=null) this.fgnd_min_good1=Integer.parseInt(properties.getProperty(prefix+"fgnd_min_good1"));
if (properties.getProperty(prefix+"fgnd_max_abs_diff")!=null) this.fgnd_max_abs_diff=Double.parseDouble(properties.getProperty(prefix+"fgnd_max_abs_diff"));
if (properties.getProperty(prefix+"fgnd_max_rel_diff")!=null) this.fgnd_max_rel_diff=Double.parseDouble(properties.getProperty(prefix+"fgnd_max_rel_diff"));
if (properties.getProperty(prefix+"fgnd_blur_frac")!=null) this.fgnd_blur_frac=Double.parseDouble(properties.getProperty(prefix+"fgnd_blur_frac"));
if (properties.getProperty(prefix+"fgnd_weight_frac")!=null) this.fgnd_weight_frac=Double.parseDouble(properties.getProperty(prefix+"fgnd_weight_frac"));
if (properties.getProperty(prefix+"fgnd_mtile_size")!=null) this.fgnd_mtile_size=Integer.parseInt(properties.getProperty(prefix+"fgnd_mtile_size"));
if (properties.getProperty(prefix+"fgnd_min_ev_rel")!=null) this.fgnd_min_ev_rel=Double.parseDouble(properties.getProperty(prefix+"fgnd_min_ev_rel"));
if (properties.getProperty(prefix+"fgnd_max_tilt")!=null) this.fgnd_max_tilt=Double.parseDouble(properties.getProperty(prefix+"fgnd_max_tilt"));
if (properties.getProperty(prefix+"fgnd_top_percent")!=null) this.fgnd_top_percent=Double.parseDouble(properties.getProperty(prefix+"fgnd_top_percent"));
if (properties.getProperty(prefix+"fgnd_min_macro_tiles")!=null) this.fgnd_min_macro_tiles=Integer.parseInt(properties.getProperty(prefix+"fgnd_min_macro_tiles"));
if (properties.getProperty(prefix+"fgnd_normal_damping")!=null) this.fgnd_normal_damping=Double.parseDouble(properties.getProperty(prefix+"fgnd_normal_damping"));
if (properties.getProperty(prefix+"mb_gain_index_pose")!=null) this.mb_gain_index_pose=Integer.parseInt(properties.getProperty(prefix+"mb_gain_index_pose"));
if (properties.getProperty(prefix+"mb_ers_index")!=null) this.mb_ers_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_index"));
if (properties.getProperty(prefix+"mb_ers_y_index")!=null) this.mb_ers_y_index=Integer.parseInt(properties.getProperty(prefix+"mb_ers_y_index"));
......@@ -7897,6 +7990,21 @@ min_str_neib_fpn 0.35
imp.air_disp_corr = this.air_disp_corr;
imp.air_disp_corr_save = this.air_disp_corr_save;
imp.fgnd_percent_low = this.fgnd_percent_low;
imp.fgnd_percent_high = this.fgnd_percent_high;
imp.fgnd_max_high_over = this.fgnd_max_high_over;
imp.fgnd_min_good1 = this.fgnd_min_good1;
imp.fgnd_max_abs_diff = this.fgnd_max_abs_diff;
imp.fgnd_max_rel_diff = this.fgnd_max_rel_diff;
imp.fgnd_blur_frac = this.fgnd_blur_frac;
imp.fgnd_weight_frac = this.fgnd_weight_frac;
imp.fgnd_mtile_size = this.fgnd_mtile_size;
imp.fgnd_min_ev_rel = this.fgnd_min_ev_rel;
imp.fgnd_max_tilt = this.fgnd_max_tilt;
imp.fgnd_top_percent = this.fgnd_top_percent;
imp.fgnd_min_macro_tiles = this.fgnd_min_macro_tiles;
imp.fgnd_normal_damping = this.fgnd_normal_damping;
imp.mb_gain_index_pose = this.mb_gain_index_pose;
imp.mb_gain_index_depth = this.mb_gain_index_depth;
......
......@@ -589,6 +589,7 @@ public class MultisceneLY {
final int nrefine, // number of disparity refines for non-inf
final int threadsMax,
final int debug_level){
boolean show_images = clt_parameters.lyms_show_images;
final double [][][] inf_noinf_lazy_eye_data = new double [2][][];
int last_scene_index = scenes.length-1;
QuadCLT last_scene = scenes[last_scene_index];
......@@ -628,7 +629,6 @@ public class MultisceneLY {
}
}
}
inf_noinf_lazy_eye_data[0] = MultisceneLY.getLYData( // TODO: show lazy_eye_data[][]
clt_parameters, // final CLTParameters clt_parameters,
clt_parameters.lyms_clust_size, // final int clust_size,
......@@ -638,7 +638,7 @@ public class MultisceneLY {
corr_vector_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debug_level, // final int debug_level);
((debug_level >-2)?"INF":null)); // String debug_suffix);
(show_images?(last_scene.getImageName()+"-INF"):null)); // String debug_suffix);
// now for non-infinity:
double [][] target_disparities_noinf = MultisceneLY.useTilesLY(
clt_parameters.lyms_clust_size, // final int clust_size,
......@@ -672,16 +672,16 @@ public class MultisceneLY {
corr_vector_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debug_level, // final int debug_level);
((debug_level >-2)?"NOINF":null)); // String debug_suffix);
(show_images?(last_scene.getImageName()+"-NOINF"):null)); // String debug_suffix);
if (debug) {
if (show_images) {
showLY(
clt_parameters, // CLTParameters clt_parameters,
last_scene.getGeometryCorrection(), // GeometryCorrection gc,
clustersX, // int clustersX,
clustersY, // int clustersY,
inf_noinf_lazy_eye_data[1], // double [][] ly_data,
"LY_noinf-initial"); // String title);
last_scene.getImageName()+"-LY_noinf-initial"); // String title);
}
for (int n = 0; n < nrefine; n++) {
......@@ -701,16 +701,16 @@ public class MultisceneLY {
corr_vector_delta, // final CorrVector corr_vector_delta, // null or extrinsic vector offset, applied to all scenes
threadsMax, // final int threadsMax,
debug_level, // final int debug_level);
((debug_level >-2)?("NOINF"+n):null)); // String debug_suffix);
(show_images?("NOINF"+n):null)); // String debug_suffix);
if (debug) {
if (show_images) {
showLY(
clt_parameters, // CLTParameters clt_parameters,
last_scene.getGeometryCorrection(), // GeometryCorrection gc,
clustersX, // int clustersX,
clustersY, // int clustersY,
inf_noinf_lazy_eye_data[1], // double [][] ly_data,
"LY_noinf-"+n); // String title);
last_scene.getImageName()+"-LY_noinf-"+n); // String title);
}
}
......@@ -906,10 +906,15 @@ public class MultisceneLY {
scene.saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU)
scene. gpuResetCorrVector(); // is it needed - no, it is included in above
if (debug_level > -2) {
if (nscene == 0 ) {
System.out.print("Correlating scene ");
}
if (nscene == last_scene_index) {
System.out.println("Correlating last scene");
// System.out.println("Correlating last scene");
System.out.println("last");
} else {
System.out.println("Correlating scene "+nscene);
// System.out.println("Correlating scene "+nscene);
System.out.print(nscene+" ");
}
}
double [][] disparity_array = new double[tilesY][tilesX];
......@@ -1018,10 +1023,14 @@ public class MultisceneLY {
// Need to initialize and update tp_tasks_combo from GPU
image_dtt.setUpdateTasksGPU(
tp_tasks_combo); // final TpTask[] tp_tasks
double [][][] dcorr_tiles = show_corr? (new double [tp_tasks_combo.length][][]):null;
final double[][] disparity_map = new double [image_dtt.getDisparityTitles().length][];
final double [][][][] ddnd = new double [tilesY][tilesX][][];
boolean run_ly_lma = clt_parameters.imp.run_ly_lma;
if (!run_ly_lma) {
System.out.println("getLYData(): run_ly_lma is false, it should be true. Set it in clt_parameters.imp.run_ly_lma . Temporarily overwriting configuration using true");
run_ly_lma = true;
}
// Does not use disparity_map[DISPARITY_STRENGTH_INDEX]
image_dtt.clt_process_tl_correlations( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
......@@ -1045,7 +1054,7 @@ public class MultisceneLY {
//optional, may be null
disparity_map, // final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
ddnd, // [tilesY][tilesX][num_sensors][2] data for LY. Should be either null or [tilesY][tilesX][][]. disparity_map should be non-null
clt_parameters.imp.run_ly_lma, // correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
run_ly_lma, // correlate_lma, // final boolean run_lma, // calculate LMA, false - CM only
// define combining of all 2D correlation pairs for CM (LMA does not use them)
clt_parameters.img_dtt.mcorr_comb_width, //final int mcorr_comb_width, // combined correlation tile width (set <=0 to skip combined correlations)
clt_parameters.img_dtt.mcorr_comb_height,//final int mcorr_comb_height, // combined correlation tile full height
......@@ -1111,7 +1120,7 @@ public class MultisceneLY {
wh[0],
wh[1],
true,
"disparity_map_decimated"+"-"+debug_suffix,
last_scene.getImageName()+"disparity_map_decimated"+"-"+debug_suffix,
ImageDtt.getDisparityTitles(last_scene.getNumSensors(),last_scene.isMonochrome()) // ImageDtt.DISPARITY_TITLES
);
......@@ -1495,7 +1504,7 @@ public class MultisceneLY {
300, // 2.943408022525927E-0, // 4, // 17 10000x vy
500.0}; // 390.6185365641268}; //4}; // 18 100000x vz
// delta = 0.001; // should be 0.001
final boolean debug_img = false; // true; // false;
final boolean debug_img = clt_parameters.lyms_show_images; // true; // false;
final int last_scene_index = scenes.length-1;
final QuadCLT last_scene = scenes[last_scene_index];
final int numSens = last_scene.getNumSensors();
......@@ -1559,7 +1568,7 @@ public class MultisceneLY {
for (int nly = 0; nly < ly_initial2.length; nly++) if (ly_initial2[nly] != null ) {
ea.showInput(
ly_initial2[nly], // double[][] data,
"drv_reference-"+SINF_NOINF[nly]);// String title);
last_scene.getImageName()+"-drv_reference-"+SINF_NOINF[nly]);// String title);
}
System.out.println("Initial:\n"+last_scene.getGeometryCorrection().getCorrVector().toString(true)); // true - short out
double min_strength = 0.1; // 0.23
......@@ -1609,7 +1618,7 @@ public class MultisceneLY {
for (int nly = 0; nly < ly2.length; nly++) if (ly2[nly] != null ) {
ea.showInput(
ly2[nly], // double[][] data,
"drv_par-"+SINF_NOINF[nly]);// String title);
last_scene.getImageName()+"-drv_par-"+SINF_NOINF[nly]);// String title);
}
}
......@@ -1660,8 +1669,7 @@ public class MultisceneLY {
clustersX,
clustersY,
true,
"ND_test_npar-_"+npar+"-"+SINF_NOINF[nly],
sens_titles);
last_scene.getImageName()+"-ND_test_npar-_"+npar+"-"+SINF_NOINF[nly], sens_titles);
}
}
}
......
......@@ -6499,45 +6499,13 @@ public class OpticalFlow {
return null;
}
double [][] ds = new double [][] {dls[use_lma?1:0].clone(), dls[2]};
final double gnd_percent_low = 0.01; // discard lowest overliers
final double gnd_percent_high= 0.9; // high ground percentile
final double gnd_max_high_over = 0.5; // pix = make dependent on average disparity?
final int min_good1 = 50; // minimal good tiles after pass1
final double max_abs_diff = 0.05; // maximal absolute disparity difference from the plane
final double max_rel_diff = 0.1; // maximal relative disparity difference from the plane
final double normal_damping = 0.001; // pull to horizontal if not enough data
final double blur_frac = 0.01; // 0.03
final double weight_frac = 0.3; // multiply weight by w= 1/(1 + (err/k_max_diff)^2)
final int mtile_size = 16;
final double min_ev_rel = 0.3;
final double max_tilt = 0.2;
final double top_percent = 0.5; // remove above 50% center intersection
final int min_macro_tiles = 3;
final boolean [] good_tiles = new boolean[ds[0].length];
// String dbg_title =master_CLT.getImageName()+"-ground tilts";
String dbg_title = "-ground_tilts";
double [][] to_ground_xyzatr0= GroundPlane.getPlaneDualPassMetric( // returns to_ground_xyzatr (rotated around the ground point nadir of teh drone)
clt_parameters, // final CLTParameters clt_parameters,
master_CLT, // final QuadCLT ref_Clt,
gnd_percent_low, // final double gnd_percent_low,
gnd_percent_high, // final double gnd_percent_high,
gnd_max_high_over, // final double gnd_max_high_over,
min_good1, // final int min_good1, // minimal good tiles after pass1
max_abs_diff, // final double max_abs_diff, // maximal absolute disparity difference from the plane
max_rel_diff, // final double max_rel_diff, // maximal relative disparity difference from the plane
blur_frac, // final double blur_frac, // = 0.01; // 0.03
weight_frac, // final double weight_frac, // = 0.3; // multiply weight by w= 1/(1 + (err/k_max_diff)^2)
mtile_size, // final int mtile_size, // = 16;
min_ev_rel, // final double min_ev_rel, // = 0.3;
max_tilt, // final double max_tilt, // = 0.2;
top_percent, // final double top_percent, // = 0.5; // remove above 50% center intersection
min_macro_tiles, // final int min_macro_tiles, // = 3;
normal_damping, // final double normal_damping,
master_CLT.getTilesX(),// final int width,
good_tiles, // final boolean [] good_tiles, // null or boolean[data.length] // should all be false
null, // final double [] gnd_disp, // if not null
......@@ -6549,15 +6517,9 @@ public class OpticalFlow {
master_CLT.getErsCorrection().printVectors (to_ground_xyzatr0[0], to_ground_xyzatr0[1]);
double [] plane_tilts = GroundPlane.getPlaneDualPass( // returns tiltX, tiltY, disp_center, frac_good
clt_parameters, // final CLTParameters clt_parameters,
ds[0], // final double [] data,
ds[1], // final double [] weights,
gnd_percent_low, // final double gnd_percent_low,
gnd_percent_high, // final double gnd_percent_high,
gnd_max_high_over, // final double gnd_max_high_over,
min_good1, // final int min_good1, // minimal good tiles after pass1
max_abs_diff, // final double max_abs_diff, // maximal absolute disparity difference from the plane
max_rel_diff, // final double max_rel_diff, // maximal relative disparity difference from the plane
normal_damping, // final double normal_damping,
master_CLT.getTilesX(),// final int width,
good_tiles, // final boolean [] good_tiles, // null or boolean[data.length] // should all be false
dbg_title, // final String dbg_title,
......@@ -7382,22 +7344,25 @@ public class OpticalFlow {
System.out.println ("TexturedModel.output3d() -> "+ok_3d+" (terrain only, no vegetation)");
}
}
boolean export_terrain_sequence = true; // check master_CLT
if (export_terrain_sequence && !clt_parameters.imp.lock_position) {
final double test_bottom = 0.5;
{
double [] stereo_offset = ZERO3;
double [] stereo_atr = null;
double [][] gnp = GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
master_CLT, // final QuadCLT ref_Clt,
true, // final boolean tilted_plane,
test_bottom, // final double test_bottom,
debugLevel); // final int debugLevel)
double [][] ignp = null;
if (gnp != null) {
ignp = ErsCorrection.invertXYZATR(gnp);
// stereo_offset = new double [] {-ground_normal_pose[0][0],-ground_normal_pose[0][1],-ground_normal_pose[0][2]};
// stereo_offset = new double [] {-ground_normal_pose[0][0],-ground_normal_pose[0][1],-ground_normal_pose[0][2]};
stereo_offset = gnp[0]; // stereo_pose[0];
// stereo_atr = gnp[1]; // stereo_pose[1];
stereo_atr = new double [] {-ignp[1][0],-ignp[1][1],-ignp[1][2]}; // stereo_pose[1];
stereo_atr = gnp[1]; // stereo_pose[1];
// stereo_atr = new double [] {-ignp[1][0],-ignp[1][1],-ignp[1][2]}; // stereo_pose[1];
if (debugLevel > -3) {
System.out.println("Using airplane mode terrane as a single horizontal plane");
System.out.println("stereo_offset = ["+stereo_offset[0]+", "+stereo_offset[1]+", "+stereo_offset[2]+"]");
......@@ -7413,9 +7378,8 @@ public class OpticalFlow {
} else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
/* */
String scenes_suffix_test = master_CLT.getImageName()+"-TERRAIN-DISP"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_test = renderSceneSequence(
String scenes_suffix_disp = master_CLT.getImageName()+"-TERRAIN-DISP"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_disp = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
......@@ -7429,87 +7393,7 @@ public class OpticalFlow {
ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_test, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_test); // imp_scenes); // ImagePlus imp)
/*
String scenes_suffix = master_CLT.getImageName()+"-TERRAIN"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
new double [][] {stereo_offset,stereo_atr}, //
1, // int sensor_mask,
scenes_suffix, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain); // imp_scenes); // ImagePlus imp)
String scenes_suffix_mod = master_CLT.getImageName()+"-TERRAIN-MOD"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_mod = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // new double [] {-ignp[0][0],-ignp[0][1],-ignp[0][2]}, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
new double [][] {{-ignp[0][0],-ignp[0][1],-ignp[0][2]},stereo_atr}, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
1, // int sensor_mask,
scenes_suffix_mod, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_mod); // imp_scenes); // ImagePlus imp)
String scenes_suffix_mod1 = master_CLT.getImageName()+"-TERRAIN-MOD1"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_mod1 = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // new double [] {ignp[0][0],-ignp[0][1],ignp[0][2]}, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
new double [][] {{ignp[0][0],-ignp[0][1],ignp[0][2]}, stereo_atr},// stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
1, // int sensor_mask,
scenes_suffix_mod1, // String suffix,
scenes_suffix_disp, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
......@@ -7517,144 +7401,12 @@ public class OpticalFlow {
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_mod1); // imp_scenes); // ImagePlus imp)
imp_terrain_disp); // imp_scenes); // ImagePlus imp)
String scenes_suffix_mod2 = master_CLT.getImageName()+"-TERRAIN-MOD2"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_mod2 = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // new double [] {-gnp[0][0], gnp[0][1], -gnp[0][2]}, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
new double [][]{{-gnp[0][0], gnp[0][1], -gnp[0][2]},stereo_atr},
1, // int sensor_mask,
scenes_suffix_mod2, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_mod2); // imp_scenes); // ImagePlus imp)
String scenes_suffix_move = master_CLT.getImageName()+"-TERRAIN-MOVE"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_move = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
new double [][] {stereo_offset, ZERO3},
1, // int sensor_mask,
scenes_suffix_move, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_move); // imp_scenes); // ImagePlus imp)
String scenes_suffix_rot = master_CLT.getImageName()+"-TERRAIN-ROT"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_rot = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
ZERO3, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
new double [][] {ZERO3,stereo_atr},
1, // int sensor_mask,
scenes_suffix_rot, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_rot); // imp_scenes); // ImagePlus imp)
*/
/*
String scenes_suffix_inv = master_CLT.getImageName()+"-TERRAIN-INV"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_inv = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
new double [] {-stereo_offset[0],-stereo_offset[1],-stereo_offset[1]}, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
new double [] {-stereo_atr[0], -stereo_atr[1], -stereo_atr[1]}, //stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_inv, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_inv); // imp_scenes); // ImagePlus imp)
String scenes_suffix_inv2 = master_CLT.getImageName()+"-TERRAIN-INV2"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_inv2 = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
new double [] {-stereo_offset[0],-stereo_offset[1],-stereo_offset[1]}, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
new double [] { stereo_atr[0], stereo_atr[1], stereo_atr[1]}, //stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_inv2, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_inv2); // imp_scenes); // ImagePlus imp)
String scenes_suffix_inv3 = master_CLT.getImageName()+"-TERRAIN-INV3"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_inv3 = renderSceneSequence(
String scenes_suffix_test = master_CLT.getImageName()+"-TERRAIN-TEST2"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_test = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
true, // master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
......@@ -7663,39 +7415,11 @@ public class OpticalFlow {
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
new double [] { stereo_offset[0], stereo_offset[1], stereo_offset[1]}, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
new double [] {-stereo_atr[0], -stereo_atr[1], -stereo_atr[1]}, //stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
ZERO3, // gnp[0], // double [] stereo_offset, // offset reference camera {x,y,z}
null, // gnp[1], // double [] stereo_atr, // offset reference orientation (cuas)
gnp, // new double [][] {stereo_offset,stereo_atr}, //
1, // int sensor_mask,
scenes_suffix_inv3, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_inv3); // imp_scenes); // ImagePlus imp)
// ************** same for w/o inversion ****************
String scenes_suffix_ni = master_CLT.getImageName()+"-TERRAIN-NI"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_ni = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
gnp[0], // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
gnp[1], // null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_ni, // String suffix,
scenes_suffix_test, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
......@@ -7703,15 +7427,46 @@ public class OpticalFlow {
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_ni); // imp_scenes); // ImagePlus imp)
imp_terrain_test); // imp_scenes); // ImagePlus imp)
}
}
{
double [] stereo_offset = ZERO3;
double [] stereo_atr = null;
double [][] gnp = GroundPlane.prepareTerrainRender(
clt_parameters, // final CLTParameters clt_parameters,
master_CLT, // final QuadCLT ref_Clt,
false, // final boolean tilted_plane,
test_bottom, // final double test_bottom,
debugLevel); // final int debugLevel)
double [][] ignp = null;
if (gnp != null) {
ignp = ErsCorrection.invertXYZATR(gnp);
// stereo_offset = new double [] {-ground_normal_pose[0][0],-ground_normal_pose[0][1],-ground_normal_pose[0][2]};
stereo_offset = gnp[0]; // stereo_pose[0];
stereo_atr = gnp[1]; // stereo_pose[1];
// stereo_atr = new double [] {-ignp[1][0],-ignp[1][1],-ignp[1][2]}; // stereo_pose[1];
if (debugLevel > -3) {
System.out.println("Using airplane mode terrane as a single horizontal plane");
System.out.println("stereo_offset = ["+stereo_offset[0]+", "+stereo_offset[1]+", "+stereo_offset[2]+"]");
System.out.println("stereo_atr = ["+stereo_atr[0]+ ", "+stereo_atr[1]+ ", "+stereo_atr[2]+ "]");
// TODO add provisions to the non-flat terrain -modify terrain slice, keeping ground_normal_pose as a horizontal plane.
System.out.println("ignp[0] = ["+ignp[0][0]+", "+ignp[0][1]+", "+ignp[0][2]+"]");
System.out.println("ignp[1] = ["+ignp[1][0]+", "+ignp[1][1]+", "+ignp[1][2]+"]");
}
}
combo_dsn_final =master_CLT.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");
String scenes_suffix_inv_ni = master_CLT.getImageName()+"-TERRAIN-INV_NI"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_inv_ni = renderSceneSequence(
} else {
double [] terrain_disparity = combo_dsn_final[COMBO_DSN_INDX_TERRAIN];
String scenes_suffix = master_CLT.getImageName()+"-ITERRAIN4"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
true, // master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
......@@ -7720,10 +7475,11 @@ public class OpticalFlow {
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
new double [] {-gnp[0][0], -gnp[0][1], -gnp[0][1]}, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
new double [] {-gnp[1][0], -gnp[1][1], -gnp[1][1]}, //stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
ignp[0], // ZERO3, // stereo_offset, // ZERO3, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
gnp[1], // null, // stereo_atr, // null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
// ignp, // new double [][] {stereo_offset,stereo_atr}, //
1, // int sensor_mask,
scenes_suffix_inv_ni, // String suffix,
scenes_suffix, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
......@@ -7731,10 +7487,10 @@ public class OpticalFlow {
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_inv_ni); // imp_scenes); // ImagePlus imp)
imp_terrain); // imp_scenes); // ImagePlus imp)
String scenes_suffix_inv2_ni = master_CLT.getImageName()+"-TERRAIN-INV2-NI"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_inv2_ni = renderSceneSequence(
String scenes_suffix_flat = master_CLT.getImageName()+"-TERRAIN-FLAT"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_flat = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
......@@ -7745,10 +7501,11 @@ public class OpticalFlow {
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
new double [] {-gnp[0][0], -gnp[0][1], -gnp[0][1]}, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
new double [] { gnp[1][0], gnp[1][1], gnp[1][1]}, //stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
ZERO3, // stereo_offset, // ZERO3, // stereo_offset, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
null, // stereo_atr, // null, // stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
// gnp, // new double [][] {stereo_offset,stereo_atr}, //
1, // int sensor_mask,
scenes_suffix_inv2_ni, // String suffix,
scenes_suffix_flat, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
......@@ -7756,36 +7513,10 @@ public class OpticalFlow {
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_inv2_ni); // imp_scenes); // ImagePlus imp)
imp_terrain_flat); // imp_scenes); // ImagePlus imp)
String scenes_suffix_inv3_ni = master_CLT.getImageName()+"-TERRAIN-INV3-NI"; // quadCLTs[quadCLTs.length-1][quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain_inv3_ni = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles,
1, // int mode3d,
false, // boolean toRGB,
new double [] { gnp[0][0], gnp[0][1], gnp[0][1]}, // ZERO3, // double [] stereo_offset, // offset reference camera {x,y,z}
new double [] {-gnp[1][0], -gnp[1][1], -gnp[1][1]}, //stereo_atr, // null, // double [] stereo_atr, // offset reference orientation (cuas)
1, // int sensor_mask,
scenes_suffix_inv3_ni, // String suffix,
terrain_disparity, // selected_disparity, // double [] ref_disparity,
quadCLTs, // QuadCLT [] quadCLTs,
master_CLT, // ref_index, // int ref_index,
threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_terrain_inv3_ni); // imp_scenes); // ImagePlus imp)
*/
}
}
if ((combo_dsn_final.length <= COMBO_DSN_INDX_TERRAIN) || (combo_dsn_final[COMBO_DSN_INDX_TERRAIN] == null)) {
......@@ -8721,19 +8452,23 @@ public class OpticalFlow {
use_tarz, // boolean use_tarz, // derivatives by tarz, not symmetrical vectors
debugLevel); // final int debugLevel);
}
if (clt_parameters.lyms_show_images) {
for (int nly = 00; nly < lazy_eye_data2.length; nly++) if (lazy_eye_data2[nly] != null ) {
ea.showInput(
lazy_eye_data2[nly], // double[][] data,
"drv_reference-"+MultisceneLY.SINF_NOINF[nly]);// String title);
quadCLTs[ref_index].getImageName()+"-drv_reference-"+MultisceneLY.SINF_NOINF[nly]);// String title);
}
}
double [][] lazy_eye_data = MultisceneLY.mergeLY(
adjust_mode, // MSLY_MODE adjust_mode,
lazy_eye_data2, // double [][][] lazy_eye_data2,
force_disparity); // boolean [] force_disparity // null or [clusters]
ea.setForceDisparity(force_disparity);
if (clt_parameters.lyms_show_images) {
ea.showInput(
lazy_eye_data, // double[][] data,
"ly_combo-"+lazy_eye_data.toString());// String title);
quadCLTs[ref_index].getImageName()+"-ly_combo");// String title);
}
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
......@@ -13624,9 +13359,12 @@ public class OpticalFlow {
double max_rad2 = scene_extrap_rad * scene_extrap_rad * tileSize * tileSize; // in pixels
final double [][] disparity_scenes = new double [scenes.length][]; // [tilesX*tilesY];
// final double [][] ref_pXpYD = new double[3][];
final int dbg_tileX=70;
final int dbg_tileY=19;
final int dbg_tileX=-70;
final int dbg_tileY=-19;
final int dbg_tile=dbg_tileY * tilesX + dbg_tileX;
if (debug_level > -1) {
System.out.print("Correlating scene ");
}
for (int nscene = scenes.length-1; nscene >= 0; nscene--) {
String ts = scenes[nscene].getImageName();
double [][] scene_pXpYD;
......@@ -13781,19 +13519,24 @@ public class OpticalFlow {
}
if (debug_level > -1) {
if (nscene == indx_ref) {
System.out.println("Correlating reference scene"); // , nrefine = "+nrefine);
System.out.print("reference ");
// System.out.println("Correlating reference scene"); // , nrefine = "+nrefine);
} else {
System.out.println("Correlating scene "+nscene); // +nrefine+":"+nscene);
}
System.out.print(nscene+ " ");
// System.out.println("Correlating scene "+nscene); // +nrefine+":"+nscene);
}
}
} // for (int nscene = scenes.length-1; nscene >= 0; nscene--) {
if (debug_level > -1) {
System.out.println();
}
if (clt_parameters.lyms_show_images) {
ShowDoubleFloatArrays.showArrays(
disparity_scenes,
tilesX,
tilesY,
true,
"disparity_scenes");
ref_scene.getImageName()+"-disparity_scenes");
}
return disparity_scenes;
}
......
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