Search in sources :

Example 1 with ViewInfo

use of boofcv.alg.mvs.MultiViewStereoFromKnownSceneStructure.ViewInfo in project BoofCV by lessthanoptimal.

the class TestMultiViewStereoFromKnownSceneStructure method scoreViewsSelectStereoPairs.

/**
 * Checks to see if a score is computed for each view and is "qualitatively" correct. This does not check
 * ti see if all the geometry is handled correctly since the rectified and unrectified views are the same.
 */
@Test
void scoreViewsSelectStereoPairs() {
    createScene(4);
    double threshold = 0.25;
    // make things more interesting by degrading the score for some pairs
    pairs.vertexes.get("id=" + 2).pairs.get(1).quality3D = 0.3;
    pairs.vertexes.get("id=" + 3).pairs.get(2).quality3D = 0.7;
    for (var e : pairs.vertexes.get("id=" + 0).pairs) {
        e.quality3D = threshold - 0.01;
    }
    var dummy = new DummyLookUp();
    var alg = new MultiViewStereoFromKnownSceneStructure<>(dummy, ImageType.SB_U8);
    alg.minimumQuality3D = threshold;
    // Initialize internal data structures
    alg.initializeScores(scene, pairs);
    assertEquals(4, dummy.requestShapes.size());
    assertEquals(0, dummy.requestImage.size());
    // Call function being tested
    alg.scoreViewsSelectStereoPairs(scene);
    // First one should not have a score since every connection was below the threshold
    assertEquals(0.0, alg.arrayScores.find((a) -> a.relations.indexSba == 0).score);
    // relative score for the other views is known
    ViewInfo v1 = alg.arrayScores.find((a) -> a.relations.indexSba == 1);
    ViewInfo v2 = alg.arrayScores.find((a) -> a.relations.indexSba == 2);
    ViewInfo v3 = alg.arrayScores.find((a) -> a.relations.indexSba == 3);
    assertTrue(v3.score > v1.score);
    assertTrue(v3.score > v2.score);
    assertTrue(v1.score > v2.score);
}
Also used : ViewInfo(boofcv.alg.mvs.MultiViewStereoFromKnownSceneStructure.ViewInfo) Test(org.junit.jupiter.api.Test)

Example 2 with ViewInfo

use of boofcv.alg.mvs.MultiViewStereoFromKnownSceneStructure.ViewInfo in project BoofCV by lessthanoptimal.

the class ColorizeMultiViewStereoResults method processMvsCloud.

/**
 * Extracts color information for the point cloud on a view by view basis.
 *
 * @param scene (Input) Geometric description of the scene
 * @param mvs (Input) Contains the 3D point cloud
 * @param indexColor (Output) RGB values are passed through to this function.
 */
public void processMvsCloud(SceneStructureMetric scene, MultiViewStereoFromKnownSceneStructure<?> mvs, BoofLambdas.IndexRgbConsumer indexColor) {
    // Get a list of views that were used as "centers"
    List<ViewInfo> centers = mvs.getListCenters();
    // Get the point cloud
    DogArray<Point3D_F64> cloud = mvs.getDisparityCloud().getCloud();
    // Step through each "center" view
    for (int centerIdx = 0; centerIdx < centers.size(); centerIdx++) {
        ViewInfo center = centers.get(centerIdx);
        if (!lookupImages.loadImage(center.relations.id, image))
            throw new RuntimeException("Couldn't find image: " + center.relations.id);
        // Which points came from this view/center
        int idx0 = mvs.getDisparityCloud().viewPointIdx.get(centerIdx);
        int idx1 = mvs.getDisparityCloud().viewPointIdx.get(centerIdx + 1);
        // Setup the camera projection model using bundle adjustment model directly
        BundleAdjustmentOps.convert(scene.getViewCamera(center.metric).model, image.width, image.height, intrinsic);
        Point2Transform2_F64 norm_to_pixel = new LensDistortionBrown(intrinsic).distort_F64(false, true);
        // Get the transform from world/cloud to this view
        scene.getWorldToView(center.metric, world_to_view, tmp);
        // Grab the colorized points from this view
        colorizer.process3(image, cloud.toList(), idx0, idx1, world_to_view, norm_to_pixel, indexColor);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) LensDistortionBrown(boofcv.alg.distort.brown.LensDistortionBrown) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) ViewInfo(boofcv.alg.mvs.MultiViewStereoFromKnownSceneStructure.ViewInfo)

Aggregations

ViewInfo (boofcv.alg.mvs.MultiViewStereoFromKnownSceneStructure.ViewInfo)2 LensDistortionBrown (boofcv.alg.distort.brown.LensDistortionBrown)1 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 Test (org.junit.jupiter.api.Test)1