Search in sources :

Example 1 with FancyInterestPointRender

use of boofcv.gui.feature.FancyInterestPointRender in project narchy by automenta.

the class RasterHierarchy method displayResults.

private static <T extends ImageSingleBand> void displayResults(BufferedImage image, InterestPointDetector<T> detector, Color c) {
    Graphics2D g2 = image.createGraphics();
    FancyInterestPointRender render = new FancyInterestPointRender();
    g2.setStroke(new BasicStroke(3));
    g2.setColor(c);
    for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
        Point2D_F64 pt = detector.getLocation(i);
        // note how it checks the capabilities of the detector
        if (detector.hasScale()) {
            double scale = detector.getScale(i);
            int radius = (int) (scale * BoofDefaults.SCALE_SPACE_CANONICAL_RADIUS);
            render.addCircle((int) pt.x, (int) pt.y, radius, c);
        } else {
            render.addPoint((int) pt.x, (int) pt.y, 1, c);
        }
    }
    // make the circle's thicker
    // just draw the features onto the input image
    render.draw(g2);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) FancyInterestPointRender(boofcv.gui.feature.FancyInterestPointRender) FactoryInterestPoint(boofcv.factory.feature.detect.interest.FactoryInterestPoint)

Example 2 with FancyInterestPointRender

use of boofcv.gui.feature.FancyInterestPointRender in project BoofCV by lessthanoptimal.

the class ShowFeatureOrientationApp method setActiveAlgorithm.

@Override
public synchronized void setActiveAlgorithm(int indexFamily, String name, Object cookie) {
    if (input == null)
        return;
    RegionOrientation orientation = (RegionOrientation) cookie;
    orientation.setObjectRadius(10);
    T workImage = ConvertBufferedImage.convertFromSingle(input, null, imageType);
    AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
    deriv.setInput(workImage);
    int r = 2;
    GeneralFeatureDetector<T, D> detector = FactoryDetectPoint.createHarris(new ConfigGeneralDetector(NUM_FEATURES, r, 1), false, derivType);
    D derivX = null, derivY = null, derivXX = null, derivYY = null, derivXY = null;
    if (detector.getRequiresGradient()) {
        derivX = deriv.getDerivative(true);
        derivY = deriv.getDerivative(false);
    } else if (detector.getRequiresHessian()) {
        derivXX = deriv.getDerivative(true, true);
        derivYY = deriv.getDerivative(false, false);
        derivXY = deriv.getDerivative(true, false);
    }
    detector.process(workImage, derivX, derivY, derivXX, derivYY, derivXY);
    QueueCorner points = detector.getMaximums();
    FancyInterestPointRender render = new FancyInterestPointRender();
    if (orientation instanceof OrientationGradient) {
        ((OrientationGradient<D>) orientation).setImage(deriv.getDerivative(true), deriv.getDerivative(false));
    } else if (orientation instanceof OrientationIntegral) {
        T ii = GIntegralImageOps.transform(workImage, null);
        ((OrientationIntegral<T>) orientation).setImage(ii);
    } else if (orientation instanceof OrientationImageAverage) {
        ((OrientationImageAverage) orientation).setImage(workImage);
    } else {
        throw new IllegalArgumentException("Unknown algorithm type.");
    }
    for (int i = 0; i < points.size; i++) {
        Point2D_I16 p = points.get(i);
        double angle = orientation.compute(p.x, p.y);
        render.addCircle(p.x, p.y, radius, Color.RED, angle);
    }
    BufferedImage temp = new BufferedImage(input.getWidth(), input.getHeight(), input.getType());
    Graphics2D g2 = (Graphics2D) temp.getGraphics();
    g2.drawImage(input, 0, 0, null);
    g2.setStroke(new BasicStroke(2.5f));
    render.draw(g2);
    panel.setImage(temp);
    panel.repaint();
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) FancyInterestPointRender(boofcv.gui.feature.FancyInterestPointRender) ConfigGeneralDetector(boofcv.abst.feature.detect.interest.ConfigGeneralDetector) OrientationImageAverage(boofcv.alg.feature.orientation.OrientationImageAverage) FactoryDetectPoint(boofcv.factory.feature.detect.interest.FactoryDetectPoint) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) QueueCorner(boofcv.struct.QueueCorner)

Example 3 with FancyInterestPointRender

use of boofcv.gui.feature.FancyInterestPointRender in project BoofCV by lessthanoptimal.

the class ExampleInterestPoint method displayResults.

private static <T extends ImageGray<T>> void displayResults(BufferedImage image, InterestPointDetector<T> detector) {
    Graphics2D g2 = image.createGraphics();
    FancyInterestPointRender render = new FancyInterestPointRender();
    for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
        Point2D_F64 pt = detector.getLocation(i);
        // note how it checks the capabilities of the detector
        if (detector.hasScale()) {
            int radius = (int) (detector.getRadius(i));
            render.addCircle((int) pt.x, (int) pt.y, radius);
        } else {
            render.addPoint((int) pt.x, (int) pt.y);
        }
    }
    // make the circle's thicker
    g2.setStroke(new BasicStroke(3));
    // just draw the features onto the input image
    render.draw(g2);
    ShowImages.showWindow(image, "Detected Features", true);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) FancyInterestPointRender(boofcv.gui.feature.FancyInterestPointRender) FactoryInterestPoint(boofcv.factory.feature.detect.interest.FactoryInterestPoint)

Aggregations

FancyInterestPointRender (boofcv.gui.feature.FancyInterestPointRender)3 FactoryInterestPoint (boofcv.factory.feature.detect.interest.FactoryInterestPoint)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 OrientationImageAverage (boofcv.alg.feature.orientation.OrientationImageAverage)1 FactoryDetectPoint (boofcv.factory.feature.detect.interest.FactoryDetectPoint)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 QueueCorner (boofcv.struct.QueueCorner)1 Point2D_I16 (georegression.struct.point.Point2D_I16)1 BufferedImage (java.awt.image.BufferedImage)1