/** * Configure it to detect square-grid style targets */ public CalibrationFiducialDetector(ConfigSquareGrid config, Class<T> imageType) { DetectorFiducialCalibration detector = FactoryFiducialCalibration.squareGrid(config); int squareCols = config.numCols; int squareRows = config.numRows; double sideWidth = squareCols* config.squareWidth + (squareCols-1)*config.spaceWidth; double sideHeight = squareRows*config.squareWidth + (squareRows-1)*config.spaceWidth; double width = (sideWidth+sideHeight)/2.0; init(detector, width, imageType); }
protected void parseTarget( String where ) throws FileNotFoundException { Reader input = media.openFile(where); SimpleStringNumberReader reader = new SimpleStringNumberReader('#'); if( !reader.read(input) ) throw new RuntimeException("Parsing configuration failed"); if( reader.remainingTokens() < 7 ) throw new RuntimeException("Not enough tokens in config file"); String type = reader.nextString(); numRadial = (int)reader.nextDouble(); includeTangential = Boolean.parseBoolean(reader.nextString()); assumeZeroSkew = Boolean.parseBoolean(reader.nextString()); int numCols = (int)reader.nextDouble(); int numRows = (int)reader.nextDouble(); double width = reader.nextDouble(); if( type.compareToIgnoreCase("square") == 0 ) { double space = reader.nextDouble(); detector = FactoryFiducialCalibration.squareGrid(new ConfigSquareGrid(numRows, numCols, width, space)); } else if( type.compareToIgnoreCase("chess") == 0 ) { detector = FactoryFiducialCalibration.chessboard(new ConfigChessboard(numRows, numCols, width)); } else { throw new RuntimeException("Unknown type: "+type); } try { input.close(); } catch (IOException e) {} }
/** * Configures the detector, configures target description for calibration and starts the detector thread. */ @Override public void createNewProcessor() { DetectorFiducialCalibration detector; if( cc.targetType == CalibrationPatterns.CHESSBOARD ) { detector = FactoryFiducialCalibration.chessboard(cc.chessboard); } else if( cc.targetType == CalibrationPatterns.SQUARE_GRID ) { detector = FactoryFiducialCalibration.squareGrid(cc.squareGrid); } else if( cc.targetType == CalibrationPatterns.CIRCLE_HEXAGONAL ){ detector = FactoryFiducialCalibration.circleHexagonalGrid(cc.hexagonal); } else if( cc.targetType == CalibrationPatterns.CIRCLE_GRID ){ detector = FactoryFiducialCalibration.circleRegularGrid(cc.circleGrid); } else { throw new RuntimeException("Unknown targetType "+cc.targetType); } CalibrationComputeActivity.targetLayout = detector.getLayout(); setProcessing(new DetectTarget(detector)); }
@Override public void declareDetector() { config.thresholding = ((DetectCalibrationPolygonPanel)controlPanel).polygonPanel.getThresholdPanel().createConfig(); config.square = ((DetectCalibrationPolygonPanel)controlPanel).polygonPanel.getConfigPolygon(); config.numRows = controlPanel.getGridRows(); config.numCols = controlPanel.getGridColumns(); alg = FactoryFiducialCalibration.squareGrid(config).getAlgorithm(); reprocessImageOnly(); }