Search in sources :

Example 1 with ChessboardCorner

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

the class TestChessboardCornerEdgeIntensity method create.

private static ChessboardCorner create(double x, double y, double yaw) {
    ChessboardCorner c = new ChessboardCorner();
    c.setTo(x, y, yaw, 0);
    return c;
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner)

Example 2 with ChessboardCorner

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

the class TestChessboardCornerClusterFinder method createCorners.

List<ChessboardCorner> createCorners(int rows, int cols) {
    List<ChessboardCorner> corners = new ArrayList<>();
    for (int row = 0; row < rows; row++) {
        double y = offsetY + sideLength * row;
        for (int col = 0; col < cols; col++) {
            double x = offsetX + sideLength * col;
            ChessboardCorner c = new ChessboardCorner();
            c.intensity = 20;
            c.orientation = (((row % 2) + (col % 2)) % 2) == 0 ? Math.PI / 4 : -Math.PI / 4;
            c.x = x;
            c.y = y;
            corners.add(c);
        }
    }
    // randomize the list
    Collections.shuffle(corners, rand);
    return corners;
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) ArrayList(java.util.ArrayList)

Example 3 with ChessboardCorner

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

the class UtilCalibrationGui method drawIndexes.

public static void drawIndexes(Graphics2D g2, int fontSize, List<ChessboardCorner> points, @Nullable Point2Transform2_F32 transform, int minLevel, double scale) {
    int numDigits = BoofMiscOps.numDigits(points.size());
    String format = "%" + numDigits + "d";
    Font regular = new Font("Serif", Font.PLAIN, fontSize);
    g2.setFont(regular);
    Point2D_F32 adj = new Point2D_F32();
    AffineTransform origTran = g2.getTransform();
    for (int i = 0; i < points.size(); i++) {
        ChessboardCorner p = points.get(i);
        if (p.level2 < minLevel)
            continue;
        if (transform != null) {
            transform.compute((float) p.x, (float) p.y, adj);
        } else {
            adj.setTo((float) p.x, (float) p.y);
        }
        String text = String.format(format, i);
        int x = (int) (adj.x * scale);
        int y = (int) (adj.y * scale);
        g2.setColor(Color.BLACK);
        g2.drawString(text, x - 1, y);
        g2.drawString(text, x + 1, y);
        g2.drawString(text, x, y - 1);
        g2.drawString(text, x, y + 1);
        g2.setTransform(origTran);
        g2.setColor(Color.GREEN);
        g2.drawString(text, x, y);
    }
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) AffineTransform(java.awt.geom.AffineTransform) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 4 with ChessboardCorner

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

the class DetectXCornersVisualizeApp method processImage.

@Override
public void processImage(int sourceID, long frameID, BufferedImage buffered, ImageBase input) {
    GrayF32 gray = (GrayF32) input;
    if (controlPanel.scaleDown > 1) {
        int scale = controlPanel.scaleDown;
        GrayF32 scaled = new GrayF32(input.width / scale, input.height / scale);
        AverageDownSampleOps.down(gray, scaled);
        gray = scaled;
        visualized = ConvertBufferedImage.checkDeclare(scaled.width, scaled.height, visualized, BufferedImage.TYPE_INT_RGB);
        original = ConvertBufferedImage.checkDeclare(scaled.width, scaled.height, original, buffered.getType());
        Graphics2D g2 = original.createGraphics();
        g2.setTransform(AffineTransform.getScaleInstance(1.0 / scale, 1.0 / scale));
        g2.drawImage(buffered, 0, 0, null);
    } else {
        visualized = ConvertBufferedImage.checkDeclare(gray.width, gray.height, visualized, BufferedImage.TYPE_INT_RGB);
        original = ConvertBufferedImage.checkDeclare(gray.width, gray.height, original, buffered.getType());
        original = ConvertBufferedImage.checkCopy(buffered, original);
    }
    GrayF32 featureImg;
    double processingTime;
    synchronized (lockAlgorithm) {
        long time0 = System.nanoTime();
        detector.process(gray);
        long time1 = System.nanoTime();
        // milliseconds
        processingTime = (time1 - time0) * 1e-6;
        featureImg = detector.getDetector().getIntensityRaw();
        if (controlPanel.logItensity) {
            PixelMath.logSign(featureImg, 1.0f, logIntensity);
            VisualizeImageData.colorizeSign(logIntensity, visualized, ImageStatistics.maxAbs(logIntensity));
        } else {
            VisualizeImageData.colorizeSign(featureImg, visualized, ImageStatistics.maxAbs(featureImg));
        }
        synchronized (lockCorners) {
            DogArray<ChessboardCorner> orig = detector.getCorners();
            foundCorners.reset();
            for (int i = 0; i < orig.size(); i++) {
                foundCorners.grow().setTo(orig.get(i));
            }
        }
    }
    SwingUtilities.invokeLater(() -> {
        imagePanel.setBufferedImageNoChange(original);
        controlPanel.setProcessingTimeMS(processingTime);
        imagePanel.repaint();
    });
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner)

Example 5 with ChessboardCorner

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

the class VisualizeChessboardXCornerUtils method visualizePerpendicular.

public void visualizePerpendicular(Graphics2D g2, double scale, ChessboardCornerClusterFinder<GrayF32> clusterFinder) {
    g2.setFont(regular);
    BasicStroke thin = new BasicStroke(2);
    BasicStroke thick = new BasicStroke(4);
    // g2.setStroke(new BasicStroke(1));
    // List<Vertex> vertexes = detector.getClusterFinder().getVertexes().toList();
    List<ChessboardCornerClusterFinder.LineInfo> lines = clusterFinder.getLines().toList();
    for (int i = 0; i < lines.size(); i++) {
        ChessboardCornerClusterFinder.LineInfo lineInfo = lines.get(i);
        if (lineInfo.isDisconnected() || lineInfo.parallel)
            continue;
        ChessboardCornerClusterFinder.Vertex va = Objects.requireNonNull(lineInfo.endA).dst;
        ChessboardCornerClusterFinder.Vertex vb = Objects.requireNonNull(lineInfo.endB).dst;
        ChessboardCorner ca = foundCorners.get(va.index);
        ChessboardCorner cb = foundCorners.get(vb.index);
        double intensity = lineInfo.intensity == -Double.MAX_VALUE ? Double.NaN : lineInfo.intensity;
        line.setLine(ca.x * scale, ca.y * scale, cb.x * scale, cb.y * scale);
        g2.setStroke(thick);
        g2.setColor(Color.BLACK);
        g2.draw(line);
        g2.setStroke(thin);
        g2.setColor(Color.ORANGE);
        g2.draw(line);
        float x = (float) ((ca.x + cb.x) / 2.0);
        float y = (float) ((ca.y + cb.y) / 2.0);
        g2.setColor(Color.RED);
        g2.drawString(String.format("%.1f", intensity), x * (float) scale, y * (float) scale);
    }
}
Also used : ChessboardCorner(boofcv.alg.feature.detect.chess.ChessboardCorner) ChessboardCornerClusterFinder(boofcv.alg.fiducial.calib.chess.ChessboardCornerClusterFinder)

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