clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plWorstWorsening2,// final double worst_worsening2 Worst case worsening for thin planes,
clt_parameters.plWorstEq, // final double worstEq, // Worst case worsening after merge with equal weights
clt_parameters.plWorstEq2, // final double worstEq2, // Worst case worsening for thin planes with equal weights
clt_parameters.plWeakWorsening, // final double worst_worsening,
clt_parameters.plOKMergeEigen, // final double okMergeEigen, f result of the merged planes is below, OK to use thin planes (higher) threshold
clt_parameters.plMaxWorldSin2, // final double maxWorldSin2,
clt_parameters.plDispNorm,
clt_parameters.plMaxEigen,
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
clt_parameters.plMinStrength,
0, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
importjava.awt.Point;
importjava.util.ArrayList;
importjava.util.Collections;
importjava.util.HashSet;
importjava.util.concurrent.atomic.AtomicInteger;
*/
publicclassLinkPlanes{
SuperTilesst;
...
...
@@ -59,6 +45,14 @@ public class LinkPlanes {
publicdoubleplMaxWorldSin2;// = 0.1; // Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable
publicdoubleplWeakWorsening;// = 1.0; // Relax merge requirements for weaker planes
publicdoubleplMaxOverlap;// = 0.1; // Maximal overlap between the same supertile planes to merge
// comparing merge quality for plane pairs
publicdoubleplCostKrq;// = 0.8; // Cost of merge quality weighted
publicdoubleplCostKrqEq;// = 0.2; // Cost of merge quality equal weight
publicdoubleplCostSin2;// = 100.0; // Cost of sin squared between normals
publicdoubleplCostRdist2;// =1000.0; // Cost of squared relative distances
publicintdbg_tileX;
publicintdbg_tileY;
...
...
@@ -80,6 +74,16 @@ public class LinkPlanes {
plMaxEigen=clt_parameters.plMaxEigen;
plEigenFloor=clt_parameters.plEigenFloor;// final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
plMinStrength=clt_parameters.plMinStrength;
plMaxOverlap=clt_parameters.plMaxOverlap;
plCostKrq=clt_parameters.plCostKrq;
plCostKrqEq=clt_parameters.plCostKrqEq;
plCostSin2=clt_parameters.plCostSin2;
plCostRdist2=clt_parameters.plCostRdist2;
dbg_tileX=clt_parameters.tileX;
dbg_tileY=clt_parameters.tileY;
this.st=st;
...
...
@@ -93,6 +97,9 @@ public class LinkPlanes {
intdebugLevel)
{
if((plane1==null)||(plane2==null))returnfalse;
if(debugLevel>1){
System.out.println("planesFit() debug:");
}
TilePlanes.PlaneDatamerged_pd=null;
TilePlanes.PlaneDatamerged_pd_eq=null;
if(plane1.getWeight()<plMinStrength){
...
...
@@ -127,7 +134,7 @@ public class LinkPlanes {
false,// boolean ignore_weights,
true,// boolean sum_weights,
plPreferDisparity,
debugLevel-1);// int debugLevel)
debugLevel-2);// int debugLevel)
merged_ev=merged_pd.getValue();
}
if(Double.isNaN(merged_ev_eq)){
...
...
@@ -138,7 +145,7 @@ public class LinkPlanes {
true,// boolean ignore_weights,
true,// boolean sum_weights,
plPreferDisparity,
debugLevel-1);// int debugLevel)
debugLevel-2);// int debugLevel)
merged_ev_eq=merged_pd_eq.getValue();
}
doublew1=plane1.getWeight();
...
...
@@ -191,10 +198,10 @@ public class LinkPlanes {
System.out.println(prefix+" (fit) world sin2 ="+
plane1.getWorldSin2(plane2));
System.out.println(prefix+" (fit)"+
" world dist this="+Math.sqrt(plane1.getWorldPlaneDist2(plane2))+
", world dist other="+Math.sqrt(plane2.getWorldPlaneDist2(plane1))+
", world dist sum="+Math.sqrt(plane1.getWorldPlaneDist2(plane2)+
plane2.getWorldPlaneDist2(plane1)));
" world rdist this="+Math.sqrt(plane1.getWorldPlaneRDist2(plane2))+
", world rdist other="+Math.sqrt(plane2.getWorldPlaneRDist2(plane1))+
", world rdist sum="+Math.sqrt(plane1.getWorldPlaneRDist2(plane2)+
plane2.getWorldPlaneRDist2(plane1)));
}
}
returntrue;
...
...
@@ -211,15 +218,19 @@ public class LinkPlanes {
System.out.println(prefix+" (do not fit) world sin2 ="+
plane1.getWorldSin2(plane2));
System.out.println(prefix+" (do not fit)"+
", world dist this="+Math.sqrt(plane1.getWorldPlaneDist2(plane2))+
", world dist other="+Math.sqrt(plane2.getWorldPlaneDist2(plane1))+
", world dist sum="+Math.sqrt(plane1.getWorldPlaneDist2(plane2)+
plane2.getWorldPlaneDist2(plane1)));
", world dist this="+Math.sqrt(plane1.getWorldPlaneRDist2(plane2))+
", world dist other="+Math.sqrt(plane2.getWorldPlaneRDist2(plane1))+
", world dist sum="+Math.sqrt(plane1.getWorldPlaneRDist2(plane2)+
plane2.getWorldPlaneRDist2(plane1)));
}
}
returnfalse;
}
// 0 - this_rq,
// 1 - this_rq_eq
// 2 - composite
// 3..7 contribution of each of the factor to the overall cost
publicdouble[]getFitQualities(
TilePlanes.PlaneDataplane1,// should belong to the same supertile (or be converted for one)
TilePlanes.PlaneDataplane2,
...
...
@@ -278,10 +289,34 @@ public class LinkPlanes {
plEigenFloor);// double eigen_floor)
this_rq/=(w1+w2);// for comparison reduce this value for stronger planes
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);
st.filterNeighborPlanes(
clt_parameters.plWorstWorsening,// final double worst_worsening,
clt_parameters.plWorstWorsening2,// final double worst_worsening2 Worst case worsening for thin planes,
clt_parameters.plWorstEq,// final double worstEq, // Worst case worsening after merge with equal weights
clt_parameters.plWorstEq2,// final double worstEq2, // Worst case worsening for thin planes with equal weights
clt_parameters.plWeakWorsening,// final double worst_worsening,
clt_parameters.plOKMergeEigen,// final double okMergeEigen, f result of the merged planes is below, OK to use thin planes (higher) threshold
clt_parameters.plMaxWorldSin2,// final double maxWorldSin2,
clt_parameters.plDispNorm,
clt_parameters.plMaxEigen,
clt_parameters.plEigenFloor,// final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
clt_parameters.plMinStrength,
0,// final int debugLevel)
System.out.println("Removed "+num_removed_by_merging+" planes by merging, recalculating connections");
if(num_removed_by_merging>0){// re-calculate all links
lp.matchPlanes(
st.planes,// final TilePlanes.PlaneData [][] planes,