Search in sources :

Example 81 with TupleDesc_F64

use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.

the class ExampleFeatureSurf method easy.

/**
 * Use generalized interfaces for working with SURF. This removes much of the drudgery, but also reduces flexibility
 * and slightly increases memory and computational requirements.
 *
 *  @param image Input image type. DOES NOT NEED TO BE GrayF32, GrayU8 works too
 */
public static void easy(GrayF32 image) {
    // create the detector and descriptors
    ConfigFastHessian configDetector = new ConfigFastHessian();
    configDetector.extract = new ConfigExtract(2, 0, 5, true);
    configDetector.maxFeaturesPerScale = 200;
    configDetector.initialSampleStep = 2;
    DetectDescribePoint<GrayF32, TupleDesc_F64> surf = FactoryDetectDescribe.surfStable(configDetector, null, null, GrayF32.class);
    // specify the image to process
    surf.detect(image);
    System.out.println("Found Features: " + surf.getNumberOfFeatures());
    System.out.println("First descriptor's first value: " + surf.getDescription(0).data[0]);
}
Also used : ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64)

Example 82 with TupleDesc_F64

use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.

the class ExampleFeatureSurf method harder.

/**
 * Configured exactly the same as the easy example above, but require a lot more code and a more in depth
 * understanding of how SURF works and is configured. Each sub-problem which composes "SURF" is now explicitly
 * created and configured independently. This allows an advance user to tune it for a specific problem.
 *
 * @param image Input image type. DOES NOT NEED TO BE GrayF32, GrayU8 works too
 */
public static <II extends ImageGray<II>> void harder(GrayF32 image) {
    // SURF works off of integral images
    Class<II> integralType = GIntegralImageOps.getIntegralType(GrayF32.class);
    // define the feature detection algorithm
    ConfigFastHessian config = new ConfigFastHessian();
    config.extract = new ConfigExtract(2, 0, 5, true);
    config.maxFeaturesPerScale = 200;
    config.initialSampleStep = 2;
    FastHessianFeatureDetector<II> detector = FactoryInterestPointAlgs.fastHessian(config);
    // estimate orientation
    OrientationIntegral<II> orientation = FactoryOrientationAlgs.sliding_ii(null, integralType);
    DescribePointSurf<II> descriptor = FactoryDescribeAlgs.surfStability(null, integralType);
    // compute the integral image of 'image'
    II integral = GeneralizedImageOps.createSingleBand(integralType, image.width, image.height);
    GIntegralImageOps.transform(image, integral);
    // detect fast hessian features
    detector.detect(integral);
    // tell algorithms which image to process
    orientation.setImage(integral);
    descriptor.setImage(integral);
    List<ScalePoint> points = detector.getFoundFeatures();
    List<TupleDesc_F64> descriptions = new ArrayList<>();
    for (ScalePoint p : points) {
        // estimate orientation
        orientation.setObjectRadius(p.scale * BoofDefaults.SURF_SCALE_TO_RADIUS);
        double angle = orientation.compute(p.pixel.x, p.pixel.y);
        // extract the SURF description for this region
        TupleDesc_F64 desc = descriptor.createDescription();
        descriptor.describe(p.pixel.x, p.pixel.y, angle, p.scale, true, desc);
        // save everything for processing later on
        descriptions.add(desc);
    }
    System.out.println("Found Features: " + points.size());
    System.out.println("First descriptor's first value: " + descriptions.get(0).data[0]);
}
Also used : ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ScalePoint(boofcv.struct.feature.ScalePoint) ArrayList(java.util.ArrayList) ConfigExtract(boofcv.abst.feature.detect.extract.ConfigExtract)

Example 83 with TupleDesc_F64

use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.

the class TestConvertTupleDesc_F64_F32 method convert.

@Test
void convert() {
    var alg = new ConvertTupleDesc_F64_F32(5);
    var input = new TupleDesc_F64(5);
    input.data = new double[] { 2.5, 3, 20, -43.45, 2.123 };
    TupleDesc_F32 found = alg.createOutput();
    alg.convert(input, found);
    for (int i = 0; i < 5; i++) {
        assertEquals(input.data[i], found.data[i], UtilEjml.TEST_F32);
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) TupleDesc_F32(boofcv.struct.feature.TupleDesc_F32) Test(org.junit.jupiter.api.Test)

Example 84 with TupleDesc_F64

use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.

the class TestDescribeRegionPointConvert method basic.

@Test
public void basic() {
    DummyConvert convert = new DummyConvert();
    DummyDescribe original = new DummyDescribe();
    DescribePointRadiusAngleConvertTuple<GrayF32, TupleDesc_F64, TupleDesc_S8> alg = new DescribePointRadiusAngleConvertTuple<>(original, convert);
    TupleDesc_S8 found = alg.createDescription();
    assertEquals(found.data.length, 5);
    assertFalse(original.calledImageSet);
    alg.setImage(null);
    assertTrue(original.calledImageSet);
    alg.process(1, 2, 2, 2, found);
    assertEquals(5, found.data[0]);
    assertEquals(original.isOriented(), alg.isOriented());
    assertEquals(original.isScalable(), alg.isScalable());
    assertSame(alg.getDescriptionType(), TupleDesc_S8.class);
}
Also used : TupleDesc_S8(boofcv.struct.feature.TupleDesc_S8) GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DescribePointRadiusAngleConvertTuple(boofcv.abst.feature.describe.DescribePointRadiusAngleConvertTuple) Test(org.junit.jupiter.api.Test)

Example 85 with TupleDesc_F64

use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.

the class TestDescribeImageDenseSift method describe.

private TupleDesc_F64 describe(int x, int y, DescribeImageDense alg) {
    DescribeImageDenseSift sift = (DescribeImageDenseSift) alg;
    TupleDesc_F64 output = sift.createDescription();
    sift.alg.computeDescriptor(x, y, output);
    return output;
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64)

Aggregations

TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)127 Test (org.junit.jupiter.api.Test)74 GrayF32 (boofcv.struct.image.GrayF32)27 DogArray_I32 (org.ddogleg.struct.DogArray_I32)15 Test (org.junit.Test)14 GrayU8 (boofcv.struct.image.GrayU8)13 ArrayList (java.util.ArrayList)12 DogArray (org.ddogleg.struct.DogArray)10 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)7 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)7 ConfigAssociateGreedy (boofcv.factory.feature.associate.ConfigAssociateGreedy)7 TupleDesc_S8 (boofcv.struct.feature.TupleDesc_S8)7 File (java.io.File)7 AssociatedTripleIndex (boofcv.struct.feature.AssociatedTripleIndex)6 Point2D_F64 (georegression.struct.point.Point2D_F64)6 Point2D_I32 (georegression.struct.point.Point2D_I32)6 Planar (boofcv.struct.image.Planar)5 RecognitionNearestNeighborInvertedFile (boofcv.alg.scene.ann.RecognitionNearestNeighborInvertedFile)4 InvertedFile (boofcv.alg.scene.bow.InvertedFile)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4