Skip to content

Commit 7da4c80

Browse files
committed
Removed unused calls
1 parent aa7b983 commit 7da4c80

File tree

4 files changed

+32
-37
lines changed

4 files changed

+32
-37
lines changed

src/main/java/net/sf/javaanpr/imageanalysis/Char.java

+11-18
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ public class Char extends Photo {
8686
public boolean normalized = false;
8787
public PositionInPlate positionInPlate = null;
8888

89-
// private PixelMap pixelMap;
90-
private PixelMap.Piece bestPiece = null;
91-
9289
public int fullWidth, fullHeight, pieceWidth, pieceHeight;
9390

9491
public float statisticAverageBrightness;
@@ -117,9 +114,8 @@ public Char(BufferedImage bi) {
117114
* sa vysekavaju zo znacky, ktora uz je sama o sebe prahovana, ale nacitavanie zo suboru tomuto principu nezodpoveda, cize
118115
* spravime prahovanie zvlast
119116
*
120-
* @param fileName
121-
* @throws IOException
122-
* @throws ImageReadException
117+
* @param fileName name of character file
118+
* @throws IOException if the fileName couldn't be loaded
123119
*/
124120
public Char(String fileName) throws IOException {
125121
super(Configurator.getConfigurator().getResourceAsStream(fileName));
@@ -140,9 +136,8 @@ public Char(String fileName) throws IOException {
140136
* sa vysekavaju zo znacky, ktora uz je sama o sebe prahovana, ale nacitavanie zo suboru tomuto principu nezodpoveda, cize
141137
* spravime prahovanie zvlast
142138
*
143-
* @param is
139+
* @param is loads Char from this InputStream
144140
* @throws IOException
145-
* @throws ImageReadException
146141
*/
147142
public Char(InputStream is) throws IOException {
148143
super(is);
@@ -160,6 +155,7 @@ public Char(InputStream is) throws IOException {
160155

161156
@Override
162157
public Char clone() {
158+
super.clone();
163159
return new Char(duplicateBufferedImage(this.image), duplicateBufferedImage(this.thresholdedImage),
164160
this.positionInPlate);
165161
}
@@ -185,17 +181,17 @@ public void normalize() {
185181
*/
186182
PixelMap pixelMap = this.getPixelMap();
187183

188-
this.bestPiece = pixelMap.getBestPiece();
184+
PixelMap.Piece bestPiece = pixelMap.getBestPiece();
189185

190-
colorImage = this.getBestPieceInFullColor(colorImage, this.bestPiece);
186+
colorImage = this.getBestPieceInFullColor(colorImage, bestPiece);
191187

192188
// vypocet statistik
193189
this.computeStatisticBrightness(colorImage);
194190
this.computeStatisticContrast(colorImage);
195191
this.computeStatisticHue(colorImage);
196192
this.computeStatisticSaturation(colorImage);
197193

198-
this.image = this.bestPiece.render();
194+
this.image = bestPiece.render();
199195

200196
if (this.image == null) {
201197
this.image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
@@ -334,18 +330,18 @@ public Vector<Double> extractEdgeFeatures() {
334330
} // end my
335331
} // end mx
336332
} // end f
337-
Vector<Double> outputVector = new Vector<Double>();
333+
Vector<Double> outputVector = new Vector<>();
338334
for (Double value : output) {
339335
outputVector.add(value);
340336
}
341337
return outputVector;
342338
}
343339

344340
public Vector<Double> extractMapFeatures() {
345-
Vector<Double> vectorInput = new Vector<Double>();
341+
Vector<Double> vectorInput = new Vector<>();
346342
for (int y = 0; y < this.getHeight(); y++) {
347343
for (int x = 0; x < this.getWidth(); x++) {
348-
vectorInput.add(new Double(this.getBrightness(x, y)));
344+
vectorInput.add((double) this.getBrightness(x, y));
349345
}
350346
}
351347
return vectorInput;
@@ -365,9 +361,7 @@ private static String getSuffix(String directoryName) {
365361
directoryName = directoryName.substring(0, directoryName.length() - 1); // cuts last char off
366362
}
367363

368-
String suffix = directoryName.substring(directoryName.lastIndexOf('_'));
369-
370-
return suffix;
364+
return directoryName.substring(directoryName.lastIndexOf('_'));
371365
}
372366

373367
public static List<String> getAlphabetList(String directory) {
@@ -386,7 +380,6 @@ public static List<String> getAlphabetList(String directory) {
386380

387381
if (Configurator.getConfigurator().getResourceAsStream(s) != null) {
388382
filenames.add(s);
389-
continue;
390383
}
391384
}
392385

src/main/java/net/sf/javaanpr/imageanalysis/Plate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private Vector<Graph.Peak> computeGraph() {
114114
}
115115

116116
public Vector<Char> getChars() {
117-
Vector<Char> out = new Vector<Char>();
117+
Vector<Char> out = new Vector<>();
118118

119119
Vector<Graph.Peak> peaks = this.computeGraph();
120120

@@ -137,6 +137,7 @@ public Vector<Char> getChars() {
137137

138138
@Override
139139
public Plate clone() {
140+
super.clone();
140141
return new Plate(duplicateBufferedImage(this.image));
141142
}
142143

src/main/java/net/sf/javaanpr/imageanalysis/PlateHorizontalGraph.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ public Vector<Peak> findPeak_derivate(int count) { // RIESENIE DERIVACIOU
104104
float maxVal = this.getMaxValue();
105105

106106
for (a = 2; (-this.derivation(a, a + 4) < (maxVal * 0.2)) && (a < (this.yValues.size() - 2 - 2 - 4)); a++) {
107-
;
107+
108108
}
109109
for (b = this.yValues.size() - 1 - 2; (this.derivation(b - 4, b) < (maxVal * 0.2)) && (b > (a + 2)); b--) {
110-
;
110+
111111
}
112112

113-
Vector<Peak> outPeaks = new Vector<Peak>();
113+
Vector<Peak> outPeaks = new Vector<>();
114114

115115
outPeaks.add(new Peak(a, b));
116116
super.peaks = outPeaks;
@@ -121,13 +121,13 @@ public Vector<Peak> findPeak_edgedetection(int count) {
121121
float average = this.getAverageValue();
122122
int a, b;
123123
for (a = 0; this.yValues.elementAt(a) < average; a++) {
124-
;
124+
125125
}
126126
for (b = this.yValues.size() - 1; this.yValues.elementAt(b) < average; b--) {
127-
;
127+
128128
}
129129

130-
Vector<Peak> outPeaks = new Vector<Peak>();
130+
Vector<Peak> outPeaks = new Vector<>();
131131
a = Math.max(a - 5, 0);
132132
b = Math.min(b + 5, this.yValues.size());
133133

src/main/java/net/sf/javaanpr/intelligence/Intelligence.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ public Intelligence() throws ParserConfigurationException, SAXException, IOExcep
110110
parser = new Parser();
111111
}
112112

113-
// vrati ako dlho v ms trvalo posledne rozpoznaavnie
113+
/**
114+
* Vrati ako dlho v ms trvalo posledne rozpoznaavnie
115+
* @return last process duration in milliseconds
116+
*/
114117
public long lastProcessDuration() {
115118
return lastProcessDuration;
116119
}
@@ -154,8 +157,8 @@ public String recognizeWithReport(CarSnapshot carSnapshot) throws IllegalArgumen
154157
}
155158

156159
// SKEW-RELATED
157-
Plate notNormalizedCopy = null;
158-
BufferedImage renderedHoughTransform = null;
160+
Plate notNormalizedCopy;
161+
BufferedImage renderedHoughTransform;
159162
HoughTransformation hough = null;
160163

161164
/*
@@ -315,7 +318,7 @@ public String recognizeWithReport(CarSnapshot carSnapshot) throws IllegalArgumen
315318

316319
float similarityCost = 0;
317320
RecognizedChar rc = null;
318-
if (ok == true) {
321+
if (ok) {
319322
rc = chrRecog.recognize(chr);
320323
similarityCost = rc.getPatterns().elementAt(0).getCost();
321324

@@ -329,7 +332,7 @@ public String recognizeWithReport(CarSnapshot carSnapshot) throws IllegalArgumen
329332

330333
}
331334

332-
if (ok == true) {
335+
if (ok) {
333336
recognizedPlate.addChar(rc);
334337
} else {
335338
}
@@ -395,7 +398,7 @@ public String recognize(CarSnapshot carSnapshot) {
395398
for (Plate plate : b.getPlates()) {// doporucene 3
396399

397400
// SKEW-RELATED
398-
Plate notNormalizedCopy = null;
401+
Plate notNormalizedCopy;
399402

400403
@SuppressWarnings("unused")
401404
BufferedImage renderedHoughTransform = null;
@@ -521,9 +524,9 @@ public String recognize(CarSnapshot carSnapshot) {
521524
continue;
522525
}
523526

524-
float similarityCost = 0;
527+
float similarityCost;
525528
RecognizedChar rc = null;
526-
if (ok == true) {
529+
if (ok) {
527530
rc = chrRecog.recognize(chr);
528531
similarityCost = rc.getPatterns().elementAt(0).getCost();
529532

@@ -535,7 +538,7 @@ public String recognize(CarSnapshot carSnapshot) {
535538

536539
}
537540

538-
if (ok == true) {
541+
if (ok) {
539542
recognizedPlate.addChar(rc);
540543
}
541544
} // end for each char
@@ -548,9 +551,7 @@ public String recognize(CarSnapshot carSnapshot) {
548551
}
549552

550553
lastProcessDuration = time.getTime();
551-
String parsedOutput = Intelligence.parser.parse(recognizedPlate, syntaxAnalysisMode);
552-
553-
return parsedOutput;
554+
return Intelligence.parser.parse(recognizedPlate, syntaxAnalysisMode);
554555

555556
} // end for each plate
556557

0 commit comments

Comments
 (0)