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);
}
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);
}
}
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));
}
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);
}
}
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));
}
}
}
Aggregations