Closed MateuszKaczmarczyk closed 7 years ago
Hey, could you please upload your config.xml
and possibly even the image you are testing against? Thanks for reporting the issue!
config.xml and example photos I used are below. The only thing I changed in config.xml is path to syntax file, it's because it couldn't find syntax file with default path, so I moved it and changed path.
config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
Global configuration file for the Automatic Number Plate Recognition System ```7 0 3 3 20 5 15 0.5 0.5 15.0 0.1 0.92 0.161 0.1 0.145 0.24 0.2 100.0 8 13 /alphabets/alphabet_8x13 1 0 0 neuralnetworks/network_avgres_813_map.xml 8000 0.07 0.05 0.5 20 2 syntax.xml 9 25 0.1 0.55 0.2 0.55 1 0.05 0.42 0.86 0.7 ```
Photos:
Now I tried with another photo, and there is no exception, but result is: null. Photo that returns null below:
Thanks for the bug report, I'll get to it as soon as possible.
master
version of JavaANPR with the default configuration, the syntax file is found just fine.<!DOCTYPE structure SYSTEM "src/main/resources/dtd/syntax.dtd">
<structure>
<type name="poland">
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
</type>
<type name="poland2">
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
</type>
</structure>
Almost all of them were mostly correct. Still no exceptions.
I pushed 2 new commits into master, try to rebuild with the newest version and see if the error still appears.
Still the same error on first two photos, and third returns null. I think some problems may be caused by wrong project import. I created new project with only one class, and added jar (after running mvn clean install) of javaanpr, so i can use net.sf.javaanpr.* packages. First problem i've faced was:
ERROR net.sf.javaanpr.intelligence.Parser - Failed to load from parser syntax description file java.io.FileNotFoundException: C:\prj\anprtest\src\main\resources\dtd\syntax.dtd
And then, after fixing above error:
java.lang.ArrayIndexOutOfBoundsException: 0 >= 00 >= 0 at java.util.Vector.elementAt(Unknown Source) at net.sf.javaanpr.intelligence.Intelligence.recognize(Intelligence.java:244) at main.java.pl.anpr.MainClass.main(MainClass.java:12)
I fixed the dtd loading issue in 8f121829243eb488421f7b62314a04ade8a8fa25.
I could not reproduce you're other error. It worked for me doing the following steps:
package cz.matfyz.oskopek;
import net.sf.javaanpr.configurator.Configurator;
import net.sf.javaanpr.imageanalysis.CarSnapshot;
import net.sf.javaanpr.intelligence.Intelligence;
public class Main {
public static void main(String[] args) throws Exception {
Configurator.getConfigurator().loadConfiguration("cz/matfyz/oskopek/config.xml");
Intelligence intel = new Intelligence();
String[] imgs = {"img1.jpg", "img2.jpg", "img3.jpg"};
for (String img : imgs) {
CarSnapshot carSnap = new CarSnapshot("/home/oskopek/tmp/" + img);
String numberPlate = intel.recognize(carSnap, true);
System.out.println(img + ":\t" + numberPlate);
}
}
}
src/cz/matfyz/oskopek/config.xml
file:
src/main/resources
(of JavaANPR). The only change is the syntax.xml file:<entry key="intelligence_syntaxDescriptionFile">cz/matfyz/oskopek/syntax.xml</entry>
src/cz/matfyz/oskopek/syntax.xml
file:<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE structure SYSTEM "https://raw.githubusercontent.com/oskopek/javaanpr/master/src/main/resources/dtd/syntax.dtd">
<structure>
<type name="poland">
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
</type>
<type name="poland2">
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="0123456789"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
<char content="abcdefghijklmnopqrstuvwxyz"/>
</type>
</structure>
Resulting output:
img1.jpg: null
img2.jpg: PO082CC
img3.jpg: NNI12742
I tried to run this project on Linux OS (Ubuntu) and everything seems to be ok, there is no exception. Output is the same:
img1.jpg: null
img2.jpg: PO082CC
img3.jpg: NNI12742
However on Windows 10 still "java.lang.ArrayIndexOutOfBoundsException: 0 >= 0". Maybe it's OS fault, or maybe - different version of Java or Maven?
I'm going to run JavaANPR on Raspberry Pi (Linux, Raspbian), so i think it will be working there. For now, I will work on Linux. Thank you for help, now there are no configuration problems (like missing syntax file), and I can develop my application.
Couldn't reproduce issue on Windows 7, JDK8. Closing as "wontfix".
When I'm trying to recogonize car plates from jpg, I'm getting ArrayIndexOutOfBoundsException. Below is the code and error.
Code:
Error:
Error is in this line of Intelligence.java:
similarityCost = ((RecognizedPattern)rc.getPatterns().elementAt(0)).getCost();
So it's look like rc.getPatterns() returns empty collection.I tried with different images, and error is occuring every time. I'm using lastest version of JavaANPR and default settings.