Search in sources :

Example 6 with ScoreAssociateHamming_B

use of boofcv.abst.feature.associate.ScoreAssociateHamming_B in project BoofCV by lessthanoptimal.

the class VisualizeDepthVisualOdometryApp method changeSelectedAlgortihm.

private void changeSelectedAlgortihm(int whichAlg) {
    this.whichAlg = whichAlg;
    AlgType prevAlgType = this.algType;
    Class imageType = GrayU8.class;
    Class derivType = GImageDerivativeOps.getDerivativeType(imageType);
    DepthSparse3D<GrayU16> sparseDepth = new DepthSparse3D.I<>(1e-3);
    PkltConfig pkltConfig = new PkltConfig();
    pkltConfig.templateRadius = 3;
    pkltConfig.pyramidScaling = new int[] { 1, 2, 4, 8 };
    algType = AlgType.UNKNOWN;
    if (whichAlg == 0) {
        algType = AlgType.FEATURE;
        ConfigGeneralDetector configDetector = new ConfigGeneralDetector(600, 3, 1);
        PointTrackerTwoPass tracker = FactoryPointTrackerTwoPass.klt(pkltConfig, configDetector, imageType, derivType);
        alg = FactoryVisualOdometry.depthDepthPnP(1.5, 120, 2, 200, 50, false, sparseDepth, tracker, imageType, GrayU16.class);
    } else if (whichAlg == 1) {
        algType = AlgType.FEATURE;
        ConfigGeneralDetector configExtract = new ConfigGeneralDetector(600, 3, 1);
        GeneralFeatureDetector detector = FactoryPointTracker.createShiTomasi(configExtract, derivType);
        DescribeRegionPoint describe = FactoryDescribeRegionPoint.brief(null, imageType);
        ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
        AssociateDescription2D<TupleDesc_B> associate = new AssociateDescTo2D<>(FactoryAssociation.greedy(score, 150, true));
        PointTrackerTwoPass tracker = FactoryPointTrackerTwoPass.dda(detector, describe, associate, null, 1, imageType);
        alg = FactoryVisualOdometry.depthDepthPnP(1.5, 80, 3, 200, 50, false, sparseDepth, tracker, imageType, GrayU16.class);
    } else if (whichAlg == 2) {
        algType = AlgType.FEATURE;
        PointTracker tracker = FactoryPointTracker.combined_ST_SURF_KLT(new ConfigGeneralDetector(600, 3, 1), pkltConfig, 50, null, null, imageType, derivType);
        PointTrackerTwoPass twopass = new PointTrackerToTwoPass<>(tracker);
        alg = FactoryVisualOdometry.depthDepthPnP(1.5, 120, 3, 200, 50, false, sparseDepth, twopass, imageType, GrayU16.class);
    } else if (whichAlg == 3) {
        algType = AlgType.DIRECT;
        alg = FactoryVisualOdometry.depthDirect(sparseDepth, ImageType.pl(3, GrayF32.class), GrayU16.class);
    } else {
        throw new RuntimeException("Unknown selection");
    }
    if (algType != prevAlgType) {
        switch(prevAlgType) {
            case FEATURE:
                mainPanel.remove(featurePanel);
                break;
            case DIRECT:
                mainPanel.remove(directPanel);
                break;
            default:
                mainPanel.remove(algorithmPanel);
                break;
        }
        switch(algType) {
            case FEATURE:
                mainPanel.add(featurePanel, BorderLayout.NORTH);
                break;
            case DIRECT:
                mainPanel.add(directPanel, BorderLayout.NORTH);
                break;
            default:
                mainPanel.add(algorithmPanel, BorderLayout.NORTH);
                break;
        }
        mainPanel.invalidate();
    }
    setImageTypes(alg.getVisualType(), ImageType.single(alg.getDepthType()));
}
Also used : PkltConfig(boofcv.alg.tracker.klt.PkltConfig) FactoryDescribeRegionPoint(boofcv.factory.feature.describe.FactoryDescribeRegionPoint) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) ScoreAssociateHamming_B(boofcv.abst.feature.associate.ScoreAssociateHamming_B) FactoryPointTrackerTwoPass(boofcv.factory.feature.tracker.FactoryPointTrackerTwoPass) PointTrackerTwoPass(boofcv.abst.feature.tracker.PointTrackerTwoPass) GeneralFeatureDetector(boofcv.alg.feature.detect.interest.GeneralFeatureDetector) PointTrackerToTwoPass(boofcv.abst.feature.tracker.PointTrackerToTwoPass) AssociateDescription2D(boofcv.abst.feature.associate.AssociateDescription2D) PointTracker(boofcv.abst.feature.tracker.PointTracker) FactoryPointTracker(boofcv.factory.feature.tracker.FactoryPointTracker)

Aggregations

ScoreAssociateHamming_B (boofcv.abst.feature.associate.ScoreAssociateHamming_B)6 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)6 TupleDesc_B (boofcv.struct.feature.TupleDesc_B)4 GrayF32 (boofcv.struct.image.GrayF32)4 Random (java.util.Random)4 AssociateDescTo2D (boofcv.abst.feature.associate.AssociateDescTo2D)2 AssociateDescription2D (boofcv.abst.feature.associate.AssociateDescription2D)2 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)2 WrapDescribeBrief (boofcv.abst.feature.describe.WrapDescribeBrief)2 PointTracker (boofcv.abst.feature.tracker.PointTracker)2 PointTrackerToTwoPass (boofcv.abst.feature.tracker.PointTrackerToTwoPass)2 PointTrackerTwoPass (boofcv.abst.feature.tracker.PointTrackerTwoPass)2 EasyGeneralFeatureDetector (boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)2 GeneralFeatureDetector (boofcv.alg.feature.detect.interest.GeneralFeatureDetector)2 PkltConfig (boofcv.alg.tracker.klt.PkltConfig)2 FactoryDescribeRegionPoint (boofcv.factory.feature.describe.FactoryDescribeRegionPoint)2 FactoryPointTracker (boofcv.factory.feature.tracker.FactoryPointTracker)2 FactoryPointTrackerTwoPass (boofcv.factory.feature.tracker.FactoryPointTrackerTwoPass)2 DetectDescribeFusion (boofcv.abst.feature.detdesc.DetectDescribeFusion)1 DetectDescribeMulti (boofcv.abst.feature.detdesc.DetectDescribeMulti)1