Ejemplo n.º 1
0
  {
    squareDetector.contour2Poly_splitFraction = 0.1;
    squareDetector.contour2Poly_minimumSideFraction = 0.05;

    ConfigRefinePolygonLineToImage refineLine = new ConfigRefinePolygonLineToImage();
    refineLine.cornerOffset = 0;

    squareDetector.refine = refineLine;
  }
  @Override
  public void stateChanged(ChangeEvent e) {
    PolygonRefineType refine = PolygonRefineType.values()[refineChoice.getSelectedIndex()];

    if (e.getSource() == spinnerMinEdge) {
      config.minimumEdgeIntensity = ((Number) spinnerMinEdge.getValue()).doubleValue();
    } else if (e.getSource() == spinnerMinSides) {
      minSides = ((Number) spinnerMinSides.getValue()).intValue();
      if (minSides > maxSides) {
        maxSides = minSides;
        spinnerMaxSides.setValue(minSides);
      }
      updateSidesInConfig();
    } else if (e.getSource() == spinnerMaxSides) {
      maxSides = ((Number) spinnerMaxSides.getValue()).intValue();
      if (maxSides < minSides) {
        minSides = maxSides;
        spinnerMinSides.setValue(minSides);
      }
      updateSidesInConfig();
    } else if (e.getSource() == selectZoom) {
      zoom = ((Number) selectZoom.getValue()).doubleValue();
      owner.viewUpdated();
      return;
    } else if (e.getSource() == spinnerMinContourSize) {
      config.minContourImageWidthFraction =
          ((Number) spinnerMinContourSize.getValue()).doubleValue();
    } else if (e.getSource() == spinnerContourSplit) {
      config.contour2Poly_splitFraction = ((Number) spinnerContourSplit.getValue()).doubleValue();
    } else if (e.getSource() == spinnerContourMinSplit) {
      config.contour2Poly_minimumSideFraction =
          ((Number) spinnerContourMinSplit.getValue()).doubleValue();
    } else if (e.getSource() == spinnerContourIterations) {
      config.contour2Poly_iterations = ((Number) spinnerContourIterations.getValue()).intValue();
    } else if (e.getSource() == spinnerSplitPenalty) {
      config.splitPenalty = ((Number) spinnerSplitPenalty.getValue()).doubleValue();
    } else if (e.getSource() == spinnerLineSamples) {
      if (refine == PolygonRefineType.LINE) {
        configLine.lineSamples = ((Number) spinnerLineSamples.getValue()).intValue();
      } else {
        configCorner.lineSamples = ((Number) spinnerLineSamples.getValue()).intValue();
      }
    } else if (e.getSource() == spinnerCornerOffset) {
      if (refine == PolygonRefineType.LINE) {
        configLine.cornerOffset = ((Number) spinnerCornerOffset.getValue()).intValue();
      } else {
        configCorner.cornerOffset = ((Number) spinnerCornerOffset.getValue()).intValue();
      }
    } else if (e.getSource() == spinnerSampleRadius) {
      if (refine == PolygonRefineType.LINE) {
        configLine.sampleRadius = ((Number) spinnerSampleRadius.getValue()).intValue();
      } else {
        configCorner.sampleRadius = ((Number) spinnerSampleRadius.getValue()).intValue();
      }
    } else if (e.getSource() == spinnerRefineMaxIterations) {
      if (refine == PolygonRefineType.LINE) {
        configLine.maxIterations = ((Number) spinnerRefineMaxIterations.getValue()).intValue();
      } else {
        configCorner.maxIterations = ((Number) spinnerRefineMaxIterations.getValue()).intValue();
      }
    } else if (e.getSource() == spinnerConvergeTol) {
      if (refine == PolygonRefineType.LINE) {
        configLine.convergeTolPixels = ((Number) spinnerConvergeTol.getValue()).doubleValue();
      } else {
        configCorner.convergeTolPixels = ((Number) spinnerConvergeTol.getValue()).doubleValue();
      }
    } else if (e.getSource() == spinnerMaxCornerChange) {
      if (refine == PolygonRefineType.LINE) {
        configLine.maxCornerChangePixel =
            ((Number) spinnerMaxCornerChange.getValue()).doubleValue();
      } else {
        configCorner.maxCornerChangePixel =
            ((Number) spinnerMaxCornerChange.getValue()).doubleValue();
      }
    }
    owner.configUpdate();
  }