Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions src/main/java/net/sf/javaanpr/configurator/Configurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,75 +46,75 @@ public final class Configurator {
private Properties list;

private Configurator() throws IOException {
this.list = new Properties();
list = new Properties();

this.setIntProperty("photo_adaptivethresholdingradius", 7); // 0 = not adaptive, 7 is recommended
setIntProperty("photo_adaptivethresholdingradius", 7); // 0 = not adaptive, 7 is recommended

this.setDoubleProperty("bandgraph_peakfootconstant", 0.55); // 0.75
this.setDoubleProperty("bandgraph_peakDiffMultiplicationConstant", 0.2);
setDoubleProperty("bandgraph_peakfootconstant", 0.55); // 0.75
setDoubleProperty("bandgraph_peakDiffMultiplicationConstant", 0.2);

this.setIntProperty("carsnapshot_distributormargins", 25);
this.setIntProperty("carsnapshot_graphrankfilter", 9);
setIntProperty("carsnapshot_distributormargins", 25);
setIntProperty("carsnapshot_graphrankfilter", 9);

this.setDoubleProperty("carsnapshotgraph_peakfootconstant", 0.55); // 0.55
this.setDoubleProperty("carsnapshotgraph_peakDiffMultiplicationConstant", 0.1);
setDoubleProperty("carsnapshotgraph_peakfootconstant", 0.55); // 0.55
setDoubleProperty("carsnapshotgraph_peakDiffMultiplicationConstant", 0.1);

this.setIntProperty("intelligence_skewdetection", 0);
setIntProperty("intelligence_skewdetection", 0);

// this.setDoubleProperty("char_contrastnormalizationconstant", 0.5); //1.0
this.setIntProperty("char_normalizeddimensions_x", 8); // 8
this.setIntProperty("char_normalizeddimensions_y", 13); // 13
this.setIntProperty("char_resizeMethod", 1); // 0 = linear 1 = average
this.setIntProperty("char_featuresExtractionMethod", 0); // 0 = map, 1 = edge
this.setStrProperty("char_neuralNetworkPath", "/neuralnetworks/network_avgres_813_map.xml");
this.setStrProperty("char_learnAlphabetPath", "/alphabets/alphabet_8x13");
this.setIntProperty("intelligence_classification_method", 0); // 0 = pattern match, 1 = neural network
// setDoubleProperty("char_contrastnormalizationconstant", 0.5); //1.0
setIntProperty("char_normalizeddimensions_x", 8); // 8
setIntProperty("char_normalizeddimensions_y", 13); // 13
setIntProperty("char_resizeMethod", 1); // 0 = linear 1 = average
setIntProperty("char_featuresExtractionMethod", 0); // 0 = map, 1 = edge
setStrProperty("char_neuralNetworkPath", "/neuralnetworks/network_avgres_813_map.xml");
setStrProperty("char_learnAlphabetPath", "/alphabets/alphabet_8x13");
setIntProperty("intelligence_classification_method", 0); // 0 = pattern match, 1 = neural network

this.setDoubleProperty("plategraph_peakfootconstant", 0.7); // urci sirku detekovanej medzery
this.setDoubleProperty("plategraph_rel_minpeaksize", 0.86); // 0.85 (mensie cislo seka znaky, vacsie zase
setDoubleProperty("plategraph_peakfootconstant", 0.7); // urci sirku detekovanej medzery
setDoubleProperty("plategraph_rel_minpeaksize", 0.86); // 0.85 (mensie cislo seka znaky, vacsie zase
// nespravne zdruzuje)

this.setDoubleProperty("platehorizontalgraph_peakfootconstant", 0.05);
this.setIntProperty("platehorizontalgraph_detectionType", 1); // 0 = magnitude derivate, 1 = edge detection
setDoubleProperty("platehorizontalgraph_peakfootconstant", 0.05);
setIntProperty("platehorizontalgraph_detectionType", 1); // 0 = magnitude derivate, 1 = edge detection

this.setDoubleProperty("plateverticalgraph_peakfootconstant", 0.42);
setDoubleProperty("plateverticalgraph_peakfootconstant", 0.42);

this.setIntProperty("intelligence_numberOfBands", 3);
this.setIntProperty("intelligence_numberOfPlates", 3);
this.setIntProperty("intelligence_numberOfChars", 20);
this.setIntProperty("intelligence_minimumChars", 5);
this.setIntProperty("intelligence_maximumChars", 15);
setIntProperty("intelligence_numberOfBands", 3);
setIntProperty("intelligence_numberOfPlates", 3);
setIntProperty("intelligence_numberOfChars", 20);
setIntProperty("intelligence_minimumChars", 5);
setIntProperty("intelligence_maximumChars", 15);
// plate heuristics
this.setDoubleProperty("intelligence_maxCharWidthDispersion", 0.5); // in plate
this.setDoubleProperty("intelligence_minPlateWidthHeightRatio", 0.5);
this.setDoubleProperty("intelligence_maxPlateWidthHeightRatio", 15.0);
setDoubleProperty("intelligence_maxCharWidthDispersion", 0.5); // in plate
setDoubleProperty("intelligence_minPlateWidthHeightRatio", 0.5);
setDoubleProperty("intelligence_maxPlateWidthHeightRatio", 15.0);
// char heuristics
this.setDoubleProperty("intelligence_minCharWidthHeightRatio", 0.1);
this.setDoubleProperty("intelligence_maxCharWidthHeightRatio", 0.92);
this.setDoubleProperty("intelligence_maxBrightnessCostDispersion", 0.161);
this.setDoubleProperty("intelligence_maxContrastCostDispersion", 0.1);
this.setDoubleProperty("intelligence_maxHueCostDispersion", 0.145);
this.setDoubleProperty("intelligence_maxSaturationCostDispersion", 0.24); // 0.15
this.setDoubleProperty("intelligence_maxHeightCostDispersion", 0.2);
this.setDoubleProperty("intelligence_maxSimilarityCostDispersion", 100);
setDoubleProperty("intelligence_minCharWidthHeightRatio", 0.1);
setDoubleProperty("intelligence_maxCharWidthHeightRatio", 0.92);
setDoubleProperty("intelligence_maxBrightnessCostDispersion", 0.161);
setDoubleProperty("intelligence_maxContrastCostDispersion", 0.1);
setDoubleProperty("intelligence_maxHueCostDispersion", 0.145);
setDoubleProperty("intelligence_maxSaturationCostDispersion", 0.24); // 0.15
setDoubleProperty("intelligence_maxHeightCostDispersion", 0.2);
setDoubleProperty("intelligence_maxSimilarityCostDispersion", 100);
// recognition
this.setIntProperty("intelligence_syntaxanalysis", 2);
this.setStrProperty("intelligence_syntaxDescriptionFile", "/syntax.xml");
setIntProperty("intelligence_syntaxanalysis", 2);
setStrProperty("intelligence_syntaxDescriptionFile", "/syntax.xml");

this.setIntProperty("neural_maxk", 8000); // maximum K - maximalny pocet iteracii
this.setDoubleProperty("neural_eps", 0.07); // epsilon - pozadovana presnost
this.setDoubleProperty("neural_lambda", 0.05); // lambda factor - rychlost ucenia, velkost gradientu
this.setDoubleProperty("neural_micro", 0.5); // micro - momentovy clen pre prekonavanie lokalnych extremov
setIntProperty("neural_maxk", 8000); // maximum K - maximalny pocet iteracii
setDoubleProperty("neural_eps", 0.07); // epsilon - pozadovana presnost
setDoubleProperty("neural_lambda", 0.05); // lambda factor - rychlost ucenia, velkost gradientu
setDoubleProperty("neural_micro", 0.5); // micro - momentovy clen pre prekonavanie lokalnych extremov
// top(log(m recognized units)) = 6
this.setIntProperty("neural_topology", 20); // topologia strednej vrstvy
setIntProperty("neural_topology", 20); // topologia strednej vrstvy

this.setStrProperty("help_file_help", "/help/help.html");
this.setStrProperty("help_file_about", "/help/about.html");
this.setStrProperty("reportgeneratorcss", "/reportgenerator/style.css");
setStrProperty("help_file_help", "/help/help.html");
setStrProperty("help_file_about", "/help/about.html");
setStrProperty("reportgeneratorcss", "/reportgenerator/style.css");

InputStream is = this.getResourceAsStream(this.fileName);
InputStream is = getResourceAsStream(fileName);
if (is != null) {
this.loadConfiguration(is);
loadConfiguration(is);
is.close();
}
Configurator.configurator = this;
Expand All @@ -133,83 +133,83 @@ public static synchronized Configurator getConfigurator() {
}

public String getConfigurationFileName() {
return this.fileName;
return fileName;
}

public void setConfigurationFileName(String name) {
this.fileName = name;
fileName = name;
}

public String getStrProperty(String name) {
return this.list.getProperty(name).toString();
return list.getProperty(name).toString();
}

public String getPathProperty(String name) {
return this.getStrProperty(name).replace('/', File.separatorChar);
return getStrProperty(name).replace('/', File.separatorChar);

}

public void setStrProperty(String name, String value) {
this.list.setProperty(name, value);
list.setProperty(name, value);
}

public int getIntProperty(String name) throws NumberFormatException {
return Integer.decode(this.list.getProperty(name));
return Integer.decode(list.getProperty(name));
}

public void setIntProperty(String name, int value) {
this.list.setProperty(name, String.valueOf(value));
list.setProperty(name, String.valueOf(value));
}

public double getDoubleProperty(String name) throws NumberFormatException {
return Double.parseDouble(this.list.getProperty(name));
return Double.parseDouble(list.getProperty(name));
}

public void setDoubleProperty(String name, double value) {
this.list.setProperty(name, String.valueOf(value));
list.setProperty(name, String.valueOf(value));
}

public Color getColorProperty(String name) {
return new Color(Integer.decode(this.list.getProperty(name)));
return new Color(Integer.decode(list.getProperty(name)));
}

public void setColorProperty(String name, Color value) {
this.list.setProperty(name, String.valueOf(value.getRGB()));
list.setProperty(name, String.valueOf(value.getRGB()));
}

public void saveConfiguration() throws IOException {
this.saveConfiguration(this.fileName);
saveConfiguration(fileName);
}

public void saveConfiguration(String arg_file) throws IOException {
FileOutputStream os = new FileOutputStream(arg_file);
this.list.storeToXML(os, this.comment);
list.storeToXML(os, comment);
os.close();
}

public void loadConfiguration() throws IOException {
this.loadConfiguration(this.fileName);
loadConfiguration(fileName);
}

public void loadConfiguration(String arg_file) throws IOException {
InputStream is = this.getResourceAsStream(arg_file);
this.loadConfiguration(is);
InputStream is = getResourceAsStream(arg_file);
loadConfiguration(is);
is.close();
}

public void loadConfiguration(InputStream arg_stream) throws IOException {
if (arg_stream == null) {
this.list = null;
list = null;
return;
}
this.list.loadFromXML(arg_stream);
list.loadFromXML(arg_stream);
}

public InputStream getResourceAsStream(String filename) {
String corrected = filename;
URL f = this.getClass().getResource(corrected);
URL f = getClass().getResource(corrected);
if (f != null) {
return this.getClass().getResourceAsStream(corrected);
return getClass().getResourceAsStream(corrected);
}

if (filename.startsWith("/")) {
Expand All @@ -220,9 +220,9 @@ public InputStream getResourceAsStream(String filename) {
corrected = "/" + filename;
}

f = this.getClass().getResource(corrected);
f = getClass().getResource(corrected);
if (f != null) {
return this.getClass().getResourceAsStream(corrected);
return getClass().getResourceAsStream(corrected);
}

// Should actually load filename. It is here for the GUI. Loading images exactly from specified filesystem path
Expand Down