Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand All @@ -23,6 +23,7 @@
import boofcv.abst.feature.detect.extract.NonMaxSuppression;
import boofcv.abst.feature.detect.intensity.GeneralFeatureIntensity;
import boofcv.abst.feature.detect.intensity.WrapperGradientCornerIntensity;
import boofcv.abst.filter.derivative.ImageGradient;
import boofcv.alg.feature.detect.interest.GeneralFeatureDetector;
import boofcv.alg.feature.detect.selector.FeatureSelectLimitIntensity;
import boofcv.alg.feature.detect.selector.FeatureSelectNBest;
Expand All @@ -32,6 +33,7 @@
import boofcv.core.image.GeneralizedImageOps;
import boofcv.factory.feature.detect.extract.FactoryFeatureExtractor;
import boofcv.factory.feature.detect.intensity.FactoryIntensityPointAlg;
import boofcv.factory.filter.derivative.FactoryDerivative;
import boofcv.gui.image.ImagePanel;
import boofcv.gui.image.ProcessImageSequence;
import boofcv.gui.image.ShowImages;
Expand Down Expand Up @@ -62,19 +64,22 @@ public class VideoDetectCorners<T extends ImageGray<T>, D extends ImageGray<D>>
D derivYY;
D derivXY;

ImageGradient<T, D> gradient;
Class<D> derivType;

QueueCorner corners;

ImagePanel panel;

public VideoDetectCorners( SimpleImageSequence<T> sequence,
GeneralFeatureDetector<T, D> detector,
Class<D> derivType ) {
GeneralFeatureDetector<T, D> detector,
ImageGradient<T, D> gradient,
Class<D> derivType ) {
super(sequence);

this.derivType = derivType;
this.detector = detector;
this.gradient = gradient;
}

@Override
Expand All @@ -86,8 +91,7 @@ public void processFrame( T image ) {
derivY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height);
}

// compute the image gradient
GImageDerivativeOps.gradient(DerivativeType.SOBEL, image, derivX, derivY, BoofDefaults.DERIV_BORDER_TYPE);
gradient.process(image, derivX, derivY);
}

if (detector.getRequiresHessian()) {
Expand Down Expand Up @@ -135,12 +139,16 @@ void perform( String fileName, Class<T> imageType, Class<D> derivType ) {
int maxCorners = 200;
int radius = 2;

ImageGradient<T, D> gradient = FactoryDerivative.sobel(imageType, derivType);

GeneralFeatureIntensity<T, D> intensity = new WrapperGradientCornerIntensity<>(FactoryIntensityPointAlg.shiTomasi(radius, false, derivType));
// GeneralFeatureIntensity<T, D> intensity =
// new WrapperFastCornerIntensity<T, D>(FactoryIntensityPointAlg.createFast12(defaultType, 8 , 12));

float intensityScale = intensity.thresholdScaleByDerivative(gradient.divisor());

ConfigExtract config = new ConfigExtract();
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(config);
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(config, intensityScale);
// FeatureExtractor extractor = new WrapperNonMaximumBlock( new NonMaxExtractorNaive(radius+10,10f));
// FeatureExtractor extractor = new WrapperNonMaxCandidate(new NonMaxCandidateStrict(radius+10, 10f));
extractor.setIgnoreBorder(radius + 10);
Expand All @@ -151,7 +159,7 @@ void perform( String fileName, Class<T> imageType, Class<D> derivType ) {
var detector = new GeneralFeatureDetector<>(intensity, null, extractor, selector);
detector.setFeatureLimit(maxCorners);

VideoDetectCorners<T, D> display = new VideoDetectCorners<>(sequence, detector, derivType);
VideoDetectCorners<T, D> display = new VideoDetectCorners<>(sequence, detector, gradient, derivType);

display.process();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -172,12 +172,12 @@ private synchronized void doProcess() {
if (intensityAlg.localMinimums()) {
configExtract.detectMinimums = true;
configExtract.detectMaximums = false;
extractorMin = FactoryFeatureExtractor.nonmax(configExtract);
extractorMin = FactoryFeatureExtractor.nonmax(configExtract, 1);
}
if (intensityAlg.localMaximums()) {
configExtract.detectMinimums = false;
configExtract.detectMaximums = true;
extractorMax = FactoryFeatureExtractor.nonmax(configExtract);
extractorMax = FactoryFeatureExtractor.nonmax(configExtract, 1);
}

GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensityAlg,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -266,18 +266,18 @@ private void handleAlgorithmChanged() {

case "Harris":
detector = FactoryDetectPoint.createHarris(config,
new ConfigHarrisCorner(controlPanel.weighted, controlPanel.radiusCorner), derivType);
new ConfigHarrisCorner(controlPanel.weighted, controlPanel.radiusCorner), derivType, deriv.getEdgeDivisor());
break;
case "Shi Tomasi":
detector = FactoryDetectPoint.createShiTomasi(config,
new ConfigShiTomasi(controlPanel.weighted, controlPanel.radiusCorner), derivType);
new ConfigShiTomasi(controlPanel.weighted, controlPanel.radiusCorner), derivType, deriv.getEdgeDivisor());
break;
case "FAST":
config.detectMinimums = true;
detector = FactoryDetectPoint.createFast(config, null, imageType);
break;
case "KitRos":
detector = FactoryDetectPoint.createKitRos(config, derivType);
detector = FactoryDetectPoint.createKitRos(config, derivType, deriv.getEdgeDivisor());
break;
case "Median":
detector = FactoryDetectPoint.createMedian(config, imageType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand All @@ -19,12 +19,15 @@
package boofcv.demonstrations.feature.detect.interest;

import boofcv.abst.feature.detect.interest.*;
import boofcv.abst.filter.derivative.ImageGradient;
import boofcv.alg.feature.detect.intensity.HessianBlobIntensity;
import boofcv.alg.feature.detect.interest.GeneralFeatureDetector;
import boofcv.alg.filter.derivative.DerivativeType;
import boofcv.alg.filter.derivative.GImageDerivativeOps;
import boofcv.demonstrations.shapes.ShapeVisualizePanel;
import boofcv.factory.feature.detect.interest.FactoryDetectPoint;
import boofcv.factory.feature.detect.interest.FactoryInterestPoint;
import boofcv.factory.filter.derivative.FactoryDerivative;
import boofcv.gui.BoofSwingUtil;
import boofcv.gui.DemonstrationBase;
import boofcv.gui.StandardAlgConfigPanel;
Expand Down Expand Up @@ -67,6 +70,8 @@ public class DemoDetectPointFeaturesApp<T extends ImageGray<T>> extends Demonstr
VisualizePanel imagePanel = new VisualizePanel();
ControlPanel controls = new ControlPanel();

ImageGradient<T, ?> gradient;

InterestPointDetector<T> detector;
boolean detectorChanged = true;

Expand All @@ -83,6 +88,8 @@ public DemoDetectPointFeaturesApp( List<?> exampleInputs, Class<T> imageClass )
this.imageClass = imageClass;
this.derivClass = GImageDerivativeOps.getDerivativeType(imageClass);

gradient = FactoryDerivative.gradientSB(DerivativeType.SOBEL, imageClass, derivClass);

imagePanel.setPreferredSize(new Dimension(800, 800));

add(BorderLayout.WEST, controls);
Expand Down Expand Up @@ -297,14 +304,14 @@ private void createHarris() {
controls.configExtract.detectMinimums = false;
controls.adjustControls(true, false);
changeDetector(FactoryDetectPoint.createHarris(controls.configExtract,
new ConfigHarrisCorner(controls.weighted, controls.configExtract.radius), derivClass));
new ConfigHarrisCorner(controls.weighted, controls.configExtract.radius), derivClass, gradient.divisor()));
}

private void createShiTomasi() {
controls.configExtract.detectMinimums = false;
controls.adjustControls(true, false);
changeDetector(FactoryDetectPoint.createShiTomasi(controls.configExtract,
new ConfigShiTomasi(controls.weighted, controls.configExtract.radius), derivClass));
new ConfigShiTomasi(controls.weighted, controls.configExtract.radius), derivClass, gradient.divisor()));
}

private void createFastIntensity() {
Expand All @@ -326,7 +333,7 @@ private void createFast() {
private void createKitRos() {
controls.configExtract.detectMinimums = false;
controls.adjustControls(false, false);
changeDetector(FactoryDetectPoint.createKitRos(controls.configExtract, derivClass));
changeDetector(FactoryDetectPoint.createKitRos(controls.configExtract, derivClass, 1));
}

private void createMedian() {
Expand All @@ -350,7 +357,7 @@ private void createLaplace() {
}

private void changeDetector( GeneralFeatureDetector fd ) {
detector = new GeneralToInterestPoint(fd, -1, imageClass, derivClass);
detector = new GeneralToInterestPoint(fd, gradient, -1, imageClass, derivClass);
}

public static void main( String[] args ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand All @@ -22,11 +22,14 @@
import boofcv.abst.feature.detect.interest.ConfigGeneralDetector;
import boofcv.abst.feature.detect.interest.ConfigHarrisCorner;
import boofcv.abst.feature.detect.interest.ConfigShiTomasi;
import boofcv.abst.filter.derivative.ImageGradient;
import boofcv.alg.feature.detect.intensity.HessianBlobIntensity;
import boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector;
import boofcv.alg.feature.detect.interest.GeneralFeatureDetector;
import boofcv.alg.filter.derivative.DerivativeType;
import boofcv.demonstrations.feature.detect.ImageCorruptPanel;
import boofcv.factory.feature.detect.interest.FactoryDetectPoint;
import boofcv.factory.filter.derivative.FactoryDerivative;
import boofcv.gui.SelectAlgorithmAndInputPanel;
import boofcv.gui.feature.FancyInterestPointRender;
import boofcv.gui.image.ImagePanel;
Expand Down Expand Up @@ -81,30 +84,31 @@ public DetectPointsWithNoiseApp( Class<T> imageType, Class<D> derivType ) {
GeneralFeatureDetector<T, D> alg;
ConfigGeneralDetector configExtract = new ConfigGeneralDetector(maxFeatures, radius, thresh);

ImageGradient<T, D> gradient = FactoryDerivative.gradientSB(DerivativeType.SOBEL, imageType, derivType);

alg = FactoryDetectPoint.createHarris(configExtract, null, derivType);
addAlgorithm(0, "Harris", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
alg = FactoryDetectPoint.createHarris(configExtract, new ConfigHarrisCorner(true, radius), derivType);
addAlgorithm(0, "Harris Weighted", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
alg = FactoryDetectPoint.createShiTomasi(configExtract, null, derivType);
addAlgorithm(0, "Shi-Tomasi", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
alg = FactoryDetectPoint.createShiTomasi(configExtract, new ConfigShiTomasi(true, radius), derivType);
addAlgorithm(0, "Shi-Tomasi Weighted", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
alg = FactoryDetectPoint.createHarris(configExtract, null, derivType, gradient.divisor());
addAlgorithm(0, "Harris", new EasyGeneralFeatureDetector<>(alg, gradient, imageType, derivType));
alg = FactoryDetectPoint.createHarris(configExtract, new ConfigHarrisCorner(true, radius), derivType, gradient.divisor());
addAlgorithm(0, "Harris Weighted", new EasyGeneralFeatureDetector<>(alg, gradient, imageType, derivType));
alg = FactoryDetectPoint.createShiTomasi(configExtract, null, derivType, gradient.divisor());
addAlgorithm(0, "Shi-Tomasi", new EasyGeneralFeatureDetector<>(alg, gradient, imageType, derivType));
alg = FactoryDetectPoint.createShiTomasi(configExtract, new ConfigShiTomasi(true, radius), derivType, gradient.divisor());
addAlgorithm(0, "Shi-Tomasi Weighted", new EasyGeneralFeatureDetector<>(alg, gradient, imageType, derivType));
configExtract.detectMinimums = true;
configExtract.threshold = 10;
alg = FactoryDetectPoint.createFast(configExtract, new ConfigFastCorner(10, 9), imageType);
configExtract.detectMinimums = false;
configExtract.threshold = thresh;
addAlgorithm(0, "Fast", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
alg = FactoryDetectPoint.createKitRos(configExtract, derivType);
addAlgorithm(0, "KitRos", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
addAlgorithm(0, "Fast", new EasyGeneralFeatureDetector<>(alg, gradient, imageType, derivType));
alg = FactoryDetectPoint.createKitRos(configExtract, derivType, gradient.divisor());
addAlgorithm(0, "KitRos", new EasyGeneralFeatureDetector<>(alg, null, imageType, derivType));
alg = FactoryDetectPoint.createMedian(configExtract, imageType);
addAlgorithm(0, "Median", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
addAlgorithm(0, "Median", new EasyGeneralFeatureDetector<>(alg, null, imageType, derivType));
alg = FactoryDetectPoint.createHessianDeriv(configExtract, HessianBlobIntensity.Type.DETERMINANT, derivType);
addAlgorithm(0, "Hessian", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
addAlgorithm(0, "Hessian", new EasyGeneralFeatureDetector<>(alg, null, imageType, derivType));
configExtract.detectMinimums = true;
alg = FactoryDetectPoint.createHessianDeriv(configExtract, HessianBlobIntensity.Type.TRACE, derivType);
addAlgorithm(0, "Laplace", new EasyGeneralFeatureDetector<>(alg, imageType, derivType));
addAlgorithm(0, "Laplace", new EasyGeneralFeatureDetector<>(alg, null, imageType, derivType));

JPanel viewArea = new JPanel(new BorderLayout());
corruptPanel = new ImageCorruptPanel();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -126,7 +126,7 @@ public synchronized void setActiveAlgorithm( int indexFamily, String name, Objec

int r = 2;
GeneralFeatureDetector<T, D> detector = FactoryDetectPoint.
createHarris(new ConfigGeneralDetector(NUM_FEATURES, r, 1), null, derivType);
createHarris(new ConfigGeneralDetector(NUM_FEATURES, r, 1), null, derivType, 1);

D derivX = null, derivY = null, derivXX = null, derivYY = null, derivXY = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand All @@ -23,6 +23,7 @@
import boofcv.abst.sfm.AccessPointTracks3D;
import boofcv.abst.sfm.d3.MonocularPlaneVisualOdometry;
import boofcv.abst.tracker.PointTracker;
import boofcv.alg.filter.derivative.DerivativeType;
import boofcv.alg.filter.derivative.GImageDerivativeOps;
import boofcv.alg.tracker.klt.ConfigPKlt;
import boofcv.factory.sfm.ConfigPlanarTrackPnP;
Expand Down Expand Up @@ -314,16 +315,16 @@ private MonocularPlaneVisualOdometry<I> createVisualOdometry( int whichAlg ) {

return FactoryVisualOdometry.monoPlaneInfinity(config, imageClass);
} else if (whichAlg == 1) {
ConfigPKlt configKlt = new ConfigPKlt();
var configKlt = new ConfigPKlt();
configKlt.pyramidLevels = ConfigDiscreteLevels.levels(4);
configKlt.templateRadius = 3;
ConfigPointDetector configDetector = new ConfigPointDetector();
var configDetector = new ConfigPointDetector();
configDetector.type = PointDetectorTypes.SHI_TOMASI;
configDetector.general.maxFeatures = 600;
configDetector.general.radius = 3;
configDetector.general.threshold = 1;

PointTracker<I> tracker = FactoryPointTracker.klt(configKlt, configDetector, imageClass, derivType);
PointTracker<I> tracker = FactoryPointTracker.klt(configKlt, DerivativeType.SOBEL, configDetector, imageClass, derivType);

double cellSize = 0.06;
double inlierGroundTol = 1.5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -54,10 +54,12 @@ public static void main( String[] args ) {
configCorner.radius = configNonMax.radius; // in general you should use the same radius here
configCorner.weighted = true; // weighted corners will appear at the corners on a chessboard

// set weighted to false and see what happens to the feature's locations. unweighted is much faster
GeneralFeatureDetector<GrayU8, GrayS16> detector = FactoryDetectPoint.createShiTomasi(configNonMax, configCorner, GrayS16.class);
ImageGradient<GrayU8, GrayS16> sobel = FactoryDerivative.sobel(GrayU8.class, GrayS16.class);

// set weighted to false and see what happens to the feature's locations. unweighted is much faster
GeneralFeatureDetector<GrayU8, GrayS16> detector = FactoryDetectPoint.createShiTomasi(
configNonMax, configCorner, GrayS16.class, sobel.divisor());

BufferedImage image = UtilImageIO.loadImageNotNull(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Chess/frame05.jpg"));

// Convert the image into a usable format and predeclare memory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -78,7 +78,7 @@ DetectDescribePoint<T, TD> createFromPremade( Class<T> imageType ) {
DetectDescribePoint<T, TD> createFromComponents( Class<T> imageType ) {
// create a corner detector
Class derivType = GImageDerivativeOps.getDerivativeType(imageType);
GeneralFeatureDetector corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(1000, 5, 1), null, derivType);
GeneralFeatureDetector corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(1000, 5, 1), null, derivType, 1);
InterestPointDetector detector = FactoryInterestPoint.wrapPoint(corner, 1, imageType, derivType);

// describe points using BRIEF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Abeles. All Rights Reserved.
* Copyright (c) 2026, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -61,7 +61,7 @@ public class ExampleFeatureLimit {
public static BufferedImage renderLimit( GrayF32 intensity, SelectLimitTypes type ) {
// Configure how it will select features inside the intensity image
var limit = new ConfigSelectLimit(type, 0xBEEF);
NonMaxLimiter nonmax = FactoryFeatureExtractor.nonmaxLimiter(new ConfigExtract(NON_MAX_RADIUS, 0), limit, MAX_FEATURES);
NonMaxLimiter nonmax = FactoryFeatureExtractor.nonmaxLimiter(new ConfigExtract(NON_MAX_RADIUS, 0), 1f,limit, MAX_FEATURES);

// Detect the features
nonmax.process(intensity);
Expand Down
Loading