Search in sources :

Example 6 with ChessboardCorner

use of boofcv.alg.feature.detect.chess.ChessboardCorner in project BoofCV by lessthanoptimal.

the class VisualizeChessboardXCornerUtils method visualizeCorners.

public void visualizeCorners(Graphics2D g2, double scale, int minPyramidLevel, boolean showNumbers) {
    for (int i = 0; i < foundCorners.size; i++) {
        ChessboardCorner c = foundCorners.get(i);
        if (c.level2 < minPyramidLevel)
            continue;
        double x = c.x;
        double y = c.y;
        g2.setStroke(stroke5);
        g2.setColor(Color.BLACK);
        VisualizeFeatures.drawCircle(g2, x * scale, y * scale, 5, circle);
        g2.setStroke(stroke2);
        g2.setColor(Color.ORANGE);
        VisualizeFeatures.drawCircle(g2, x * scale, y * scale, 5, circle);
        double dx = 6 * Math.cos(c.orientation);
        double dy = 6 * Math.sin(c.orientation);
        g2.setStroke(stroke2);
        g2.setColor(Color.CYAN);
        line.setLine((x - dx) * scale, (y - dy) * scale, (x + dx) * scale, (y + dy) * scale);
        g2.draw(line);
    }
    if (showNumbers) {
        UtilCalibrationGui.drawIndexes(g2, 18, foundCorners.toList(), null, minPyramidLevel, scale);
    }
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner)

Example 7 with ChessboardCorner

use of boofcv.alg.feature.detect.chess.ChessboardCorner in project BoofCV by lessthanoptimal.

the class TestECoCheckDetector method createCorrectedTarget_Marked.

/**
 * It will fail to create a target because a grid element has been marked, indicating that it has already been
 * used. This is a rare situation not tested in image based tests above.
 */
@Test
void createCorrectedTarget_Marked() {
    Transform transform = new Transform();
    transform.marker = 0;
    // make this large enough so that it doesn't blow up by trying to access a pixel out of bounds
    alg.cornersAroundBinary.reshape(10, 10);
    // Create a grid with a few arbitrary elements that will have no issues
    DogArray<GridElement> sparseGrid = alg.clusterToGrid.getSparseGrid();
    for (int i = 0; i < 5; i++) {
        GridElement e = sparseGrid.grow();
        e.row = i;
        e.col = 0;
        e.node = new ChessboardCornerGraph.Node();
        e.node.corner = new ChessboardCorner();
    }
    // Pass the first time
    assertTrue(alg.createCorrectedTarget(transform, new ECoCheckFound()));
    // Second time it will blow up because they have been marked!
    assertFalse(alg.createCorrectedTarget(transform, new ECoCheckFound()));
}
Also used : GridElement(boofcv.alg.fiducial.calib.chess.ChessboardCornerClusterToGrid.GridElement) ChessboardCornerGraph(boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph) ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) Transform(boofcv.alg.fiducial.calib.ecocheck.ECoCheckDetector.Transform) Test(org.junit.jupiter.api.Test)

Example 8 with ChessboardCorner

use of boofcv.alg.feature.detect.chess.ChessboardCorner in project BoofCV by lessthanoptimal.

the class TestChessboardCornerClusterFinder method createFisheye.

List<ChessboardCorner> createFisheye() {
    double[] data = new double[] { 901.730, 19.788, -0.916481, 776.088, 36.243, 0.800666, 659.545, 67.488, -1.141423, 556.513, 110.203, 0.534072, 568.884, 159.993, -1.193452, 587.523, 219.934, 0.483544, 609.680, 284.868, -1.216572, 699.776, 255.642, 0.630314, 799.915, 234.210, -1.047695, 906.694, 223.450, 0.866288, 1016.448, 224.564, -0.848513, 1122.507, 237.118, 1.029737, 1135.740, 163.016, -0.661328, 1146.909, 94.946, 1.022470, 1154.920, 40.350, -0.735298, 1026.851, 77.206, -0.746636, 1021.864, 147.066, 0.870077, 904.144, 146.284, -0.927371, 789.445, 159.577, 0.700495, 682.746, 185.030, -1.134515, 668.750, 120.472, 0.577675, 780.841, 91.222, -0.959134, 902.360, 75.823, 0.804160, 1030.534, 21.252, 0.903699 };
    // Input image was 1920x1920
    // let's scale that down to 480x480
    double scale = 4.0;
    List<ChessboardCorner> out = new ArrayList<>();
    for (int i = 0; i < data.length; i += 3) {
        ChessboardCorner c = new ChessboardCorner();
        c.x = data[i] / scale;
        c.y = data[i + 1] / scale;
        c.orientation = data[i + 2];
        c.intensity = 100;
        out.add(c);
    }
    return out;
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) ArrayList(java.util.ArrayList)

Example 9 with ChessboardCorner

use of boofcv.alg.feature.detect.chess.ChessboardCorner in project BoofCV by lessthanoptimal.

the class TestChessboardCornerEdgeIntensity method square.

@Test
void square() {
    RenderCalibrationTargetsGraphics2D render = new RenderCalibrationTargetsGraphics2D(30, 1);
    render.chessboard(5, 4, 50);
    ChessboardCornerEdgeIntensity<GrayU8> alg = new ChessboardCornerEdgeIntensity<>(GrayU8.class);
    alg.setImage(render.getGrayU8());
    double x0 = padding + length;
    double y0 = padding + length;
    double yawA = Math.PI / 4;
    double yawB = -Math.PI / 4;
    ChessboardCorner a11 = create(x0, y0, yawA);
    ChessboardCorner a12 = create(x0 + length, y0, yawB);
    ChessboardCorner a21 = create(x0, y0 + length, yawB);
    ChessboardCorner a22 = create(x0 + length, y0 + length, yawA);
    double found0 = alg.process(a11, a12, 0);
    double found1 = alg.process(a11, a21, Math.PI / 2.0);
    double found2 = alg.process(a21, a22, 0);
    assertEquals(255, found0, UtilEjml.TEST_F32);
    assertEquals(255, found1, UtilEjml.TEST_F32);
    assertEquals(255, found2, UtilEjml.TEST_F32);
    // same results in the other direction
    found0 = alg.process(a12, a11, Math.PI);
    found1 = alg.process(a21, a11, -Math.PI / 2.0);
    found2 = alg.process(a22, a21, Math.PI);
    assertEquals(255, found0, UtilEjml.TEST_F32);
    assertEquals(255, found1, UtilEjml.TEST_F32);
    assertEquals(255, found2, UtilEjml.TEST_F32);
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) RenderCalibrationTargetsGraphics2D(boofcv.gui.RenderCalibrationTargetsGraphics2D) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

Example 10 with ChessboardCorner

use of boofcv.alg.feature.detect.chess.ChessboardCorner in project BoofCV by lessthanoptimal.

the class TestChessboardCornerClusterFinder method perfect_ambiguous.

void perfect_ambiguous(int rows, int cols, int numAmbiguous) {
    List<ChessboardCorner> input = createCorners(rows, cols);
    // add new corners which are near by existing ones but not part of the grid
    int N = rows * cols;
    for (int i = 0; i < numAmbiguous; i++) {
        ChessboardCorner c = input.get(rand.nextInt(N));
        ChessboardCorner d = new ChessboardCorner();
        d.setTo(c);
        d.x += rand.nextGaussian() * sideLength / 30.0;
        d.y += rand.nextGaussian() * sideLength / 30.0;
        input.add(d);
    }
    ChessboardCornerClusterFinder<GrayU8> alg = createAlg();
    // this is perfect, 8 should be enough
    alg.setMaxNeighbors(10);
    // reduced the number so that having an non-exhaustive search is stressed more
    alg.process(image, input, 1);
    DogArray<ChessboardCornerGraph> found = alg.getOutputClusters();
    if (numAmbiguous == 0) {
        assertEquals(1, found.size);
        checkClusterPerfect(found.get(0), rows, cols);
    } else {
        assertTrue(found.size > 0);
        for (int i = 0; i < found.size; i++) {
            checkClusterAmbiguous(found.get(i), rows, cols);
        }
    }
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) GrayU8(boofcv.struct.image.GrayU8)

Aggregations

ChessboardCorner (boofcv.alg.feature.detect.chess.ChessboardCorner)18 Test (org.junit.jupiter.api.Test)9 Node (boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph.Node)8 DogArray (org.ddogleg.struct.DogArray)3 GrayU8 (boofcv.struct.image.GrayU8)2 ArrayList (java.util.ArrayList)2 ChessboardCornerClusterFinder (boofcv.alg.fiducial.calib.chess.ChessboardCornerClusterFinder)1 GridElement (boofcv.alg.fiducial.calib.chess.ChessboardCornerClusterToGrid.GridElement)1 GridInfo (boofcv.alg.fiducial.calib.chess.ChessboardCornerClusterToGrid.GridInfo)1 ChessboardCornerGraph (boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph)1 Transform (boofcv.alg.fiducial.calib.ecocheck.ECoCheckDetector.Transform)1 RenderCalibrationTargetsGraphics2D (boofcv.gui.RenderCalibrationTargetsGraphics2D)1 GrayF32 (boofcv.struct.image.GrayF32)1 Point2D_F32 (georegression.struct.point.Point2D_F32)1 AffineTransform (java.awt.geom.AffineTransform)1