@@ -3389,7 +3389,7 @@ public class TileProcessor {
st.planes,// final TilePlanes.PlaneData [][] planes,
merge_candidates,// final int [][][] merge_candidates,
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
2,// -1, // debugLevel, // final int debugLevel)
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
...
...
@@ -3424,7 +3424,7 @@ public class TileProcessor {
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
2,// -1, // debugLevel, // final int debugLevel)
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
...
...
@@ -3582,13 +3582,24 @@ public class TileProcessor {
LinkPlaneslp=newLinkPlanes(clt_parameters,st);
// condition supertiles (create and manage links, merge)
st.planes,// final TilePlanes.PlaneData [][] planes,
10,// final int max_num_merge_try,
0);// debugLevel); // final int debugLevel);
// Used only by conflicts (not processed currently)
lp.calcStarValueStrength(
true,// boolean set_start_planes,
clt_parameters.plStarOrtho,// orthoWeight, // final double orthoWeight,
clt_parameters.plStarDiag,// diagonalWeight, // final double diagonalWeight,
clt_parameters.plStarPwr,// starPwr, // final double starPwr, // Divide cost by number of connections to this power
clt_parameters.plStarWeightPwr,// starWeightPwr, // final double starWeightPwr, // Use this power of tile weight when calculating connection cost
clt_parameters.plWeightToDens,// weightToDens, // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
clt_parameters.plStarValPwr,// starValPwr, //double starValPwr, // Raise value of each tile before averaging
2,// starSteps, // final int steps,
st.planes,// final TilePlanes.PlaneData [][] planes,
clt_parameters.plPreferDisparity,// preferDisparity, // final boolean preferDisparity)
debugLevel-2);
// re-generate planes in the supertiles using previously calculated planes (for tghe tiles and their neighbors)
// as hints, new planes will be assumed parallel to the known and possibly slightly offset in disparity
if(clt_parameters.plDiscrEn){
...
...
@@ -3627,37 +3638,50 @@ public class TileProcessor {
clt_parameters.plDiscrGrown,// final int plDiscrGrown, // = 0; // Only use tiles within this range from original selection
clt_parameters.plDiscrXMedian,// final double plDiscrXMedian, // = 1.5; // Remove outliers from the final selection that have distance more than scaled median
0,// -1, // debugLevel, // final int debugLevel)
debugLevel,// -1, // debugLevel, // final int debugLevel)
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
0.0,// 3, // final double disp_far, // minimal disparity to select (or NaN)
Double.NaN,// final double disp_near, // maximal disparity to select (or NaN)
clt_parameters.plDispNorm,// final double dispNorm, // Normalize disparities to the average if above
0.0,// final double min_weight,
clt_parameters.plMinPoints,// final int min_tiles,
// parameters to reduce outliers
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
2,// -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" planes by merging, recalculating connections");
if(num_removed_by_merging==0){// re-calculate all links
// Consider supertiles with conflicts, merge conflicting layers with relaxed requirements
}else{// to be removed after testing the new version
for(intnum_merge_try=0;num_merge_try<max_num_tries;num_merge_try++){// smooth and merge
st.resetPlanesMod();// clean start
planes_mod=st.planesSmooth_old(
lp,// LinkPlanes lp,
clt_parameters.plPull,// final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors
clt_parameters.plMaxEigen,// final double maxValue, // do not combine with too bad planes
clt_parameters.plIterations,// final int num_passes,
clt_parameters.plStopBad,// Do not update supertile if any of connected neighbors is not good (false: just skip that neighbor)
clt_parameters.plNormPow,// 0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1
Math.pow(10.0,-clt_parameters.plPrecision),// final double maxDiff, // maximal change in any of the disparity values
clt_parameters.plPreferDisparity,
debugLevel,// 0, // 1,// 0, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// create costs for the modified planes
lp.interPlaneCosts(
true,// final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
lp.setExclusiveLinks(
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
// 2.5, //final double max_cost
lp.getExNeibCost()*lp.getExNeibSmooth(),// final double max_cost,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// once more after updating exclusive links
planes_mod=st.planesSmooth_old(
lp,// LinkPlanes lp,
clt_parameters.plPull,// final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors
clt_parameters.plMaxEigen,// final double maxValue, // do not combine with too bad planes
clt_parameters.plIterations,// final int num_passes,
clt_parameters.plStopBad,// Do not update supertile if any of connected neighbors is not good (false: just skip that neighbor)
clt_parameters.plNormPow,// 0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1
Math.pow(10.0,-clt_parameters.plPrecision),// final double maxDiff, // maximal change in any of the disparity values
clt_parameters.plPreferDisparity,
debugLevel,// 0, // 1,// 0, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
lp.interPlaneCosts(
true,// final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// recalculate links? more smooth?
lp.setExclusiveLinks(
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
// 2.5, //final double max_cost
lp.getExNeibCost()*lp.getExNeibSmooth(),// final double max_cost,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// just in case? Not yet needed
lp.setNonExclusive(
// false, // final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
true,// final boolean en_sticks, // allow merging with bad plates
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
//TODO: Fix the mess to get rid of the plane_nooverlaps
// see if some modified planes need to be merged (but merge originals)
// TODO: Stricter requirements for merging here than for original planes?
Conflictsconflicts0_stats=newConflicts(
conflicts0,
st,
-1);// debugLevel);
System.out.println("Trying relaxed merging for conflicting plane pairs");
debugLevel+1,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
num_removed_by_merging=st.applyMergePlanes(
intnum_removed_by_merging=st.applyMergePlanes(
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
...
...
@@ -4103,93 +4044,185 @@ public class TileProcessor {
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
2,// -1, // debugLevel, // final int debugLevel)
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" conflicting planes by merging, recalculating connections");
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" planes by merging, recalculating connections");
if(num_removed_by_merging==0){// re-calculate all links
break;
// Consider supertiles with conflicts, merge conflicting layers with relaxed requirements
//TODO: Fix the mess to get rid of the plane_nooverlaps
Conflictsconflicts0_stats=newConflicts(
conflicts0,
st,
-1);// debugLevel);
System.out.println("Trying relaxed merging for conflicting plane pairs");
plane_nooverlaps=lp.overlapSameTileCandidates(
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
conflicting_candidates,// final int [][][] merge_candidates,\
0.4,// final double min_distance,
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// remove merge candidates that break connections to neighbors
if(debugLevel>100)lp.keepSameTileConnections(
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
conflicting_candidates,// final int [][][] merge_candidates,
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
true,// final boolean merge_low_eigen, here it should be true
true,// final boolean useNonExcl, // consider only directions available for non-exclusive merges
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// Consider supertiles with conflicts, merge conflicting layers with relaxed requirements
//end of TODO: Fix the mess to get rid of the plane_nooverlaps
// try to merge original (measured) planes, not smoothed ones
lp.costSameTileConnections(
// st.planes_mod, // final TilePlanes.PlaneData [][] planes,
st.planes,// final TilePlanes.PlaneData [][] planes,
conflicting_candidates,// final int [][][] merge_candidates,
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
lp.getConflRelax(),//relax_for_conflicts, // final double relax,
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
lp.getConflRelax(),// relax_for_conflicts, // final double relax,
debugLevel+1,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
num_removed_by_merging=st.applyMergePlanes(
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
0.0,// 3, // final double disp_far, // minimal disparity to select (or NaN)
Double.NaN,// final double disp_near, // maximal disparity to select (or NaN)
clt_parameters.plDispNorm,// final double dispNorm, // Normalize disparities to the average if above
0.0,// final double min_weight,
clt_parameters.plMinPoints,// final int min_tiles,
// parameters to reduce outliers
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" conflicting planes by merging, recalculating connections");
if(num_merge_try>=max_num_tries){
System.out.println("Exceeded maximal number of iterations, beaking anyway...");
break;
}
if(num_removed_by_merging==0){// re-calculate all links
break;
}
}
}
// Do the same as in conditionSuperTiles before smoothing again
lp.matchPlanes(
st.planes,// final TilePlanes.PlaneData [][] planes,
2,// -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
lp.interPlaneCosts(//
true,// final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
st.planes,// final TilePlanes.PlaneData [][] planes,
2,// -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// Do the same as in conditionSuperTiles before smoothing again
lp.filterNeighborPlanes(
st.planes,// final TilePlanes.PlaneData [][] planes,
true,// final boolean merge_low_eigen,
2,// -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// calculate it here - use results to keep some planes from merging