diff --git a/config/build.xml b/config/build.xml new file mode 100644 index 0000000..bd1e903 --- /dev/null +++ b/config/build.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + Builds, tests, and runs the project Tess4J. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/config.txt b/config/config.txt new file mode 100644 index 0000000..20a7a8b --- /dev/null +++ b/config/config.txt @@ -0,0 +1 @@ +Code : 8 diff --git a/config/lib/win32-x86-64/libtesseract3051.dll b/config/lib/win32-x86-64/libtesseract3051.dll new file mode 100644 index 0000000..6cd60e0 Binary files /dev/null and b/config/lib/win32-x86-64/libtesseract3051.dll differ diff --git a/config/lib/win32-x86/libtesseract3051.dll b/config/lib/win32-x86/libtesseract3051.dll new file mode 100644 index 0000000..ddc5e08 Binary files /dev/null and b/config/lib/win32-x86/libtesseract3051.dll differ diff --git a/config/nbproject/build-impl.xml b/config/nbproject/build-impl.xml new file mode 100644 index 0000000..7386081 --- /dev/null +++ b/config/nbproject/build-impl.xml @@ -0,0 +1,1793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/nbproject/genfiles.properties b/config/nbproject/genfiles.properties new file mode 100644 index 0000000..189448f --- /dev/null +++ b/config/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=1dc6a699 +build.xml.script.CRC32=f0eaf91d +build.xml.stylesheet.CRC32=28e38971@1.38.2.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=1f03e186 +nbproject/build-impl.xml.script.CRC32=a52f4060 +nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.88.0.48 diff --git a/config/nbproject/private/config.properties b/config/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/config/nbproject/private/private.properties b/config/nbproject/private/private.properties new file mode 100644 index 0000000..33e876b --- /dev/null +++ b/config/nbproject/private/private.properties @@ -0,0 +1,8 @@ +compile.on.save=true +do.depend=true +do.jar=true +do.jlink=false +javac.debug=false +javadoc.preview=true +jlink.strip=false +user.properties.file=C:\\Users\\Quan\\AppData\\Roaming\\NetBeans\\dev\\build.properties diff --git a/config/nbproject/private/private.xml b/config/nbproject/private/private.xml new file mode 100644 index 0000000..6807a2b --- /dev/null +++ b/config/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/config/nbproject/project.properties b/config/nbproject/project.properties new file mode 100644 index 0000000..ae00480 --- /dev/null +++ b/config/nbproject/project.properties @@ -0,0 +1,138 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.desc=A Java wrapper for Tesseract OCR API +application.homepage=http://tess4j.sf.net +application.title=Tess4J +application.vendor=Quan Nguyen +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/tess4j-${version}.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.commons-beanutils-1.9.2.jar=lib/commons-beanutils-1.9.2.jar +file.reference.commons-io-2.6.jar=lib/commons-io-2.6.jar +file.reference.commons-logging-1.2.jar=lib/commons-logging-1.2.jar +file.reference.fontbox-2.0.9.jar=lib/fontbox-2.0.9.jar +file.reference.ghost4j-1.0.1.jar=lib/ghost4j-1.0.1.jar +file.reference.itext-2.1.7.jar=lib/itext-2.1.7.jar +file.reference.jai-imageio-core-1.4.0.jar=lib/jai-imageio-core-1.4.0.jar +file.reference.jbig2-imageio-3.0.0.jar=lib/jbig2-imageio-3.0.0.jar +file.reference.jboss-vfs-3.2.12.Final.jar=lib/jboss-vfs-3.2.12.Final.jar +file.reference.jna-4.1.0.jar=lib/jna-4.1.0.jar +file.reference.jul-to-slf4j-1.7.25.jar=lib/jul-to-slf4j-1.7.25.jar +file.reference.lept4j-1.6.4.jar=lib/lept4j-1.6.4.jar +file.reference.log4j-1.2.17.jar=lib/log4j-1.2.17.jar +file.reference.logback-classic-1.2.3.jar=lib/logback-classic-1.2.3.jar +file.reference.logback-core-1.2.3.jar=lib/logback-core-1.2.3.jar +file.reference.pdfbox-2.0.9.jar=lib/pdfbox-2.0.9.jar +file.reference.pdfbox-tools-2.0.9.jar=lib/pdfbox-tools-2.0.9.jar +file.reference.slf4j-api-1.7.25.jar=lib/slf4j-api-1.7.25.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.ghost4j-1.0.1.jar}:\ + ${file.reference.jna-4.1.0.jar}:\ + ${file.reference.log4j-1.2.17.jar}:\ + ${file.reference.itext-2.1.7.jar}:\ + ${file.reference.commons-beanutils-1.9.2.jar}:\ + ${file.reference.commons-logging-1.2.jar}:\ + ${file.reference.slf4j-api-1.7.25.jar}:\ + ${file.reference.jul-to-slf4j-1.7.25.jar}:\ + ${file.reference.commons-io-2.6.jar}:\ + ${file.reference.jboss-vfs-3.2.12.Final.jar}:\ + ${file.reference.logback-classic-1.2.3.jar}:\ + ${file.reference.logback-core-1.2.3.jar}:\ + ${file.reference.jai-imageio-core-1.4.0.jar}:\ + ${file.reference.lept4j-1.6.4.jar}:\ + ${file.reference.pdfbox-2.0.9.jar}:\ + ${file.reference.pdfbox-tools-2.0.9.jar}:\ + ${file.reference.fontbox-2.0.9.jar}:\ + ${file.reference.jbig2-imageio-3.0.0.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=true +javac.external.vm=false +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit_4.classpath}:\ + ${libs.hamcrest.classpath} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle=Tess4J API +jlink.launcher=false +jlink.launcher.name=Tess4J +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/config/nbproject/project.xml b/config/nbproject/project.xml new file mode 100644 index 0000000..e1c23bd --- /dev/null +++ b/config/nbproject/project.xml @@ -0,0 +1,19 @@ + + + org.netbeans.modules.java.j2seproject + + + Tess4J + + + + + + + + + .\lib\nblibraries.properties + + + + diff --git a/config/tessdata/configs/api_config b/config/tessdata/configs/api_config new file mode 100644 index 0000000..5cd6ec0 --- /dev/null +++ b/config/tessdata/configs/api_config @@ -0,0 +1 @@ +tessedit_zero_rejection T diff --git a/config/tessdata/configs/digits b/config/tessdata/configs/digits new file mode 100644 index 0000000..6a329f8 --- /dev/null +++ b/config/tessdata/configs/digits @@ -0,0 +1 @@ +tessedit_char_whitelist 0123456789-. diff --git a/config/tessdata/configs/hocr b/config/tessdata/configs/hocr new file mode 100644 index 0000000..72f83e8 --- /dev/null +++ b/config/tessdata/configs/hocr @@ -0,0 +1 @@ +tessedit_create_hocr 1 \ No newline at end of file diff --git a/config/tessdata/eng.traineddata b/config/tessdata/eng.traineddata new file mode 100644 index 0000000..561883f Binary files /dev/null and b/config/tessdata/eng.traineddata differ diff --git a/config/tessdata/osd.traineddata b/config/tessdata/osd.traineddata new file mode 100644 index 0000000..527457c Binary files /dev/null and b/config/tessdata/osd.traineddata differ diff --git a/config/tessdata/pdf.ttf b/config/tessdata/pdf.ttf new file mode 100644 index 0000000..eb359b3 Binary files /dev/null and b/config/tessdata/pdf.ttf differ diff --git a/config/tessdata/pdf.ttx b/config/tessdata/pdf.ttx new file mode 100644 index 0000000..c6db1c8 --- /dev/null +++ b/config/tessdata/pdf.ttx @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/commands/Read.java b/src/commands/Read.java index 215f892..ff1c626 100644 --- a/src/commands/Read.java +++ b/src/commands/Read.java @@ -1,10 +1,5 @@ package commands; -import picocli.CommandLine; - -import picocli.CommandLine.*; -import progressbar.ProgressBar; - import java.io.File; import java.io.PrintStream; import java.util.concurrent.Callable; @@ -17,50 +12,42 @@ import org.apache.logging.log4j.core.config.Configurator; import config.Config; import csv.GenerateCSV; import ocr.GestionnaireCopies; - - +import picocli.CommandLine; +import picocli.CommandLine.Command; +import picocli.CommandLine.Model; +import picocli.CommandLine.Option; +import picocli.CommandLine.Parameters; +import picocli.CommandLine.Spec; @SuppressWarnings("unused") -@Command( - name = "-r", - version = "Version 1.0", - sortOptions = false, - usageHelpWidth = 60, - header = "Read command - Automatic entry", - footer = "", - description = "\nAnalyzes all scanned copies (pdf files) provided to recognize student's name and mark.\n" -) +@Command(name = "-r", version = "Version 1.0", sortOptions = false, usageHelpWidth = 60, header = "Read command - Automatic entry", footer = "", description = "\nAnalyzes all scanned copies (pdf files) provided to recognize student's name and mark.\n") +public class Read implements Callable { + public Logger logger = LogManager.getLogger(Read.class); - -public class Read implements Callable { - - public Logger logger = LogManager.getLogger(Read.class); - @Spec Model.CommandSpec spec; - - @Option(names= {"-help"}, arity = "0", order = 1, description = "command help") + + @Option(names = { "-help" }, arity = "0", order = 1, description = "command help") boolean help; - - @Option(names= {"-u"}, arity = "1", order = 2, description = "update mode") + + @Option(names = { "-u" }, arity = "1", order = 2, description = "update mode") int step; - - @Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode") + + @Option(names = { "-v" }, arity = "0..*", order = 3, defaultValue = "1", description = "verbose mode") public int vb_level; - - @Option(names= {"-d"}, arity = "1", order = 4, defaultValue = "copies", description ="directory") + + @Option(names = { "-d" }, arity = "1", order = 4, defaultValue = "copies", description = "directory") String directory_name; - - @Option(names= {"-o"}, arity = "1", order = 5, defaultValue = "result.csv", description ="result") + + @Option(names = { "-o" }, arity = "1", order = 5, defaultValue = "result.csv", description = "result") String result_name; - - @Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path") + + @Parameters(arity = "0..1", defaultValue = "config/source.txt", description = "source path") String source_path; - - + // Flux de sortie si nécéssaire public Read(PrintStream out) { } @@ -68,49 +55,42 @@ public class Read implements Callable { // Check de l'extension csv (à améliorer) public boolean isCsv(String file) { return file.endsWith(".csv"); - + } - @Override public Void call() throws Exception { - + // Niveau de debug selon verbosite - - if (vb_level >= 0 && vb_level <=2) { + + if ((this.vb_level >= 0) && (this.vb_level <= 2)) { Configurator.setLevel("commands", Level.FATAL); Configurator.setLevel("csv", Level.FATAL); - } - else if (vb_level >= 3 && vb_level <=4) { + } else if ((this.vb_level >= 3) && (this.vb_level <= 4)) { Configurator.setLevel("commands", Level.ERROR); Configurator.setLevel("csv", Level.ERROR); - } - else if (vb_level >= 5 && vb_level <=6) { + } else if ((this.vb_level >= 5) && (this.vb_level <= 6)) { Configurator.setLevel("commands", Level.WARN); Configurator.setLevel("csv", Level.WARN); - } - else if (vb_level >= 7 && vb_level <=8) { + } else if ((this.vb_level >= 7) && (this.vb_level <= 8)) { Configurator.setLevel("commands", Level.INFO); Configurator.setLevel("csv", Level.INFO); - } - else { + } else { Configurator.setLevel("commands", Level.DEBUG); Configurator.setLevel("csv", Level.DEBUG); } - + // Help genere de la commande - - if(help) { - logger.info("Help for 'read' command executed"); + + if (this.help) { + this.logger.info("Help for 'read' command executed"); CommandLine.usage(this.spec, System.out); - } - else { - - + } else { + //************* Progress Bar Prototype ************** - + // ProgressBar bar = new ProgressBar(); -// +// // System.out.println("\nReading pdf ...\n"); // // bar.update(0, 1000); @@ -122,46 +102,45 @@ public class Read implements Callable { // // update the progress bar // bar.update(i, 1000); // On ajoute 100/imgList.length à chaque temps estimé par image // } -// +// // System.out.println("\nCopies correction succeed !\n"); //*************************************************** - - + // Log des parametres - - logger.info("Read mode activated"); - logger.debug("Update : "+step); - logger.debug("Verbose : "+vb_level); - logger.debug("Directory : "+directory_name); - logger.debug("Result : "+result_name); - logger.debug("Source : "+source_path); - - - if (!isCsv(result_name)) { - result_name = result_name+".csv"; - logger.info("Result file name changed to '"+result_name+"'"); + + this.logger.info("Read mode activated"); + this.logger.debug("Update : " + this.step); + this.logger.debug("Verbose : " + this.vb_level); + this.logger.debug("Directory : " + this.directory_name); + this.logger.debug("Result : " + this.result_name); + this.logger.debug("Source : " + this.source_path); + + if (!this.isCsv(this.result_name)) { + this.result_name = this.result_name + ".csv"; + this.logger.info("Result file name changed to '" + this.result_name + "'"); } - - Config config = new Config(source_path); //Initialise le fichier de configuration selon le chemin donné + Config config = new Config(this.source_path); // Initialise le fichier de configuration selon le chemin + // donné config.readConfig(); - + String filePath = new File("").getAbsolutePath(); - + // Instantie l'OCR - GestionnaireCopies ocr = new GestionnaireCopies(directory_name); - - - logger.debug("CSV initialized with : "+ocr.createHashMapforCSV()+" , "+config.getParam().get("Code")+" , "+result_name); - - GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"),config.getParam().get("MarkFormat"), result_name); - - csv.createFile(); //Génère le fichier csv à partir de la HMap retournée par l'OCR - - //Done ! - + GestionnaireCopies ocr = new GestionnaireCopies(this.directory_name); + + this.logger.debug("CSV initialized with : " + ocr.createHashMapforCSV() + " , " + + config.getParam().get("Code") + " , " + this.result_name); + + GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(), config.getParam().get("Code"), + config.getParam().get("MarkFormat"), this.result_name); + + csv.createFile(); // Génère le fichier csv à partir de la HMap retournée par l'OCR + + // Done ! + } - return null; + return null; } } diff --git a/src/ocr/OCR.java b/src/ocr/OCR.java index 55925fc..f4d6181 100644 --- a/src/ocr/OCR.java +++ b/src/ocr/OCR.java @@ -1,28 +1,27 @@ package ocr; + import java.awt.image.BufferedImage; -import net.sourceforge.tess4j.Tesseract; -import net.sourceforge.tess4j.TesseractException; - + +import net.sourceforge.tess4j.Tesseract; +import net.sourceforge.tess4j.TesseractException; + public abstract class OCR { - - public static String applyOcrNumber(BufferedImage img) { - //FAIRE L'OCR + // FAIRE L'OCR Tesseract tesseract = new Tesseract(); - String str=""; + String str = ""; try { - tesseract.setDatapath("Tess4J"); + tesseract.setDatapath("config"); tesseract.setLanguage("eng"); - //tesseract.setOcrEngineMode(2); - tesseract.setTessVariable("tessedit_char_whitelist",",0123456789"); - str=tesseract.doOCR(img); + // tesseract.setOcrEngineMode(2); + tesseract.setTessVariable("tessedit_char_whitelist", ",0123456789"); + str = tesseract.doOCR(img); } catch (TesseractException e) { - + e.printStackTrace(); } - - - return str; + + return str; } } diff --git a/src/recadragePdf/CorrectionPdf.java b/src/recadragePdf/CorrectionPdf.java index 7d380d2..59b2a52 100644 --- a/src/recadragePdf/CorrectionPdf.java +++ b/src/recadragePdf/CorrectionPdf.java @@ -1,4 +1,4 @@ -package RecadragePdf; +package recadragePdf; public class CorrectionPdf { diff --git a/tests/TestExec.java b/tests/TestExec.java index e14a506..11c3bcc 100644 --- a/tests/TestExec.java +++ b/tests/TestExec.java @@ -1,19 +1,13 @@ -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; -import picocli.CommandLine; - - class TestExec { @Test void test() throws InterruptedException { - + Exec exec = new Exec(); - - - //Exec.main(new String[] {}); + + Exec.main(new String[] {}); } }