Search in sources :

Example 21 with Point2D_I16

use of georegression.struct.point.Point2D_I16 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 22 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class VideoDetectCorners method updateGUI.

@Override
public void updateGUI(BufferedImage guiImage, T origImage) {
    Graphics2D g2 = guiImage.createGraphics();
    for (int i = 0; i < corners.size(); i++) {
        Point2D_I16 pt = corners.get(i);
        g2.setColor(Color.BLACK);
        g2.fillOval(pt.x - 4, pt.y - 4, 9, 9);
        g2.setColor(Color.RED);
        g2.fillOval(pt.x - 2, pt.y - 2, 5, 5);
    }
    if (panel == null) {
        panel = ShowImages.showWindow(guiImage, "Image Sequence");
        addComponent(panel);
    } else {
        panel.setImage(guiImage);
        panel.repaint();
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16)

Example 23 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class ExampleNonMaximumSupression method renderNonMax.

public static BufferedImage renderNonMax(GrayF32 intensity, int radius, float threshold) {
    // Create and configure the feature detector
    NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(new ConfigExtract(radius, threshold));
    // We will only searching for the maximums.  Other variants will look for minimums or will exclude previous
    // candidate detections from being detected twice
    QueueCorner maximums = new QueueCorner();
    nonmax.process(intensity, null, null, null, maximums);
    // Visualize the intensity image
    BufferedImage output = new BufferedImage(intensity.width, intensity.height, BufferedImage.TYPE_INT_RGB);
    VisualizeImageData.colorizeSign(intensity, output, -1);
    // render each maximum with a circle
    Graphics2D g2 = output.createGraphics();
    g2.setColor(Color.blue);
    for (int i = 0; i < maximums.size(); i++) {
        Point2D_I16 c = maximums.get(i);
        VisualizeFeatures.drawCircle(g2, c.x, c.y, radius);
    }
    return output;
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) FactoryIntensityPoint(boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)

Example 24 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class GenericNonMaxAlgorithmTests method checkSamePoints.

private void checkSamePoints(QueueCorner list0, QueueCorner list1) {
    for (int j = 0; j < list0.size(); j++) {
        Point2D_I16 b = list0.get(j);
        boolean foundMatch = false;
        for (int k = 0; k < list1.size(); k++) {
            Point2D_I16 a = list1.get(k);
            if (a.x == b.x && a.y == b.y) {
                foundMatch = true;
                break;
            }
        }
        assertTrue(foundMatch);
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16)

Example 25 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class GeneralTemplateMatchTests method checkExpected.

private void checkExpected(Point2D_I32... points) {
    // I'm being lazy, update this in the future
    assertFalse(alg.isBorderProcessed());
    // only process the regions which are not considered the border
    int x0 = alg.getBorderX0();
    int y0 = alg.getBorderY0();
    // solutions should be local maximums
    NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(2, -Float.MAX_VALUE, 0, true));
    QueueCorner found = new QueueCorner(10);
    extractor.process(alg.getIntensity(), null, null, null, found);
    assertTrue(found.size >= points.length);
    // search for all the expected matches
    for (Point2D_I32 expected : points) {
        int numMatches = 0;
        for (Point2D_I16 f : found.toList()) {
            double d = UtilPoint2D_F64.distance(f.x - x0, f.y - y0, expected.x, expected.y);
            if (d <= 1)
                numMatches++;
        }
        assertEquals(1, numMatches);
    }
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) NonMaxSuppression(boofcv.abst.feature.detect.extract.NonMaxSuppression) Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) Point2D_I32(georegression.struct.point.Point2D_I32)

Aggregations

Point2D_I16 (georegression.struct.point.Point2D_I16)27 QueueCorner (boofcv.struct.QueueCorner)12 GrayF32 (boofcv.struct.image.GrayF32)7 ScalePoint (boofcv.struct.feature.ScalePoint)5 ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)3 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)3 Test (org.junit.Test)3 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 FactoryIntensityPoint (boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)2 FactoryDetectPoint (boofcv.factory.feature.detect.interest.FactoryDetectPoint)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 BufferedImage (java.awt.image.BufferedImage)2 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)1 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 DetectorFastNaive (boofcv.alg.feature.detect.intensity.DetectorFastNaive)1 EasyGeneralFeatureDetector (boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)1 GeneralFeatureDetector (boofcv.alg.feature.detect.interest.GeneralFeatureDetector)1 OrientationImageAverage (boofcv.alg.feature.orientation.OrientationImageAverage)1