@@ -3389,7 +3389,7 @@ public class TileProcessor {
...
@@ -3389,7 +3389,7 @@ public class TileProcessor {
st.planes,// final TilePlanes.PlaneData [][] planes,
st.planes,// final TilePlanes.PlaneData [][] planes,
merge_candidates,// final int [][][] merge_candidates,
merge_candidates,// final int [][][] merge_candidates,
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
2,// -1, // debugLevel, // final int debugLevel)
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileX,
clt_parameters.tileY);
clt_parameters.tileY);
...
@@ -3424,7 +3424,7 @@ public class TileProcessor {
...
@@ -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.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.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
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.tileX,
clt_parameters.tileY);
clt_parameters.tileY);
...
@@ -3582,13 +3582,24 @@ public class TileProcessor {
...
@@ -3582,13 +3582,24 @@ public class TileProcessor {
LinkPlaneslp=newLinkPlanes(clt_parameters,st);
LinkPlaneslp=newLinkPlanes(clt_parameters,st);
// condition supertiles (create and manage links, merge)
// condition supertiles (create and manage links, merge)
// Used only by conflicts (not processed currently)
debugLevel);// final int debugLevel);
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)
// 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
// as hints, new planes will be assumed parallel to the known and possibly slightly offset in disparity
if(clt_parameters.plDiscrEn){
if(clt_parameters.plDiscrEn){
...
@@ -3627,37 +3638,50 @@ public class TileProcessor {
...
@@ -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.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
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)
true,// final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
2,// -1, // debugLevel, // final int debugLevel)
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
clt_parameters.tileX,
debugLevel,// final int debugLevel)
clt_parameters.tileY);
clt_parameters.tileX,
clt_parameters.tileY);
intnum_removed_by_merging=st.applyMergePlanes(
// recalculate links? more smooth?
st.planes,// final TilePlanes.PlaneData[][] planes,
lp.setExclusiveLinks(
merge_groups,// final int [][][] merge_groups,
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
// parameters to generate ellipsoids
// 2.5, //final double max_cost
0.0,// 3, // final double disp_far, // minimal disparity to select (or NaN)
lp.getExNeibCost()*lp.getExNeibSmooth(),// final double max_cost,
Double.NaN,// final double disp_near, // maximal disparity to select (or NaN)
debugLevel,// final int debugLevel)
clt_parameters.plDispNorm,// final double dispNorm, // Normalize disparities to the average if above
clt_parameters.tileX,
0.0,// final double min_weight,
clt_parameters.tileY);
clt_parameters.plMinPoints,// final int min_tiles,
// just in case? Not yet needed
// parameters to reduce outliers
lp.setNonExclusive(
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
// false, // final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
true,// final boolean en_sticks, // allow merging with bad plates
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
2,// -1, // debugLevel, // final int debugLevel)
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileX,
clt_parameters.tileY);
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
//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?
lp.getConflRelax(),// relax_for_conflicts, // final double relax,
debugLevel+1,// 2, // -1, // debugLevel, // final int debugLevel)
2,// -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileX,
clt_parameters.tileY);
clt_parameters.tileY);
num_removed_by_merging=st.applyMergePlanes(
intnum_removed_by_merging=st.applyMergePlanes(
st.planes,// final TilePlanes.PlaneData[][] planes,
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
// parameters to generate ellipsoids
...
@@ -4103,93 +4044,185 @@ public class TileProcessor {
...
@@ -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.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.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
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.tileX,
clt_parameters.tileY);
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
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
// 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);
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
lp.matchPlanes(
st.planes,// final TilePlanes.PlaneData [][] planes,