use of georegression.struct.line.LinePolar2D_F32 in project BoofCV by lessthanoptimal.
the class CommonGridRansacLineDetectorChecks method checkObvious.
/**
* Give it a single straight line and see if it can detect it. Allow the region size to be changed to check
* for issues related to that
* @param regionSize
*/
protected void checkObvious(int regionSize) {
// System.out.println("regionSize = "+regionSize);
int where = 25;
GrayU8 edgeImage = new GrayU8(width, height);
D derivX = GeneralizedImageOps.createSingleBand(derivType, width, height);
D derivY = GeneralizedImageOps.createSingleBand(derivType, width, height);
for (int i = 0; i < height; i++) {
edgeImage.set(where, i, 1);
GeneralizedImageOps.set(derivX, where, i, 20);
}
ModelManagerLinePolar2D_F32 manager = new ModelManagerLinePolar2D_F32();
GridLineModelDistance distance = new GridLineModelDistance(0.9f);
GridLineModelFitter fitter = new GridLineModelFitter(0.9f);
ModelMatcher<LinePolar2D_F32, Edgel> matcher = new Ransac<>(123123, manager, fitter, distance, 25, 1);
GridRansacLineDetector<D> alg = createDetector(regionSize, 5, matcher);
alg.process(derivX, derivY, edgeImage);
MatrixOfList<LineSegment2D_F32> lines = alg.getFoundLines();
assertEquals(width / regionSize, lines.getWidth());
assertEquals(height / regionSize, lines.getHeight());
int gridCol = where / regionSize;
for (int i = 0; i < lines.height; i++) {
List<LineSegment2D_F32> l = lines.get(gridCol, i);
assertTrue(l.size() == 1);
LineSegment2D_F32 a = l.get(0);
assertTrue(Math.abs(a.slopeY()) > 1);
assertTrue(Math.abs(a.slopeX()) < 0.01);
}
}
use of georegression.struct.line.LinePolar2D_F32 in project BoofCV by lessthanoptimal.
the class TestGridLineModelDistance method computeDistance_list.
@Test
public void computeDistance_list() {
float theta = (float) (Math.PI / 4.0);
LinePolar2D_F32 l = new LinePolar2D_F32((float) (Math.sqrt(2 * 5 * 5)), theta);
GridLineModelDistance alg = new GridLineModelDistance(0.2f);
alg.setModel(l);
double[] distance = new double[2];
List<Edgel> points = new ArrayList<>();
points.add(new Edgel(5, 5, theta));
points.add(new Edgel(0, 0, theta));
alg.computeDistance(points, distance);
assertEquals(0, distance[0], 1e-4);
assertEquals(7.0711, distance[1], 1e-4);
}
use of georegression.struct.line.LinePolar2D_F32 in project BoofCV by lessthanoptimal.
the class TestGridLineModelDistance method distance.
/**
* Assuming two points have an angle less than the max, check the distance
*/
@Test
public void distance() {
float theta = (float) (Math.PI / 4.0);
LinePolar2D_F32 l = new LinePolar2D_F32((float) (Math.sqrt(2 * 5 * 5)), theta);
GridLineModelDistance alg = new GridLineModelDistance(0.2f);
alg.setModel(l);
assertEquals(0, alg.computeDistance(new Edgel(5, 5, theta)), 1e-4);
assertEquals(7.0711, alg.computeDistance(new Edgel(0, 0, theta)), 0.1);
}
use of georegression.struct.line.LinePolar2D_F32 in project BoofCV by lessthanoptimal.
the class TestGridLineModelFitter method checkFailInCompatible.
/**
* If only two points are passed in, they should fail if their orientations
* are more than the specified tolerance apart
*/
@Test
public void checkFailInCompatible() {
GridLineModelFitter alg = new GridLineModelFitter(0.1f);
// angle test should use half-circle and this should pass
List<Edgel> l = new ArrayList<>();
l.add(new Edgel(0, 0, (float) Math.PI / 2f));
l.add(new Edgel(1, 0, (float) -Math.PI / 2f));
LinePolar2D_F32 model = new LinePolar2D_F32();
assertTrue(alg.generate(l, model));
// this one should fail
l.clear();
l.add(new Edgel(0, 0, (float) Math.PI / 2f));
l.add(new Edgel(1, 0, (float) Math.PI / 2f - 0.5f));
assertFalse(alg.generate(l, model));
}
Aggregations