Search in sources :

Example 1 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestAssociateNearestNeighbor method various.

/**
 * Several tests combined into one
 */
@Test
public void various() {
    Dummy<Integer> nn = new Dummy<>();
    // src = assoc[i] where src is the index of the source feature and i is the index of the dst feature
    nn.assoc = new int[] { 2, 0, 1, -1, 4, -1, -1, 2, 2, 1 };
    AssociateNearestNeighbor<TupleDesc_F64> alg = new AssociateNearestNeighbor<>(nn, 10);
    FastQueue<TupleDesc_F64> src = new FastQueue<>(10, TupleDesc_F64.class, false);
    FastQueue<TupleDesc_F64> dst = new FastQueue<>(10, TupleDesc_F64.class, false);
    for (int i = 0; i < 5; i++) {
        src.add(new TupleDesc_F64(10));
    }
    for (int i = 0; i < 10; i++) {
        dst.add(new TupleDesc_F64(10));
    }
    alg.setSource(src);
    alg.setDestination(dst);
    alg.associate();
    FastQueue<AssociatedIndex> matches = alg.getMatches();
    assertTrue(nn.pointDimension == 10);
    assertEquals(7, matches.size);
    for (int i = 0, count = 0; i < nn.assoc.length; i++) {
        if (nn.assoc[i] != -1) {
            int source = nn.assoc[i];
            assertEquals(source, matches.get(count).src);
            assertEquals(i, matches.get(count).dst);
            count++;
        }
    }
    GrowQueue_I32 unassoc = alg.getUnassociatedSource();
    assertEquals(1, unassoc.size);
    assertEquals(3, unassoc.get(0));
    unassoc = alg.getUnassociatedDestination();
    assertEquals(3, unassoc.size);
    assertEquals(3, unassoc.get(0));
    assertEquals(5, unassoc.get(1));
    assertEquals(6, unassoc.get(2));
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) FastQueue(org.ddogleg.struct.FastQueue) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 2 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class BenchmarkAssociationSpeedSurf method createSet.

private FastQueue<TupleDesc_F64> createSet(String imageName) {
    try {
        BufferedImage image = ImageIO.read(new File(imageName));
        GrayF32 gray = ConvertBufferedImage.convertFrom(image, (GrayF32) null);
        FastQueue<TupleDesc_F64> ret = new FastQueue<>(10, TupleDesc_F64.class, false);
        detector.detect(gray);
        for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
            ret.add(detector.getDescription(i).copy());
        }
        return ret;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) FastQueue(org.ddogleg.struct.FastQueue) IOException(java.io.IOException) File(java.io.File) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Example 3 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class FactoryMultiView method computePnP_1.

/**
 * Created an estimator for the P3P problem that selects a single solution by considering additional
 * observations.
 *
 * <p>NOTE: Observations are in normalized image coordinates NOT pixels.</p>
 *
 * <p>
 * NOTE: EPnP has several tuning parameters and the defaults here might not be the best for your situation.
 * Use {@link #computePnPwithEPnP} if you wish to have access to all parameters.
 * </p>
 *
 * @param which The algorithm which is to be returned.
 * @param numIterations Number of iterations. Only used by some algorithms and recommended number varies
 *                      significantly by algorithm.
 * @param numTest How many additional sample points are used to remove ambiguity in the solutions.  Not used
 *                if only a single solution is found.
 * @return An estimator which returns a single estimate.
 */
public static Estimate1ofPnP computePnP_1(EnumPNP which, int numIterations, int numTest) {
    if (which == EnumPNP.EPNP) {
        PnPLepetitEPnP alg = new PnPLepetitEPnP(0.1);
        alg.setNumIterations(numIterations);
        return new WrapPnPLepetitEPnP(alg);
    }
    FastQueue<Se3_F64> solutions = new FastQueue<>(4, Se3_F64.class, true);
    return new EstimateNto1ofPnP(computePnP_N(which, -1), solutions, numTest);
}
Also used : PnPLepetitEPnP(boofcv.alg.geo.pose.PnPLepetitEPnP) FastQueue(org.ddogleg.struct.FastQueue) Se3_F64(georegression.struct.se.Se3_F64)

Example 4 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class TestAssociateSurfBasic method basicAssociation.

@Test
public void basicAssociation() {
    FastQueue<BrightFeature> src = new FastQueue<>(10, BrightFeature.class, false);
    FastQueue<BrightFeature> dst = new FastQueue<>(10, BrightFeature.class, false);
    // create a list where some should be matched and others not
    src.add(createDesc(true, 10));
    src.add(createDesc(true, 12));
    src.add(createDesc(false, 5));
    src.add(createDesc(false, 2344));
    src.add(createDesc(false, 1000));
    dst.add(createDesc(true, 0));
    dst.add(createDesc(true, 10.1));
    dst.add(createDesc(true, 13));
    dst.add(createDesc(false, 0.1));
    dst.add(createDesc(false, 7));
    alg.setSrc(src);
    alg.setDst(dst);
    alg.associate();
    FastQueue<AssociatedIndex> matches = alg.getMatches();
    assertEquals(3, matches.size());
    assertTrue(matches.get(0).fitScore != 0);
    assertEquals(0, matches.get(0).src);
    assertEquals(1, matches.get(0).dst);
    assertTrue(matches.get(1).fitScore != 0);
    assertEquals(1, matches.get(1).src);
    assertEquals(2, matches.get(1).dst);
    assertTrue(matches.get(2).fitScore != 0);
    assertEquals(2, matches.get(2).src);
    assertEquals(4, matches.get(2).dst);
    // see if the expected number of features are in the unassociated list
    GrowQueue_I32 unassoc = alg.unassociatedSrc;
    assertEquals(2, unassoc.size);
    // make sure none of the unassociated are contained in the associated list
    for (int i = 0; i < unassoc.size; i++) {
        int index = unassoc.data[i];
        for (int j = 0; j < matches.size(); j++) {
            if (matches.get(j).src == index)
                fail("match found");
        }
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) FastQueue(org.ddogleg.struct.FastQueue) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 5 with FastQueue

use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.

the class CompareConvertedDescriptionsApp method describeImage.

public static <TD extends TupleDesc> FastQueue<TD> describeImage(GrayF32 input, InterestPointDetector<GrayF32> detector, DescribeRegionPoint<GrayF32, TD> describe, List<Point2D_F64> location) {
    FastQueue<TD> list = new FastQueue<>(100, describe.getDescriptionType(), false);
    System.out.println("Detecting");
    detector.detect(input);
    System.out.println("Describing");
    describe.setImage(input);
    for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
        Point2D_F64 p = detector.getLocation(i);
        double radius = detector.getRadius(i);
        double ori = detector.getOrientation(i);
        TD d = describe.createDescription();
        if (describe.process(p.x, p.y, ori, radius, d)) {
            list.add(d);
            location.add(p.copy());
        }
    }
    return list;
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) FastQueue(org.ddogleg.struct.FastQueue) FactoryDescribeRegionPoint(boofcv.factory.feature.describe.FactoryDescribeRegionPoint) DescribeRegionPoint(boofcv.abst.feature.describe.DescribeRegionPoint) FactoryInterestPoint(boofcv.factory.feature.detect.interest.FactoryInterestPoint)

Aggregations

FastQueue (org.ddogleg.struct.FastQueue)9 BrightFeature (boofcv.struct.feature.BrightFeature)3 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)3 Test (org.junit.Test)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 FastQueueArray_I32 (boofcv.struct.FastQueueArray_I32)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)2 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)2 GrayU16 (boofcv.struct.image.GrayU16)2 GrayU8 (boofcv.struct.image.GrayU8)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 BufferedImage (java.awt.image.BufferedImage)2 File (java.io.File)2 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)1 PnPLepetitEPnP (boofcv.alg.geo.pose.PnPLepetitEPnP)1 FactoryDescribeRegionPoint (boofcv.factory.feature.describe.FactoryDescribeRegionPoint)1 FactoryInterestPoint (boofcv.factory.feature.detect.interest.FactoryInterestPoint)1