Search in sources :

Example 1 with ConfigRansac

use of boofcv.factory.geo.ConfigRansac in project BoofCV by lessthanoptimal.

the class ExampleStereoTwoViewsOneCamera method estimateCameraMotion.

/**
 * Estimates the camera motion robustly using RANSAC and a set of associated points.
 *
 * @param intrinsic   Intrinsic camera parameters
 * @param matchedNorm set of matched point features in normalized image coordinates
 * @param inliers     OUTPUT: Set of inlier features from RANSAC
 * @return Found camera motion.  Note translation has an arbitrary scale
 */
public static Se3_F64 estimateCameraMotion(CameraPinholeRadial intrinsic, List<AssociatedPair> matchedNorm, List<AssociatedPair> inliers) {
    ModelMatcher<Se3_F64, AssociatedPair> epipolarMotion = FactoryMultiViewRobust.essentialRansac(new ConfigEssential(intrinsic), new ConfigRansac(200, 0.5));
    if (!epipolarMotion.process(matchedNorm))
        throw new RuntimeException("Motion estimation failed");
    // save inlier set for debugging purposes
    inliers.addAll(epipolarMotion.getMatchSet());
    return epipolarMotion.getModelParameters();
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ConfigEssential(boofcv.factory.geo.ConfigEssential) ConfigRansac(boofcv.factory.geo.ConfigRansac) Se3_F64(georegression.struct.se.Se3_F64)

Example 2 with ConfigRansac

use of boofcv.factory.geo.ConfigRansac in project BoofCV by lessthanoptimal.

the class ExampleImageStitching method stitch.

/**
 * Given two input images create and display an image where the two have been overlayed on top of each other.
 */
public static <T extends ImageGray<T>> void stitch(BufferedImage imageA, BufferedImage imageB, Class<T> imageType) {
    T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType);
    T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType);
    // Detect using the standard SURF feature descriptor and describer
    DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null, null, imageType);
    ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
    AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 2, true);
    // fit the images using a homography.  This works well for rotations and distant objects.
    ModelMatcher<Homography2D_F64, AssociatedPair> modelMatcher = FactoryMultiViewRobust.homographyRansac(null, new ConfigRansac(60, 3));
    Homography2D_F64 H = computeTransform(inputA, inputB, detDesc, associate, modelMatcher);
    renderStitching(imageA, imageB, H);
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedPair(boofcv.struct.geo.AssociatedPair) BrightFeature(boofcv.struct.feature.BrightFeature) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) ConfigRansac(boofcv.factory.geo.ConfigRansac) Homography2D_F64(georegression.struct.homography.Homography2D_F64)

Aggregations

ConfigRansac (boofcv.factory.geo.ConfigRansac)2 AssociatedPair (boofcv.struct.geo.AssociatedPair)2 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)1 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)1 ConfigEssential (boofcv.factory.geo.ConfigEssential)1 BrightFeature (boofcv.struct.feature.BrightFeature)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 Se3_F64 (georegression.struct.se.Se3_F64)1