Search in sources :

Example 6 with BundleAdjustmentCamera

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;
    }
}
Also used : BundleAdjustmentCamera(boofcv.abst.geo.bundle.BundleAdjustmentCamera) VerbosePrint(org.ddogleg.struct.VerbosePrint)

Example 7 with BundleAdjustmentCamera

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);
}
Also used : BundleAdjustmentCamera(boofcv.abst.geo.bundle.BundleAdjustmentCamera)

Aggregations

BundleAdjustmentCamera (boofcv.abst.geo.bundle.BundleAdjustmentCamera)7 SceneStructureMetric (boofcv.abst.geo.bundle.SceneStructureMetric)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 VerbosePrint (org.ddogleg.struct.VerbosePrint)3 SceneStructureCommon (boofcv.abst.geo.bundle.SceneStructureCommon)2 Se3_F64 (georegression.struct.se.Se3_F64)2 TriangulateNViewsMetricH (boofcv.abst.geo.TriangulateNViewsMetricH)1 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)1 RemoveBrownPtoN_F64 (boofcv.alg.distort.brown.RemoveBrownPtoN_F64)1 BundlePinhole (boofcv.alg.geo.bundle.cameras.BundlePinhole)1 BundlePinholeBrown (boofcv.alg.geo.bundle.cameras.BundlePinholeBrown)1 BundlePinholeSimplified (boofcv.alg.geo.bundle.cameras.BundlePinholeSimplified)1 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)1 PointToPixelTransform_F64 (boofcv.struct.distort.PointToPixelTransform_F64)1 UtilPoint3D_F64 (georegression.geometry.UtilPoint3D_F64)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 Point4D_F64 (georegression.struct.point.Point4D_F64)1 ArrayList (java.util.ArrayList)1 DogArray (org.ddogleg.struct.DogArray)1