use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestFitLinesToContour method fitAnchored_perfect_input.
/**
* Easy case were the corners are all in perfect location. Try all permutations of first anchor and second anchor.
*/
@Test
public void fitAnchored_perfect_input() {
FitLinesToContour alg = new FitLinesToContour();
alg.setContour(createSquare(10, 12, 30, 40));
GrowQueue_I32 corners = createSquareCorners(10, 12, 30, 40);
GrowQueue_I32 found = new GrowQueue_I32();
for (int anchor0 = 0; anchor0 < 4; anchor0++) {
for (int j = 0; j < 4; j++) {
// this case it can't optimize
if (j == 1)
continue;
int anchor1 = (anchor0 + j) % 4;
alg.fitAnchored(anchor0, anchor1, corners, found);
assertEquals(4, found.size());
for (int i = 0; i < found.size(); i++) {
assertEquals(corners.get(i), found.get(i));
}
}
}
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestFitLinesToContour method createSquareCorners.
private GrowQueue_I32 createSquareCorners(int x0, int y0, int x1, int y1) {
GrowQueue_I32 corners = new GrowQueue_I32();
int c0 = 0;
int c1 = c0 + x1 - x0;
int c2 = c1 + y1 - y0;
int c3 = c2 + x1 - x0;
corners.add(c0);
corners.add(c1);
corners.add(c2);
corners.add(c3);
return corners;
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestFitLinesToContour method fitAnchored_easy_optimization.
/**
* Have only one corner off by a few pixels with extremely clean input data
*/
@Test
public void fitAnchored_easy_optimization() {
FitLinesToContour alg = new FitLinesToContour();
alg.setContour(createSquare(10, 12, 30, 40));
GrowQueue_I32 expected = createSquareCorners(10, 12, 30, 40);
GrowQueue_I32 input = createSquareCorners(10, 12, 30, 40);
GrowQueue_I32 found = new GrowQueue_I32();
input.set(2, input.get(2) + 3);
alg.fitAnchored(1, 3, input, found);
for (int i = 0; i < found.size(); i++) {
assertEquals(expected.get(i), found.get(i));
}
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestMinimizeEnergyPrune method prine_no_change.
/**
* Perfect case. See if it does nothing
*/
@Test
public void prine_no_change() {
List<Point2D_I32> contours = createSquare(10, 12, 20, 30);
GrowQueue_I32 corners = createSquareCorners(10, 12, 20, 30);
MinimizeEnergyPrune alg = new MinimizeEnergyPrune(1);
GrowQueue_I32 output = new GrowQueue_I32();
alg.prune(contours, corners, output);
assertEquals(corners.size(), output.size());
for (int i = 0; i < corners.size(); i++) {
assertEquals(corners.get(i), output.get(i));
}
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestMinimizeEnergyPrune method removeDuplicates.
@Test
public void removeDuplicates() {
List<Point2D_I32> contours = createSquare(10, 12, 20, 30);
GrowQueue_I32 corners = createSquareCorners(10, 12, 20, 30);
corners.add(corners.get(0));
corners.add(corners.get(2));
MinimizeEnergyPrune alg = new MinimizeEnergyPrune(4);
alg.contour = contours;
alg.removeDuplicates(corners);
checkMatched(createSquareCorners(10, 12, 20, 30), corners);
}
Aggregations