Commit dbd2a71c authored by Andrey Filippov's avatar Andrey Filippov

Fixing batch mode with new features

parent c0c2cd6a
......@@ -225,6 +225,66 @@ public class BiCamDSI {
return selection;
}
/**
* Select small/thin near objects over infinity
* @param min_strength minimal strength of the tile and neighbors
* @param min_neibs minimal number of neighbors with close disparity
* @param min_disparity minimal disaparity
* @param disp_atolerance disparity absolute tolerance (to qualify for a similar neighbor)
* @param disp_rtolerance disparity relative tolerance (adds to absolute)
* @param infinity_select tile, previously assigned to infinity (or null)
* @param selection existing selection (to add to) or null
* @param disparity array of tile disparity values (may have NaN-s)
* @param strength array of tile strength values
* @return new selection (new or added to existing)
*/
public boolean [] selectNearOverInfinity(
double min_strength,
int min_neibs,
double min_disparity,
double disp_atolerance,
double disp_rtolerance,
boolean [] infinity_select,
boolean [] selection,
double [] disparity,
double [] strength) {
int num_tiles = disparity.length;
if (infinity_select == null) {
infinity_select = new boolean [num_tiles];
for (int nTile = 0; nTile < num_tiles; nTile++) infinity_select[nTile] = true;
}
if (selection == null) selection = new boolean [num_tiles];
boolean [] new_sel = selection.clone();
//tnImage
for (int nTile =0; nTile <num_tiles; nTile++)
if ( infinity_select[nTile] &&
!selection[nTile] &&
(strength[nTile] >= min_strength ) &&
(disparity[nTile] >= min_disparity)){
int nn = 0;
double tolerance = disp_atolerance + disparity[nTile] * disp_rtolerance;
double min_d = Math.max(disparity[nTile] - tolerance, min_disparity);
double max_d = disparity[nTile] + tolerance;
for (int dir = 0; dir < 8; dir++) {
int nTile1 = tnImage.getNeibIndex(nTile, dir);
if ( (nTile1 >=0) &&
((strength [nTile1] >= min_strength ) || selection[nTile1]) && // strong or already selected
(disparity[nTile1] >= min_d) &&
(disparity[nTile1] <= max_d)){
nn++;
/// if (selection[nTile]) nn++; // count selected as 2 ?
}
}
if (nn >= min_neibs) {
new_sel[nTile] = true;
}
}
for (int nTile =0; nTile <num_tiles; nTile++) {
selection[nTile] |= new_sel[nTile];
}
return selection;
}
/**
* Select far tiles (even lone) over infinity areas that have sufficient disparity and strength
* @param min_far_strength minimal tile strength (may be 0 as the tiles are already filtered)
......
......@@ -211,6 +211,15 @@ public class BiQuadParameters {
public double ltfar_trusted_s = 0.4; // Add even single tiles over infinity if strength (and disparity too) is sufficient
public double ltfar_trusted_d = 0.2; // Add even single tiles over infinity if disparity (and strength too) is sufficient
// Parameters to select near (too near to be processed as poles) objects over infinity background
public double ltgrp_min_strength = 0.2; // Minimal strength of the tile and neighbors
public int ltgrp_min_neibs = 2; // minimal number of neighbors with close disparity
public double ltgrp_gr_min_disparity = 0.5; // Minimal group disparity
public double ltgrp_gr_disp_atolerance = 0.2; // Group disparity absolute tolerance (to qualify for a similar neighbor)
public double ltgrp_gr_disp_rtolerance = 0.1; // Group disparity relative tolerance (adds to absolute)
// rig selection filtering
......@@ -581,10 +590,22 @@ public class BiQuadParameters {
gd.addMessage("Filtering selection of non-infinity tiles");
gd.addNumericField("Add even single tiles over infinity if STRENGTH (and disparity too) is sufficient", this.ltfar_trusted_s, 4,6,"",
"Add strong tiles over infinity areas that have both strenth and disparity above respective thersholds (re-add them after filtering)");
"Add strong tiles over infinity areas that have both strenth and disparity above respective thresholds (re-add them after filtering)");
gd.addNumericField("Add even single tiles over infinity if DISPARITY (and strength too) is sufficient", this.ltfar_trusted_d, 4,6,"pix",
"Add strong tiles over infinity areas that have both strenth and disparity above respective thersholds (re-add them after filtering)");
"Add strong tiles over infinity areas that have both strenth and disparity above respective thresholds (re-add them after filtering)");
gd.addMessage("Parameters to select near (too near to be processed as poles) objects over infinity background");
gd.addNumericField("Minimal strength of the tile and neighbors", this.ltgrp_min_strength, 4,6,"",
"Tile will be added to selection if the tile over infinity selection is strong enough and has several neighbors (of 8) with similar disparity and also strong");
gd.addNumericField("Minimal number of neighbors with close disparity", this.ltgrp_min_neibs, 0,3,"tiles",
"For thin objects (poles, wires) there may be just 2 neighbors");
gd.addNumericField("Minimal group disparity", this.ltgrp_gr_min_disparity, 4,6,"pix",
"Only process tiles that are close enough (and their qualifying neighbors too)");
gd.addNumericField("Group disparity absolute tolerance (to qualify for a similar neighbor)", this.ltgrp_gr_disp_atolerance, 4,6,"pix",
"Neighbors should have disparity different by not more than this");
gd.addNumericField("Group disparity relative tolerance", this.ltgrp_gr_disp_rtolerance, 4,6,"pix/pix",
"Increase disparity tolerance by this for each absolute disparity pixel");
gd.addTab("Rig selection","Rig tile selection filter");
......@@ -814,6 +835,13 @@ public class BiQuadParameters {
this.ltfar_trusted_s= gd.getNextNumber();
this.ltfar_trusted_d= gd.getNextNumber();
this.ltgrp_min_strength= gd.getNextNumber();
this.ltgrp_min_neibs= (int) gd.getNextNumber();
this.ltgrp_gr_min_disparity= gd.getNextNumber();
this.ltgrp_gr_disp_atolerance= gd.getNextNumber();
this.ltgrp_gr_disp_rtolerance= gd.getNextNumber();
this.rf_master_infinity= gd.getNextBoolean();
this.rf_master_near= gd.getNextBoolean();
this.rf_pre_expand= (int) gd.getNextNumber();
......@@ -1013,6 +1041,13 @@ public class BiQuadParameters {
properties.setProperty(prefix+"ltfar_trusted_s", this.ltfar_trusted_s+"");
properties.setProperty(prefix+"ltfar_trusted_d", this.ltfar_trusted_d+"");
properties.setProperty(prefix+"ltgrp_min_strength", this.ltgrp_min_strength+"");
properties.setProperty(prefix+"ltgrp_min_neibs", this.ltgrp_min_neibs+"");
properties.setProperty(prefix+"ltgrp_gr_min_disparity", this.ltgrp_gr_min_disparity+"");
properties.setProperty(prefix+"ltgrp_gr_disp_atolerance", this.ltgrp_gr_disp_atolerance+"");
properties.setProperty(prefix+"ltgrp_gr_disp_rtolerance", this.ltgrp_gr_disp_rtolerance+"");
properties.setProperty(prefix+"rf_master_infinity", this.rf_master_infinity+"");
properties.setProperty(prefix+"rf_master_near", this.rf_master_near+"");
properties.setProperty(prefix+"rf_pre_expand", this.rf_pre_expand+"");
......@@ -1210,6 +1245,12 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"ltfar_trusted_s")!=null) this.ltfar_trusted_s=Double.parseDouble(properties.getProperty(prefix+"ltfar_trusted_s"));
if (properties.getProperty(prefix+"ltfar_trusted_d")!=null) this.ltfar_trusted_d=Double.parseDouble(properties.getProperty(prefix+"ltfar_trusted_d"));
if (properties.getProperty(prefix+"ltgrp_min_strength")!=null) this.ltgrp_min_strength=Double.parseDouble(properties.getProperty(prefix+"ltgrp_min_strength"));
if (properties.getProperty(prefix+"ltgrp_min_neibs")!=null) this.ltgrp_min_neibs=Integer.parseInt(properties.getProperty(prefix+"ltgrp_min_neibs"));
if (properties.getProperty(prefix+"ltgrp_gr_min_disparity")!=null) this.ltgrp_gr_min_disparity=Double.parseDouble(properties.getProperty(prefix+"ltgrp_gr_min_disparity"));
if (properties.getProperty(prefix+"ltgrp_gr_disp_atolerance")!=null)this.ltgrp_gr_disp_atolerance=Double.parseDouble(properties.getProperty(prefix+"ltgrp_gr_disp_atolerance"));
if (properties.getProperty(prefix+"ltgrp_gr_disp_rtolerance")!=null)this.ltgrp_gr_disp_rtolerance=Double.parseDouble(properties.getProperty(prefix+"ltgrp_gr_disp_rtolerance"));
if (properties.getProperty(prefix+"rf_master_infinity")!=null) this.rf_master_infinity=Boolean.parseBoolean(properties.getProperty(prefix+"rf_master_infinity"));
if (properties.getProperty(prefix+"rf_master_near")!=null) this.rf_master_near=Boolean.parseBoolean(properties.getProperty(prefix+"rf_master_near"));
if (properties.getProperty(prefix+"rf_pre_expand")!=null) this.rf_pre_expand=Integer.parseInt(properties.getProperty(prefix+"rf_pre_expand"));
......@@ -1408,6 +1449,12 @@ public class BiQuadParameters {
bqp.ltfar_trusted_s= this.ltfar_trusted_s;
bqp.ltfar_trusted_d= this.ltfar_trusted_d;
bqp.ltgrp_min_strength = this.ltgrp_min_strength;
bqp.ltgrp_min_neibs = this.ltgrp_min_neibs;
bqp.ltgrp_gr_min_disparity = this.ltgrp_gr_min_disparity;
bqp.ltgrp_gr_disp_atolerance = this.ltgrp_gr_disp_atolerance;
bqp.ltgrp_gr_disp_rtolerance = this.ltgrp_gr_disp_rtolerance;
bqp.rf_master_infinity= this.rf_master_infinity;
bqp.rf_master_near= this.rf_master_near;
bqp.rf_pre_expand= this.rf_pre_expand;
......
......@@ -135,6 +135,12 @@ public class EyesisCorrectionParameters {
public boolean clt_batch_assign = true; // Assign tiles to surfaces
public boolean clt_batch_gen3d = true; // Generate 3d output: x3d and/or obj+mtl
public boolean clt_batch_dbg1 = true; // Generate debug images if a single set is selected
public boolean clt_batch_dsi = true; // Create and save DSI combo image with the model
public boolean clt_batch_dsi_aux = false; // Calculate and save aux camera DSI (currently it is offset from the main/rig data
public boolean clt_batch_save_extrinsics = true; // Save cameras extrinsic parameters with the model
public boolean clt_batch_save_all = true; // Save all parameters with the model
public String x3dModelVersion="v01";
public String jp4SubDir="jp4";
......@@ -263,7 +269,12 @@ public class EyesisCorrectionParameters {
cp.clt_batch_assign= this.clt_batch_assign;
cp.clt_batch_gen3d= this.clt_batch_gen3d;
cp.clt_batch_dbg1= this.clt_batch_dbg1;
}
cp.clt_batch_dsi= this.clt_batch_dsi;
cp.clt_batch_dsi_aux= this.clt_batch_dsi_aux;
cp.clt_batch_save_extrinsics= this.clt_batch_save_extrinsics;
cp.clt_batch_save_all= this.clt_batch_save_all;
}
public void initAuxFromMain(CorrectionParameters cp) { // from master to aux
......@@ -413,6 +424,11 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"clt_batch_gen3d", this.clt_batch_gen3d+"");
properties.setProperty(prefix+"clt_batch_dbg1", this.clt_batch_dbg1+"");
properties.setProperty(prefix+"clt_batch_dsi", this.clt_batch_dsi+"");
properties.setProperty(prefix+"clt_batch_dsi_aux", this.clt_batch_dsi_aux+"");
properties.setProperty(prefix+"clt_batch_save_extrinsics", this.clt_batch_save_extrinsics+"");
properties.setProperty(prefix+"clt_batch_save_all", this.clt_batch_save_all+"");
properties.setProperty(prefix+"thumb_width", this.thumb_width+"");
properties.setProperty(prefix+"thumb_height", this.thumb_height+"");
properties.setProperty(prefix+"thumb_h_center", this.thumb_h_center+"");
......@@ -557,7 +573,12 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"clt_batch_gen3d")!= null) this.clt_batch_gen3d=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_gen3d"));
if (properties.getProperty(prefix+"clt_batch_dbg1")!= null) this.clt_batch_dbg1=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dbg1"));
if (properties.getProperty(prefix+"thumb_width")!=null) this.thumb_width=Integer.parseInt(properties.getProperty(prefix+"thumb_width"));
if (properties.getProperty(prefix+"clt_batch_dsi")!= null) this.clt_batch_dsi=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi"));
if (properties.getProperty(prefix+"clt_batch_dsi_aux")!= null) this.clt_batch_dsi_aux=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_dsi_aux"));
if (properties.getProperty(prefix+"clt_batch_save_extrinsics")!= null) this.clt_batch_save_extrinsics=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_extrinsics"));
if (properties.getProperty(prefix+"clt_batch_save_all")!= null) this.clt_batch_save_all=Boolean.parseBoolean(properties.getProperty(prefix+"clt_batch_save_all"));
if (properties.getProperty(prefix+"thumb_width")!=null) this.thumb_width=Integer.parseInt(properties.getProperty(prefix+"thumb_width"));
if (properties.getProperty(prefix+"thumb_height")!=null) this.thumb_height=Integer.parseInt(properties.getProperty(prefix+"thumb_height"));
if (properties.getProperty(prefix+"thumb_h_center")!=null) this.thumb_h_center= Double.parseDouble(properties.getProperty(prefix+"thumb_h_center"));
if (properties.getProperty(prefix+"thumb_v_center")!=null) this.thumb_v_center= Double.parseDouble(properties.getProperty(prefix+"thumb_v_center"));
......@@ -899,6 +920,18 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Assign tiles to surfaces", this.clt_batch_assign); // 27
gd.addCheckbox ("Generate 3d output: x3d and/or obj+mtl", this.clt_batch_gen3d); // 28
gd.addCheckbox ("Generate debug images if a single set is selected", this.clt_batch_dbg1); // 29
gd.addCheckbox ("Create DSI combo image", this.clt_batch_dsi,
"Save main camera, dual-quad rig and optionally aux camera combo DSI image with the model");
gd.addCheckbox ("Include aux camera DSI data in the combo DSI", this.clt_batch_dsi_aux,
"Currently DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time");
gd.addCheckbox ("Save field adjustment data with the model", this.clt_batch_save_extrinsics,
"This data can be used to restore specific filed-adjusted cameras extrinsics used when the model was generated");
gd.addCheckbox ("Save all parameters with the model", this.clt_batch_save_all,
"Save a copy of all parameters with the model");
if (clt_parameters != null) {
// gd.addMessage ("============ selected CLT parameters ============");
gd.addTab ("CLT", "Modify selected CLT parameters");
......@@ -968,6 +1001,10 @@ public class EyesisCorrectionParameters {
this.clt_batch_assign= gd.getNextBoolean(); // 27
this.clt_batch_gen3d= gd.getNextBoolean(); // 28
this.clt_batch_dbg1= gd.getNextBoolean(); // 29
this.clt_batch_dsi= gd.getNextBoolean();
this.clt_batch_dsi_aux= gd.getNextBoolean();
this.clt_batch_save_extrinsics= gd.getNextBoolean();
this.clt_batch_save_all= gd.getNextBoolean();
if (clt_parameters != null) {
clt_parameters.grow_disp_max = gd.getNextNumber();
clt_parameters.gain_equalize = gd.getNextBoolean();
......
This diff is collapsed.
......@@ -926,7 +926,12 @@ public class LinkPlanes {
this_plane.initMergedValue(dir,other_planes.length); // filled with NaN
for (int np = 0; np < other_planes.length; np ++){
if (other_planes[np] != null) {
TilePlanes.PlaneData other_plane = this_plane.getPlaneToThis(
if (nsTile0 == 790) {
System.out.println("?LinkPlanes.matchPlanes() DEBUG1:");
System.out.println("?LinkPlanes.matchPlanes() DEBUG1:");
}
TilePlanes.PlaneData other_plane = this_plane.getPlaneToThis( // returns NaN with FRONTO
other_planes[np],
dl - 2); // debugLevel);
if (other_plane !=null) { // now always, but may add later
......
......@@ -203,7 +203,10 @@ public class QuadCLT {
// public void setProperties(){
// setProperties(this.properties_prefix);
// }
public void setProperties(String prefix){ // save
public void setProperties(String prefix, Properties properties){ // save
if (properties == null) {
properties = this.properties;
}
// System.out.println("setProperties("+prefix+")");
for (int n = 0; n < fine_corr.length; n++){
for (int d = 0; d < fine_corr[n].length; d++){
......@@ -5610,7 +5613,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
public boolean assignCLTPlanes(
public double [][] assignCLTPlanes(
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
......@@ -5618,14 +5621,14 @@ public class QuadCLT {
{
if (tp == null){
System.out.println("showCLTPlanes(): tp is null");
return false;
return null;
}
if (tp.clt_3d_passes == null){
System.out.println("showCLTPlanes(): tp.clt_3d_passes is null");
return false;
return null;
}
this.startStepTime=System.nanoTime();
boolean ok = tp.assignTilesToSurfaces(
double [][] assign_dbg = tp.assignTilesToSurfaces(
clt_parameters,
geometryCorrection,
threadsMax,
......@@ -5635,7 +5638,7 @@ public class QuadCLT {
Runtime.getRuntime().gc();
System.out.println("assignCLTPlanes(): processing finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return ok;
return assign_dbg;
}
......@@ -9199,13 +9202,13 @@ public class QuadCLT {
} else continue; // if (correctionsParameters.clt_batch_surf)
if (correctionsParameters.clt_batch_assign) {
boolean ok = tp.assignTilesToSurfaces(
double [][] assign_dbg = tp.assignTilesToSurfaces(
clt_parameters,
geometryCorrection,
threadsMax,
updateStatus,
debugLevelInner);
if (!ok) continue;
if (assign_dbg == null) continue;
} else continue; // if (correctionsParameters.clt_batch_assign)
if (correctionsParameters.clt_batch_gen3d) {
......
......@@ -1818,7 +1818,12 @@ public class SuperTiles{
}
sel_list.add(new Selections2(new_sel));
}
if (sel_list.isEmpty()) {
if (dl > 2){
System.out.println("dispClusterizeHighest(): nsTile="+nsTile+": nothing found");
}
continue;
}
plane_selections[nsTile] = new boolean [sel_list.size()][][]; //plane_sels;
for (int np = 0; np < plane_selections[nsTile].length; np++) {
plane_selections[nsTile][np] = sel_list.get(np).getSel();
......@@ -2546,6 +2551,8 @@ public class SuperTiles{
final int dbg_X,
final int dbg_Y)
{
// TODO: Make a configurable parameters (0 should also work)
final int min_fresh_used = 1; // minimal number of new tiles not already used by the other direction (hor/vert)
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
......@@ -2816,6 +2823,7 @@ public class SuperTiles{
new_planes_selections[np] = planes_selections[nsTile][np];
new_plane_types[np] = hor_planes[nsTile][np];
}
int planes_added = 0;
for (int nnp = 0; nnp < num_planes; nnp++) { // SelStrength ss:selStrengthList){
SelStrength ss = selStrengthList.get(nnp);
new_plane_types[np] = ss.type != 0; // 0 - vert, 1 - hor;
......@@ -2831,6 +2839,27 @@ public class SuperTiles{
// Filling small gaps in new selections before marking them as "used"
boolean [] used_before = (ss.type == 0) ? used_vert[nsTile][ml] : used_hor[nsTile][ml];
boolean [] this_used = sels_all[ss.type][ss.indx][ml].clone();
// See how many really new tiles has this_used;
int num_really_new = 0;
for (int i = 0; i < num_tiles; i++) if (this_used[i] && !used_vert[nsTile][ml][i] && !used_hor[nsTile][ml][i]) {
num_really_new++;
}
// see if is enough
if (num_really_new < min_fresh_used) {
for (int i = 0; i < num_tiles; i++){
used_before[i] |= this_used[i]; // Still mark them as used on this orientation
}
this_used = new boolean[this_used.length]; // unselect all
if (dl > 1){
System.out.println("initialDiscriminateTiles():"+nsTile+" selection does not provide enough previously unused tiles");
}
// disable these tiles in this orientation used
} else {
planes_added++;
}
boolean [] this_used_expanded = this_used.clone();
tnStile.growSelection(
2,
......@@ -2882,6 +2911,13 @@ public class SuperTiles{
}
np++;
}
if (planes_added == 0) {
if (dl > 1){
System.out.println("initialDiscriminateTiles():"+nsTile+": No new planes added");
}
continue;
}
planes_selections[nsTile] = new_planes_selections;
hor_planes[nsTile] = new_plane_types;
if (dl > 2){
......@@ -3456,7 +3492,7 @@ public class SuperTiles{
plFrontoOffs, // final double plFrontoOffs, // increasing weight of the near tiles by using difference between the reduced average as weight. <= 0 - disable
PlFrontoPow, // double fronto_pow, // = 1.0; // increase weight even more
hor_planes, // final boolean [][] hor_planes, // returns plane types (hor/vert)
debugLevel + 0, // 1, // 0, // 1, // + 2, // 1, // final int debugLevel,
debugLevel+(debug_initial_discriminate? 3:0), // 1, // 0, // 1, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y)
this.planes = new_planes; // save as "measured" (as opposed to "smoothed" by neighbors) planes
......
This diff is collapsed.
......@@ -270,7 +270,9 @@ public class TilePlanes {
{
if (!force && (world_xyz == null)) return Double.NaN;
if (wvectors == null) return Double.NaN;
Matrix norm_disp = new Matrix(this.getWorldXYZ(this.correctDistortions, 0),3); // normal to plane from disparity space
double [] anorm_disp = this.getWorldXYZ(this.correctDistortions, 0);
if (anorm_disp == null) return Double.NaN;
Matrix norm_disp = new Matrix(anorm_disp,3); // normal to plane from disparity space
Matrix norm_world = new Matrix(wvectors[0],3); // normal to plane from disparity space
Matrix cp = cross3d(norm_disp, norm_world);
double cp2 = cp.transpose().times(cp).get(0, 0);
......@@ -1273,7 +1275,7 @@ public class TilePlanes {
}
if ((dispNorm > 0.0) && (zxy[0] > dispNorm)) {
almost_fronto = false; // disable fronto for near objects completely
// almost_fronto = false; // disable fronto for near objects completely
}
this.fronto = almost_fronto;
return almost_fronto;
......@@ -2163,6 +2165,8 @@ public class TilePlanes {
double w = disp_str[nl][1][indx];
if ((w > 0.0) && !(disp_str[nl][0][indx] > 0.0)) {
System.out.println("BUG!!!: getPlaneFromMeas(): disp_str[nl][0]["+indx+"]="+disp_str[nl][0][indx]+", disp_str[nl][1]["+indx+"]="+disp_str[nl][1][indx]);
w = 0.0;
disp_str[nl][1][indx] = 0.0;
continue;
}
if (w > 0.0){
......@@ -3995,6 +3999,23 @@ public class TilePlanes {
px_py[0],
px_py[1],
this.correctDistortions);
if (Double.isNaN(disp)) {
System.out.println("getPlaneToThis(), px_py = {"+px_py[0]+", "+px_py[1]+"}, px_py_other = {"+px_py_other[0]+", "+px_py_other[1]+"}");
System.out.println("getPlaneToThis(), disp = "+disp);
System.out.println("getPlaneToThis(), pd="+ pd.toString());
System.out.println("getPlaneToThis(), otherPd="+ otherPd.toString());
System.out.println("getPlaneToThis(), pd.getWorldXYZ(this.correctDistortions)="+ pd.getWorldXYZ(this.correctDistortions));
System.out.println("getPlaneToThis(), wv1 = {"+ wv1[0]+", "+ wv1[1]+", "+ wv1[2]+"}");
System.out.println("getPlaneToThis(), wv2 = {"+ wv2[0]+", "+ wv2[1]+", "+ wv2[2]+"}");
double [] norm_xyz = pd.getWorldXYZ(this.correctDistortions);
System.out.println("getPlaneToThis(),norm_xyz="+ norm_xyz);
disp = geometryCorrection.getPlaneDisparity( // disparity (at this center) for crossing other supertile plane
norm_xyz, // will calculate if not yet done so. Should it use otherPd, not pd? and then clone later?
px_py[0],
px_py[1],
this.correctDistortions);
}
if (debugLevel > 0) {
System.out.println("getPlaneToThis(), px_py = {"+px_py[0]+", "+px_py[1]+"}, px_py_other = {"+px_py_other[0]+", "+px_py_other[1]+"}");
System.out.println("getPlaneToThis(), disp = "+disp);
......@@ -4178,6 +4199,15 @@ public class TilePlanes {
int debugLevel)
{
double delta = 0.0001;
// debugging:
if (world_xyz != null) {
double l2 = world_xyz[0]*world_xyz[0] + world_xyz[1]*world_xyz[1]+world_xyz[2]*world_xyz[2];
if (l2 < 0.5) {
System.out.println("getWorldXYZ(): l2="+l2); // +" this=\n"+this.toString());
world_xyz = null;
}
}
if (world_xyz != null) return world_xyz;
setCorrectDistortions(correct_distortions);
// get pixel coordinates of the plane origin point
......@@ -4271,6 +4301,10 @@ public class TilePlanes {
// convert plane normal vector to world coordinates
//world_xyz
world_xyz = norm_xyz.times((xyz.transpose().times(norm_xyz).get(0,0))).getColumnPackedCopy();
double l2 = world_xyz[0]*world_xyz[0] + world_xyz[1]*world_xyz[1]+world_xyz[2]*world_xyz[2];
if (l2 < 0.5) {
System.out.println("getWorldXYZ(): l2="+l2); // +" this=\n"+this.toString());
}
return world_xyz;
}
......
......@@ -2245,6 +2245,24 @@ public class TileProcessor {
System.out.println("showScan("+title+"): isMeasured()="+scan.isMeasured()+", isProcessed()="+scan.isProcessed()+", isCombo()="+scan.isCombo());
}
public double [][] getShowDS(
CLTPass3d scan,
boolean force_final)
{
double [][] dbg_img = getShowScan(scan);
double [][] ds = new double [2][];
if (!force_final && (dbg_img[2] != null)) {
ds[0] = dbg_img[2]; // disparity
} else {
ds[0] = dbg_img[1]; // final
}
if (!force_final && (dbg_img[7] != null)) {
ds[1] = dbg_img[7]; // strength
} else {
ds[1] = dbg_img[6]; // final strength
}
return ds;
}
public double [][] getShowScan(
CLTPass3d scan)
......@@ -4696,7 +4714,7 @@ public class TileProcessor {
}
public boolean assignTilesToSurfaces(
public double [][] assignTilesToSurfaces(
EyesisCorrectionParameters.CLTParameters clt_parameters,
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
......@@ -4712,7 +4730,7 @@ public class TileProcessor {
SuperTiles st = scan_prev.getSuperTiles();
TileSurface tileSurface = st.getTileSurface();
if (tileSurface == null){
return false;
return null; // false;
}
// show testure_tiles
......@@ -5069,10 +5087,10 @@ public class TileProcessor {
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf");
}
if (!batch_mode && (debugLevel > -1)) {
ta.showTileCost("before_",tile_layers_surf);
ta.showTileCosts("before_",tile_layers_surf);
ta.showTileCost("before_",tile_layers_surf); // , true);
ta.showTileCosts("before_",tile_layers_surf); //, true);
}
TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf);
TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf);// ,(debugLevel > -1));
for (int i = 0; i < ta_stats.length; i++){
System.out.println(ta_stats[i].toString());
......@@ -5097,12 +5115,12 @@ public class TileProcessor {
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf");
}
if (!batch_mode && (debugLevel > -2)) {
ta.showTileCost("after_",tile_layers_surf);
ta.showTileCost("after_",tile_layers_surf); // , true);
}
if (!batch_mode && (debugLevel > -1)) {
ta.showTileCosts("after_",tile_layers_surf);
ta.showTileCosts("after_",tile_layers_surf); // , true);
}
ta_stats = ta.statTileCosts(tile_layers_surf);
ta_stats = ta.statTileCosts(tile_layers_surf); // , (debugLevel > -1));
System.out.println("Optimized:");
for (int i = 0; i < ta_stats.length; i++){
System.out.println(ta_stats[i].toString());
......@@ -5122,10 +5140,14 @@ public class TileProcessor {
tileSel, // final boolean [][] tileSel,
debugLevel); // final int debugLevel,
double [][] assignments_dbg = tileSurface.getShowAssignment(dispStrength);
if (!batch_mode && clt_parameters.tsShow && (debugLevel > -2)){
tileSurface.showAssignment(
"assignments", // String title,
dispStrength); // final double [][][] dispStrength)
String title_asgn = "assignments";
String [] titles_asgn = tileSurface.getTitlesAssignment(dispStrength);
(new showDoubleFloatArrays()).showArrays(assignments_dbg, tilesX, tilesY, true, title_asgn, titles_asgn);
/// tileSurface.showAssignment(
/// "assignments", // String title,
/// dispStrength); // final double [][][] dispStrength)
}
boolean [][] assigned_sel = tileSurface.extractSelection(
batch_mode ? -5: 0, // final int debugLevel,
......@@ -5261,7 +5283,7 @@ public class TileProcessor {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
sdfa_instance.showArrays(img_data, tilesX, tilesY, true, "final_surfaces",titles);
}
return true;
return assignments_dbg;
}
//======================
......
......@@ -76,6 +76,12 @@ public class TileSurface {
static int CLUST_NUM_CONFLICTS_B = 6;
static int CLUST_NUM_STATS = 7;
static int ASGN_DISP = 0;
static int ASGN_A_DISP = 1;
static int ASGN_A_NAN = 2;
static int ASGN_INDX = 3;
static int ASGN_STRENGTH = 4;
static int ASGN_NG = 5;
// private int nsTilesstSize = 0; // 8;
......@@ -2776,6 +2782,57 @@ public class TileSurface {
public void showAssignment(
String title,
final double [][][] dispStrength)
{
String [] titles = getTitlesAssignment(dispStrength);
double [][] img_data = getShowAssignment(dispStrength);
(new showDoubleFloatArrays()).showArrays(img_data, imageTilesX, imageTilesY, true, title, titles);
}
public double [][] getShowAssignment(
final double [][][] dispStrength)
{
double [][] img_data = new double [ASGN_NG * tileLayers.length][];
for (int ml = 0; ml < tileLayers.length; ml ++){
if (dispStrength[ml] != null) {
img_data[ASGN_NG * ml + ASGN_DISP] = dispStrength[ml][0];
img_data[ASGN_NG * ml + ASGN_STRENGTH] = dispStrength[ml][1];
img_data[ASGN_NG * ml + ASGN_A_DISP] = new double [dispStrength[ml][0].length];
img_data[ASGN_NG * ml + ASGN_A_NAN] = new double [dispStrength[ml][0].length];
img_data[ASGN_NG * ml + ASGN_INDX] = new double [dispStrength[ml][0].length];
for (int nTile = 0; nTile < dispStrength[ml][0].length; nTile++){
int nSurfTile = getSurfaceTileIndex(nTile);
if (tileLayers[ml][nTile] > 0){
img_data[ASGN_NG * ml + ASGN_A_DISP][nTile] = tileData[nSurfTile][tileLayers[ml][nTile]-1].getDisparity();
img_data[ASGN_NG * ml + ASGN_A_NAN][nTile] = tileData[nSurfTile][tileLayers[ml][nTile]-1].getDisparity();
} else {
img_data[ASGN_NG * ml + ASGN_A_DISP][nTile] = dispStrength[ml][0][nTile];
img_data[ASGN_NG * ml + ASGN_A_NAN][nTile] = Double.NaN;
}
img_data[ASGN_NG * ml + ASGN_INDX][nTile] = tileLayers[ml][nTile];
}
}
}
return img_data;
}
public String [] getTitlesAssignment(
final double [][][] dispStrength)
{
int ng = 5;
String [] titles = new String[ng * tileLayers.length];
for (int ml = 0; ml < tileLayers.length; ml ++){
titles[ng * ml + ASGN_DISP] = "disp_"+ml;
titles[ng * ml + ASGN_A_DISP] = "a_disp_"+ml;
titles[ng * ml + ASGN_A_NAN] = "a_nan_"+ml;
titles[ng * ml + ASGN_INDX] = "index_"+ml;
titles[ng * ml + ASGN_STRENGTH] = "strength_"+ml;
}
return titles;
}
public void showAssignment_old(
String title,
final double [][][] dispStrength)
{
int layer_disp = 0;
int layer_a_disp = 1;
......@@ -2816,6 +2873,7 @@ public class TileSurface {
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, title, titles);
}
/**
* Unassign tiles that have too few connected other tiles (or total weight of the cluster is too small)
* This is a single-threaded method
......
This diff is collapsed.
......@@ -228,6 +228,29 @@ import ij.process.ImageProcessor;
} else imp[i]=null;
return imp;
}
public ImagePlus makeArrays(double[][] pixels, int width, int height, String title, String [] titles) {
int i,j;
if (pixels==null) {
System.out.println("showDoubleFloatArrays.makeArrays(): - pixel array is null");
}
float [] fpixels;
ImageStack array_stack=new ImageStack(width,height);
boolean not_empty = false;
for (i=0;i<pixels.length;i++) if (pixels[i]!=null) {
not_empty = true;
fpixels=new float[pixels[i].length];
for (j=0;j<fpixels.length;j++) fpixels[j]=(float)pixels[i][j];
array_stack.addSlice(titles[i], fpixels);
}
if (not_empty) {
ImagePlus imp_stack = new ImagePlus(title, array_stack);
imp_stack.getProcessor().resetMinAndMax();
// imp_stack.show();
return imp_stack;
}
return null;
}
public ImagePlus [] makeArrays(double[][] pixels, int width, int height, String [] titles) {
int i,j;
float [] fpixels;
......
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