use of boofcv.abst.geo.bundle.BundleAdjustmentCamera in project BoofCV by lessthanoptimal.
the class MultiViewStereoFromKnownSceneStructure method pruneViewsThatAreSimilarByNeighbors.
/**
* Marks a view as used so that it can't be used as a center if most of the view is "covered" by another
* view which has a higher score and most of the view area is covered by other views. The exception to this
* rule is if there are a significant number of pixels not covered by any neighbors.
*/
protected void pruneViewsThatAreSimilarByNeighbors(SceneStructureMetric scene) {
for (int rankIndex = 0; rankIndex < arrayScores.size; rankIndex++) {
ViewInfo center = arrayScores.get(rankIndex);
List<StereoPairGraph.Edge> pairs = center.relations.pairs;
BundleAdjustmentCamera candidateCamera = scene.cameras.get(center.metric.camera).model;
computeRectification.setView1(candidateCamera, center.dimension.width, center.dimension.height);
scoreCoverage.initialize(center.dimension.width, center.dimension.height, computeRectification.view1_dist_to_undist);
scene.getWorldToView(center.metric, world_to_view1, tmp);
boolean tooSimilar = false;
for (int pairIdx = 0; pairIdx < pairs.size(); pairIdx++) {
StereoPairGraph.Edge pair = pairs.get(pairIdx);
ViewInfo connected = Objects.requireNonNull(mapScores.get(pair.other(center.relations).id));
// If the view has already been prune then there can't be any overlap
if (connected.used)
continue;
// Only consider overlap with views that have a better score (and have already been accepted)
if (connected.score < center.score)
continue;
// are identical. Break the tie using their ID
if (connected.score == center.score && connected.relations.id.compareTo(center.relations.id) < 0)
continue;
double intersection = computeIntersection(scene, connected);
if (intersection > maximumCenterOverlap) {
tooSimilar = true;
if (verbose != null)
verbose.printf("excluding view['%s'] because view['%s'] covered %.2f\n", center.relations.id, connected.relations.id, intersection);
break;
}
}
if (tooSimilar)
center.used = true;
}
}
use of boofcv.abst.geo.bundle.BundleAdjustmentCamera in project BoofCV by lessthanoptimal.
the class MultiViewStereoFromKnownSceneStructure method computeIntersection.
/**
* Computes how much the two rectified images intersect each other
*
* @return fraction of intersection, 0.0 to 1.0
*/
protected double computeIntersection(SceneStructureMetric scene, ViewInfo connected) {
BundleAdjustmentCamera connectedCamera = scene.cameras.get(connected.metric.camera).model;
// Compute the transform from view-1 to view-2
scene.getWorldToView(connected.metric, world_to_view2, tmp);
world_to_view1.invert(tmp).concat(world_to_view2, view1_to_view2);
// Compute rectification then apply coverage with geometric score
computeRectification.processView2(connectedCamera, connected.dimension.width, connected.dimension.height, view1_to_view2);
// Find how much the rectified image intersects
return scoreCoverage.fractionIntersection(connected.dimension.width, connected.dimension.height, computeRectification.undist_to_rect2);
}
Aggregations