use of boofcv.alg.feature.detect.interest.GeneralFeatureDetector in project BoofCV by lessthanoptimal.
the class CompareFeatureExtractorApp method doProcess.
private synchronized void doProcess() {
// System.out.println("radius "+radius+" min separation "+minSeparation+" thresholdFraction "+thresholdFraction+" numFeatures "+numFeatures);
deriv.setInput(grayImage);
D derivX = deriv.getDerivative(true);
D derivY = deriv.getDerivative(false);
D derivXX = deriv.getDerivative(true, true);
D derivYY = deriv.getDerivative(false, false);
D derivXY = deriv.getDerivative(true, false);
// todo modifying buffered images which might be actively being displayed, could mess up swing
intensityAlg.process(grayImage, derivX, derivY, derivXX, derivYY, derivXY);
GrayF32 intensity = intensityAlg.getIntensity();
intensityImage = VisualizeImageData.colorizeSign(intensityAlg.getIntensity(), null, ImageStatistics.maxAbs(intensity));
float max = ImageStatistics.maxAbs(intensity);
float threshold = max * thresholdFraction;
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(minSeparation, threshold, radius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensityAlg, extractor);
detector.setMaxFeatures(numFeatures);
detector.process(grayImage, derivX, derivY, derivXX, derivYY, derivXY);
QueueCorner foundCorners = detector.getMaximums();
render.reset();
for (int i = 0; i < foundCorners.size(); i++) {
Point2D_I16 p = foundCorners.get(i);
render.addPoint(p.x, p.y, 3, Color.RED);
}
Graphics2D g2 = workImage.createGraphics();
g2.drawImage(input, 0, 0, grayImage.width, grayImage.height, null);
render.draw(g2);
drawImage();
}
use of boofcv.alg.feature.detect.interest.GeneralFeatureDetector in project BoofCV by lessthanoptimal.
the class VisualizeStereoVisualOdometryApp method createStereoDepth.
private StereoVisualOdometry<I> createStereoDepth(int whichAlg) {
Class derivType = GImageDerivativeOps.getDerivativeType(imageType);
StereoDisparitySparse<I> disparity = FactoryStereoDisparity.regionSparseWta(2, 150, 3, 3, 30, -1, true, imageType);
PkltConfig kltConfig = new PkltConfig();
kltConfig.templateRadius = 3;
kltConfig.pyramidScaling = new int[] { 1, 2, 4, 8 };
if (whichAlg == 0) {
ConfigGeneralDetector configDetector = new ConfigGeneralDetector(600, 3, 1);
PointTrackerTwoPass<I> tracker = FactoryPointTrackerTwoPass.klt(kltConfig, configDetector, imageType, derivType);
return FactoryVisualOdometry.stereoDepth(1.5, 120, 2, 200, 50, false, disparity, tracker, imageType);
} else if (whichAlg == 1) {
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);
return FactoryVisualOdometry.stereoDepth(1.5, 80, 3, 200, 50, false, disparity, tracker, imageType);
} else if (whichAlg == 2) {
PointTracker<I> tracker = FactoryPointTracker.combined_ST_SURF_KLT(new ConfigGeneralDetector(600, 3, 0), kltConfig, 50, null, null, imageType, derivType);
PointTrackerTwoPass<I> twopass = new PointTrackerToTwoPass<>(tracker);
return FactoryVisualOdometry.stereoDepth(1.5, 80, 3, 200, 50, false, disparity, twopass, imageType);
} else if (whichAlg == 3) {
ConfigGeneralDetector configDetector = new ConfigGeneralDetector(600, 3, 1);
PointTracker<I> trackerLeft = FactoryPointTracker.klt(kltConfig, configDetector, imageType, derivType);
PointTracker<I> trackerRight = FactoryPointTracker.klt(kltConfig, configDetector, imageType, derivType);
DescribeRegionPoint describe = FactoryDescribeRegionPoint.surfFast(null, imageType);
return FactoryVisualOdometry.stereoDualTrackerPnP(90, 2, 1.5, 1.5, 200, 50, trackerLeft, trackerRight, describe, imageType);
} else if (whichAlg == 4) {
// GeneralFeatureIntensity intensity =
// FactoryIntensityPoint.hessian(HessianBlobIntensity.Type.TRACE,defaultType);
GeneralFeatureIntensity intensity = FactoryIntensityPoint.shiTomasi(1, false, imageType);
NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(2, 50, 0, true, false, true));
GeneralFeatureDetector general = new GeneralFeatureDetector(intensity, nonmax);
general.setMaxFeatures(600);
DetectorInterestPointMulti detector = new GeneralToInterestMulti(general, 2, imageType, derivType);
// DescribeRegionPoint describe = FactoryDescribeRegionPoint.brief(new ConfigBrief(true),defaultType);
// DescribeRegionPoint describe = FactoryDescribeRegionPoint.pixelNCC(5,5,defaultType);
DescribeRegionPoint describe = FactoryDescribeRegionPoint.surfFast(null, imageType);
DetectDescribeMulti detDescMulti = new DetectDescribeMultiFusion(detector, null, describe);
return FactoryVisualOdometry.stereoQuadPnP(1.5, 0.5, 75, Double.MAX_VALUE, 300, 50, detDescMulti, imageType);
} else {
throw new RuntimeException("Unknown selection");
}
}
use of boofcv.alg.feature.detect.interest.GeneralFeatureDetector in project BoofCV by lessthanoptimal.
the class FactoryDetectPoint method createGeneral.
public static <T extends ImageGray<T>, D extends ImageGray<D>> GeneralFeatureDetector<T, D> createGeneral(GeneralFeatureIntensity<T, D> intensity, ConfigGeneralDetector config) {
// create a copy since it's going to modify the detector config
ConfigGeneralDetector foo = new ConfigGeneralDetector();
foo.setTo(config);
config = foo;
config.ignoreBorder += config.radius;
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(config);
GeneralFeatureDetector<T, D> det = new GeneralFeatureDetector<>(intensity, extractor);
det.setMaxFeatures(config.maxFeatures);
return det;
}
use of boofcv.alg.feature.detect.interest.GeneralFeatureDetector in project BoofCV by lessthanoptimal.
the class TestWrapVisOdomQuadPnP method createAlgorithm.
@Override
public StereoVisualOdometry<GrayF32> createAlgorithm() {
GeneralFeatureIntensity intensity = FactoryIntensityPoint.shiTomasi(1, false, GrayF32.class);
NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(2, 1, 0, true, false, true));
GeneralFeatureDetector<GrayF32, GrayF32> general = new GeneralFeatureDetector<>(intensity, nonmax);
general.setMaxFeatures(600);
DetectorInterestPointMulti detector = new GeneralToInterestMulti(general, 2, GrayF32.class, GrayF32.class);
DescribeRegionPoint describe = FactoryDescribeRegionPoint.surfFast(null, GrayF32.class);
DetectDescribeMulti detDescMulti = new DetectDescribeMultiFusion(detector, null, describe);
return FactoryVisualOdometry.stereoQuadPnP(1.5, 0.5, 200, Double.MAX_VALUE, 300, 50, detDescMulti, GrayF32.class);
}
use of boofcv.alg.feature.detect.interest.GeneralFeatureDetector 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()));
}
Aggregations