Search in sources :

Example 6 with ConfigSquareGrid

use of boofcv.abst.fiducial.calib.ConfigSquareGrid in project BoofCV by lessthanoptimal.

the class CreateCalibrationTargetGui method saveFile.

private void saveFile(boolean sendToPrinter) {
    // grab the focus and force what the user is editing to be saved
    File f;
    // see where the document is to be sent
    if (sendToPrinter) {
        // dummy to make the code below happy and less complex
        f = new File("");
    } else {
        f = FileSystemView.getFileSystemView().getHomeDirectory();
        f = new File(f, "calibration_target.pdf");
        f = BoofSwingUtil.fileChooser(this, false, f.getPath());
        if (f == null) {
            return;
        }
        if (f.isDirectory()) {
            JOptionPane.showMessageDialog(this, "Can't save to a directory!");
            return;
        }
    }
    // Make sure the file has the correct extension
    String outputFile = f.getAbsolutePath();
    String ext = FilenameUtils.getExtension(outputFile);
    if (ext.compareToIgnoreCase("pdf") != 0) {
        outputFile = FilenameUtils.removeExtension(outputFile);
        outputFile += "." + "pdf";
    }
    try {
        switch(selectedType) {
            case CHESSBOARD:
                {
                    ConfigChessboard config = (ConfigChessboard) selectedCalib;
                    CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
                    generator.sendToPrinter = sendToPrinter;
                    generator.chessboard((float) config.squareWidth);
                }
                break;
            case SQUARE_GRID:
                {
                    ConfigSquareGrid config = (ConfigSquareGrid) selectedCalib;
                    CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
                    generator.sendToPrinter = sendToPrinter;
                    generator.squareGrid((float) config.squareWidth, (float) config.spaceWidth);
                }
                break;
            case CIRCLE_GRID:
                {
                    ConfigCircleRegularGrid config = (ConfigCircleRegularGrid) selectedCalib;
                    CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
                    generator.sendToPrinter = sendToPrinter;
                    generator.circleGrid((float) config.circleDiameter, (float) config.centerDistance);
                }
                break;
            case CIRCLE_HEX:
                {
                    ConfigCircleHexagonalGrid config = (ConfigCircleHexagonalGrid) selectedCalib;
                    CreateCalibrationTargetGenerator generator = new CreateCalibrationTargetGenerator(outputFile, paper, config.numRows, config.numCols, units);
                    generator.sendToPrinter = sendToPrinter;
                    generator.circleHexagonal((float) config.circleDiameter, (float) config.centerDistance);
                }
                break;
            default:
                throw new RuntimeException("Unknown type " + selectedType);
        }
    } catch (IOException e) {
        BoofSwingUtil.warningDialog(this, e);
    }
}
Also used : ConfigSquareGrid(boofcv.abst.fiducial.calib.ConfigSquareGrid) ConfigCircleHexagonalGrid(boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid) ConfigChessboard(boofcv.abst.fiducial.calib.ConfigChessboard) IOException(java.io.IOException) ConfigCircleRegularGrid(boofcv.abst.fiducial.calib.ConfigCircleRegularGrid) File(java.io.File)

Aggregations

ConfigSquareGrid (boofcv.abst.fiducial.calib.ConfigSquareGrid)6 ConfigChessboard (boofcv.abst.fiducial.calib.ConfigChessboard)4 ConfigCircleHexagonalGrid (boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid)3 ConfigCircleRegularGrid (boofcv.abst.fiducial.calib.ConfigCircleRegularGrid)3 RenderCalibrationTargetsGraphics2D (boofcv.gui.RenderCalibrationTargetsGraphics2D)2 IOException (java.io.IOException)2 SimpleStringNumberReader (boofcv.io.SimpleStringNumberReader)1 GrayU8 (boofcv.struct.image.GrayU8)1 File (java.io.File)1 Reader (java.io.Reader)1