Search in sources :

Example 1 with SiftPoint

use of boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint in project BoofCV by lessthanoptimal.

the class CompleteSift method describeDetections.

/**
 * Computes one or more descriptors for every point in the passed in list
 */
protected void describeDetections(List<SiftPoint> detections) {
    for (int detIdx = 0; detIdx < detections.size(); detIdx++) {
        SiftPoint p = detections.get(detIdx);
        // Would it be faster if all features that come from the same images were processed at once?
        // Would it reduce context switching?
        // Gradient image is offset by one
        GrayF32 derivX = gradient.getDerivX(p.octaveIdx, (byte) (p.scaleIdx - 1));
        GrayF32 derivY = gradient.getDerivY(p.octaveIdx, (byte) (p.scaleIdx - 1));
        orientation.setImageGradient(derivX, derivY);
        describe.setImageGradient(derivX, derivY);
        double pixelScaleToInput = scaleSpace.pixelScaleCurrentToInput(p.octaveIdx);
        // adjust the image for the down sampling in each octave
        double localX = p.pixel.x / pixelScaleToInput;
        double localY = p.pixel.y / pixelScaleToInput;
        double localSigma = p.scale / pixelScaleToInput;
        // find potential orientations first
        orientation.process(localX, localY, localSigma);
        // describe each feature
        DogArray_F64 angles = orientation.getOrientations();
        for (int angleIdx = 0; angleIdx < angles.size; angleIdx++) {
            describe.process(localX, localY, localSigma, angles.get(angleIdx), features.grow());
            orientations.add(angles.get(angleIdx));
            locations.add(p);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) SiftPoint(boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint) SiftPoint(boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint) ScalePoint(boofcv.struct.feature.ScalePoint) DogArray_F64(org.ddogleg.struct.DogArray_F64)

Example 2 with SiftPoint

use of boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint in project BoofCV by lessthanoptimal.

the class TestSiftDetector method process.

/**
 * Tests the ability to detect a single square feature at multiple scales and color
 */
@Test
void process() {
    int c_x = 40, c_y = 42;
    SiftDetector alg = createDetector();
    for (int radius : new int[] { 2, 5 }) {
        int width = radius * 2 + 1;
        for (boolean white : new boolean[] { true, false }) {
            GrayF32 input = new GrayF32(80, 70);
            if (white) {
                GImageMiscOps.fillRectangle(input, 200, c_x - radius, c_y - radius, width, width);
            } else {
                GImageMiscOps.fill(input, 200);
                GImageMiscOps.fillRectangle(input, 0, c_x - radius, c_y - radius, width, width);
            }
            ss.process(input);
            alg.process(ss);
            List<SiftPoint> detections = alg.getDetections();
            assertTrue(detections.size() > 0);
            boolean found = false;
            for (int i = 0; i < detections.size(); i++) {
                ScalePoint p = detections.get(i);
                if (p.pixel.distance(c_x, c_y) <= 0.2) {
                    assertEquals(radius * 1.25, p.scale, 0.5);
                    assertEquals(p.white, white);
                    found = true;
                }
            }
            assertTrue(found);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) SiftPoint(boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint) ScalePoint(boofcv.struct.feature.ScalePoint) SiftPoint(boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint) ScalePoint(boofcv.struct.feature.ScalePoint) Test(org.junit.jupiter.api.Test)

Aggregations

SiftPoint (boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint)2 ScalePoint (boofcv.struct.feature.ScalePoint)2 GrayF32 (boofcv.struct.image.GrayF32)2 DogArray_F64 (org.ddogleg.struct.DogArray_F64)1 Test (org.junit.jupiter.api.Test)1