Search in sources :

Example 31 with GrowQueue_I32

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

the class ChecksGenericPointsToPolyline method checkMaxVertexes_loop.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
public void checkMaxVertexes_loop() {
    PointsToPolyline alg = createAlg(true);
    alg.setMaximumSides(3);
    List<Point2D_I32> contour = TestPolylineSplitMerge.rect(0, 0, 10, 20);
    GrowQueue_I32 found = new GrowQueue_I32();
    // will fail because the error is too large for 3 sides
    assertFalse(alg.process(contour, found));
    alg.setMaximumSides(4);
    assertTrue(alg.process(contour, found));
    check(found, 0, 10, 30, 40);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 32 with GrowQueue_I32

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

the class AssociateSurfBasic method associate.

/**
 * Associates the features together.
 */
public void associate() {
    // initialize data structures
    matches.reset();
    unassociatedSrc.reset();
    if (srcPositive.size == 0 && srcNegative.size == 0)
        return;
    if (dstPositive.size == 0 && dstNegative.size == 0)
        return;
    // find and add the matches
    assoc.setSource((FastQueue) srcPositive);
    assoc.setDestination((FastQueue) dstPositive);
    assoc.associate();
    FastQueue<AssociatedIndex> m = assoc.getMatches();
    for (int i = 0; i < m.size; i++) {
        AssociatedIndex a = m.data[i];
        int globalSrcIndex = srcPositive.data[a.src].index;
        int globalDstIndex = dstPositive.data[a.dst].index;
        matches.grow().setAssociation(globalSrcIndex, globalDstIndex, a.fitScore);
    }
    GrowQueue_I32 un = assoc.getUnassociatedSource();
    for (int i = 0; i < un.size; i++) {
        unassociatedSrc.add(srcPositive.data[un.get(i)].index);
    }
    assoc.setSource((FastQueue) srcNegative);
    assoc.setDestination((FastQueue) dstNegative);
    assoc.associate();
    m = assoc.getMatches();
    for (int i = 0; i < m.size; i++) {
        AssociatedIndex a = m.data[i];
        int globalSrcIndex = srcNegative.data[a.src].index;
        int globalDstIndex = dstNegative.data[a.dst].index;
        matches.grow().setAssociation(globalSrcIndex, globalDstIndex, a.fitScore);
    }
    un = assoc.getUnassociatedSource();
    for (int i = 0; i < un.size; i++) {
        unassociatedSrc.add(srcNegative.data[un.get(i)].index);
    }
}
Also used : AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 33 with GrowQueue_I32

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

the class ChecksGenericPointsToPolyline method checkIsConvex.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
public void checkIsConvex() {
    PointsToPolyline alg = createAlg(true);
    alg.setConvex(true);
    List<Point2D_I32> contour = line(0, 0, 30, 0);
    contour.addAll(line(30, 0, 30, 10));
    contour.addAll(line(30, 10, 20, 10));
    contour.addAll(line(20, 10, 20, 30));
    contour.addAll(line(20, 30, 0, 30));
    contour.addAll(line(0, 30, 0, 0));
    GrowQueue_I32 found = new GrowQueue_I32();
    assertFalse(alg.process(contour, found));
    alg.setConvex(false);
    assertTrue(alg.process(contour, found));
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 34 with GrowQueue_I32

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

the class TestReidSolomonCodes method findErrors_BruteForce.

public void findErrors_BruteForce(GrowQueue_I8 message, int numErrors, boolean expectedFail) {
    GrowQueue_I8 ecc = new GrowQueue_I8();
    int nsyn = 10;
    GrowQueue_I8 syndromes = GrowQueue_I8.zeros(nsyn);
    GrowQueue_I8 errorLocator = new GrowQueue_I8();
    GrowQueue_I32 locations = new GrowQueue_I32();
    ReidSolomonCodes alg = new ReidSolomonCodes(8, primitive8);
    alg.generator(nsyn);
    alg.computeECC(message, ecc);
    GrowQueue_I8 cmessage = message.copy();
    // corrupt the message and ecc
    int N = message.size + ecc.size;
    int[] corrupted = selectN(numErrors, N);
    for (int i = 0; i < corrupted.length; i++) {
        int w = corrupted[i];
        if (w < message.size)
            cmessage.data[w] ^= 0x45;
        else {
            ecc.data[w - message.size] ^= 0x45;
        }
    }
    // compute needed info
    alg.computeSyndromes(cmessage, ecc, syndromes);
    alg.findErrorLocatorPolynomialBM(syndromes, errorLocator);
    if (expectedFail) {
        assertFalse(alg.findErrorLocations_BruteForce(errorLocator, N, locations));
    } else {
        // find the error locations
        assertTrue(alg.findErrorLocations_BruteForce(errorLocator, N, locations));
        // see if it found the expected number of errors and that the locations match
        assertEquals(numErrors, locations.size);
        for (int i = 0; i < locations.size; i++) {
            int num = 0;
            for (int j = 0; j < corrupted.length; j++) {
                if (corrupted[j] == locations.data[i]) {
                    num++;
                }
            }
            assertEquals(1, num);
        }
        GrowQueue_I8 hack = new GrowQueue_I8();
        alg.findErrorLocatorPolynomial(N, locations, hack);
    }
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 35 with GrowQueue_I32

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

the class TestReidSolomonCodes method findErrorLocatorPolynomialBM_compareToDirect.

/**
 * Compares the results from BM against an error locator polynomial computed directly given the known
 * error locations
 */
@Test
public void findErrorLocatorPolynomialBM_compareToDirect() {
    GrowQueue_I8 found = new GrowQueue_I8();
    GrowQueue_I8 expected = new GrowQueue_I8();
    for (int i = 0; i < 30; i++) {
        int N = 50;
        GrowQueue_I8 message = randomMessage(N);
        GrowQueue_I8 ecc = new GrowQueue_I8();
        int nsyn = 10;
        GrowQueue_I8 syndromes = GrowQueue_I8.zeros(nsyn);
        ReidSolomonCodes alg = new ReidSolomonCodes(8, primitive8);
        alg.generator(nsyn);
        alg.computeECC(message, ecc);
        int where = rand.nextInt(N);
        message.data[where] ^= 0x12;
        alg.computeSyndromes(message, ecc, syndromes);
        GrowQueue_I32 whereList = new GrowQueue_I32(1);
        whereList.add(where);
        alg.findErrorLocatorPolynomialBM(syndromes, found);
        alg.findErrorLocatorPolynomial(N + ecc.size, whereList, expected);
        assertEquals(found.size, expected.size);
        for (int j = 0; j < found.size; j++) {
            assertEquals(found.get(j), expected.get(j));
        }
    }
}
Also used : GrowQueue_I8(org.ddogleg.struct.GrowQueue_I8) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Aggregations

GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)60 Test (org.junit.Test)35 Point2D_I32 (georegression.struct.point.Point2D_I32)21 GrayS32 (boofcv.struct.image.GrayS32)10 ArrayList (java.util.ArrayList)7 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)6 Point2D_F64 (georegression.struct.point.Point2D_F64)5 FastQueue (org.ddogleg.struct.FastQueue)5 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)3 ColorQueue_F32 (boofcv.struct.feature.ColorQueue_F32)3 GrayF32 (boofcv.struct.image.GrayF32)3 GrowQueue_I8 (org.ddogleg.struct.GrowQueue_I8)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 BrightFeature (boofcv.struct.feature.BrightFeature)2 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)2 BufferedImage (java.awt.image.BufferedImage)2