Search in sources :

Example 1 with ConfigShiTomasi

use of boofcv.abst.feature.detect.interest.ConfigShiTomasi in project BoofCV by lessthanoptimal.

the class ExampleCornerFeature method main.

public static void main(String[] args) {
    ConfigGeneralDetector configNonMax = new ConfigGeneralDetector();
    // a large radius is used to exaggerate weighted/unweighted affects. Try 1 or 2 for a typical value
    configNonMax.radius = 10;
    configNonMax.threshold = 100;
    configNonMax.maxFeatures = 100;
    ConfigShiTomasi configCorner = new ConfigShiTomasi();
    // in general you should use the same radius here
    configCorner.radius = configNonMax.radius;
    // weighted corners will appear at the corners on a chessboard
    configCorner.weighted = true;
    // 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);
    BufferedImage image = UtilImageIO.loadImageNotNull(UtilIO.pathExample("calibration/mono/Sony_DSC-HX5V_Chess/frame05.jpg"));
    // Convert the image into a usable format and predeclare memory
    GrayU8 gray = ConvertBufferedImage.convertFrom(image, (GrayU8) null);
    GrayS16 derivX = new GrayS16(gray.width, gray.height);
    GrayS16 derivY = new GrayS16(gray.width, gray.height);
    // The first image derivatives are needed
    sobel.process(gray, derivX, derivY);
    // Compute the corners
    detector.process(gray, derivX, derivY, null, null, null);
    // Visualize the results
    QueueCorner corners = detector.getMaximums();
    Graphics2D g2 = image.createGraphics();
    for (int i = 0; i < corners.size; i++) {
        Point2D_I16 c = corners.get(i);
        VisualizeFeatures.drawPoint(g2, c.x, c.y, 4, Color.RED, true);
    }
    ShowImages.showWindow(image, "Corners", true);
}
Also used : ConfigShiTomasi(boofcv.abst.feature.detect.interest.ConfigShiTomasi) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) GrayS16(boofcv.struct.image.GrayS16) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) GrayU8(boofcv.struct.image.GrayU8) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) FactoryDetectPoint(boofcv.factory.feature.detect.interest.FactoryDetectPoint)

Example 2 with ConfigShiTomasi

use of boofcv.abst.feature.detect.interest.ConfigShiTomasi in project BoofCV by lessthanoptimal.

the class IntensityPointFeatureApp method handleAlgorithmChanged.

private void handleAlgorithmChanged() {
    ConfigGeneralDetector config = new ConfigGeneralDetector();
    config.radius = controlPanel.radiusNonMax;
    config.maxFeatures = controlPanel.maxFeatures;
    synchronized (lockAlgorithm) {
        switch(controlPanel.selected) {
            case "Laplacian":
                config.detectMinimums = true;
                detector = FactoryDetectPoint.createHessianDeriv(config, HessianBlobIntensity.Type.TRACE, derivType);
                break;
            case "Hessian Det":
                config.detectMinimums = true;
                detector = FactoryDetectPoint.createHessianDeriv(config, HessianBlobIntensity.Type.DETERMINANT, derivType);
                break;
            case "Harris":
                detector = FactoryDetectPoint.createHarris(config, new ConfigHarrisCorner(controlPanel.weighted, controlPanel.radiusCorner), derivType);
                break;
            case "Shi Tomasi":
                detector = FactoryDetectPoint.createShiTomasi(config, new ConfigShiTomasi(controlPanel.weighted, controlPanel.radiusCorner), derivType);
                break;
            case "FAST":
                config.detectMinimums = true;
                detector = FactoryDetectPoint.createFast(config, null, imageType);
                break;
            case "KitRos":
                detector = FactoryDetectPoint.createKitRos(config, derivType);
                break;
            case "Median":
                detector = FactoryDetectPoint.createMedian(config, imageType);
                break;
            default:
                throw new RuntimeException("Unknown exception");
        }
    }
    if (controlPanel.blurSigma > 0) {
        blurFilter = FactoryBlurFilter.gaussian(imageType, controlPanel.blurSigma, -1);
    } else {
        blurFilter = null;
    }
    reprocessImageOnly();
}
Also used : ConfigHarrisCorner(boofcv.abst.feature.detect.interest.ConfigHarrisCorner) ConfigShiTomasi(boofcv.abst.feature.detect.interest.ConfigShiTomasi) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector)

Aggregations

ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)2 ConfigShiTomasi (boofcv.abst.feature.detect.interest.ConfigShiTomasi)2 ConfigHarrisCorner (boofcv.abst.feature.detect.interest.ConfigHarrisCorner)1 FactoryDetectPoint (boofcv.factory.feature.detect.interest.FactoryDetectPoint)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 QueueCorner (boofcv.struct.QueueCorner)1 GrayS16 (boofcv.struct.image.GrayS16)1 GrayU8 (boofcv.struct.image.GrayU8)1 Point2D_I16 (georegression.struct.point.Point2D_I16)1 BufferedImage (java.awt.image.BufferedImage)1