diff --git a/NGCC/Tess4J/tessdata/eng.traineddata b/NGCC/Tess4J/tessdata/eng.traineddata index f4744c2..561883f 100644 Binary files a/NGCC/Tess4J/tessdata/eng.traineddata and b/NGCC/Tess4J/tessdata/eng.traineddata differ diff --git a/NGCC/pdf b/NGCC/pdf new file mode 100644 index 0000000..eec84a3 --- /dev/null +++ b/NGCC/pdf @@ -0,0 +1 @@ +Student number;Grade diff --git a/NGCC/src/commands/Read.java b/NGCC/src/commands/Read.java index c5ef909..75e184c 100644 --- a/NGCC/src/commands/Read.java +++ b/NGCC/src/commands/Read.java @@ -5,6 +5,7 @@ import picocli.CommandLine; import picocli.CommandLine.*; import progressbar.ProgressBar; +import java.io.File; import java.io.PrintStream; import java.util.concurrent.Callable; @@ -137,10 +138,11 @@ public class Read implements Callable { Config config = new Config(source_path); //Initialise le fichier de configuration selon le chemin donné config.readConfig(); - GestionnaireCopies ocr = new GestionnaireCopies(directory_name); // Instantie l'ocr + String filePath = new File("").getAbsolutePath(); - + GestionnaireCopies ocr = new GestionnaireCopies("..\\"+directory_name+"\\"); + // Instantie l'ocr GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name, logger); diff --git a/NGCC/src/csv/GenerateCSV.java b/NGCC/src/csv/GenerateCSV.java index 20949a7..ab6979b 100644 --- a/NGCC/src/csv/GenerateCSV.java +++ b/NGCC/src/csv/GenerateCSV.java @@ -50,7 +50,7 @@ public class GenerateCSV { } public void createFile() { - try (PrintWriter writer = new PrintWriter(new File("E:\\S3T\\Projet\\pt-s3t-g4\\pdf"))) { + try (PrintWriter writer = new PrintWriter(new File("pdf"))) { logger.info("Creating csv file"); StringBuilder sb = new StringBuilder(); diff --git a/NGCC/src/ocr/GestionnaireCopies.java b/NGCC/src/ocr/GestionnaireCopies.java index 7faa144..15a5cff 100644 --- a/NGCC/src/ocr/GestionnaireCopies.java +++ b/NGCC/src/ocr/GestionnaireCopies.java @@ -1,7 +1,6 @@ package ocr; -import java.awt.Graphics2D; -import java.awt.Image; + import java.awt.image.BufferedImage; import java.io.File; @@ -11,10 +10,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.imageio.ImageIO; -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JLabel; import org.apache.pdfbox.pdmodel.PDDocument; @@ -36,6 +31,7 @@ public class GestionnaireCopies { } applyOcr(); + } public List createImagesCopies(String path){ @@ -49,9 +45,11 @@ public class GestionnaireCopies { try { - String pdfFilesDirectory = "E:\\S3T\\Projet\\pt-s3t-g4\\pdf"; + + // nom du fichier pdf à ouvrir (TODO: changer le chemin) - List files = pdfAnalyzer.listAllFiles(pdfFilesDirectory, ".pdf"); + List files = pdfAnalyzer.listAllFiles(path, ".pdf"); + for (String fname : files) { pdfFile = new File(fname); document = PDDocument.load(pdfFile); // charge le fichier pdf cree pour le traiter diff --git a/NGCC/src/ocr/ImagesCopie.java b/NGCC/src/ocr/ImagesCopie.java index 3987f85..255b65d 100644 --- a/NGCC/src/ocr/ImagesCopie.java +++ b/NGCC/src/ocr/ImagesCopie.java @@ -19,7 +19,7 @@ public class ImagesCopie { for(Img s : hMapImgs.values()) { s.applyOcrImg(); - System.out.println("Desc : "+s.getDescription()); + System.out.println("Desc : "+s.getClass().getCanonicalName()+" "+s.getDescription()); } } diff --git a/NGCC/src/ocr/OCR.java b/NGCC/src/ocr/OCR.java index 6b7eaaf..469ca4b 100644 --- a/NGCC/src/ocr/OCR.java +++ b/NGCC/src/ocr/OCR.java @@ -12,10 +12,10 @@ public abstract class OCR { Tesseract tesseract = new Tesseract(); String str=""; try { - tesseract.setDatapath("E:\\S3T\\Projet\\pt-s3t-g4\\NGCC\\Tess4J"); - + tesseract.setDatapath("Tess4J"); + tesseract.setLanguage("eng"); //tesseract.setOcrEngineMode(2); - tesseract.setTessVariable("tessedit_char_whitelist","0-9"); + tesseract.setTessVariable("tessedit_char_whitelist","0123456789"); str=tesseract.doOCR(img); } catch (TesseractException e) { diff --git a/NGCC/src/ocr/Rogneur.java b/NGCC/src/ocr/Rogneur.java index 4805aa2..170d20e 100644 --- a/NGCC/src/ocr/Rogneur.java +++ b/NGCC/src/ocr/Rogneur.java @@ -30,14 +30,11 @@ public abstract class Rogneur { int ratioX = (imgOriginale.getWidth()/595); int ratioY = (imgOriginale.getWidth()/841); - int numEtuX1 = ratioX*((595/4)+ 4); - int numEtuY1 = ratioY*115; + int numEtuX1 = ratioX*((595/4)+ 4)+10; + int numEtuY1 = ratioY*115 + 275; int numEtuX2 = ratioX*((595/4)+150); - int numEtuY2 = ratioY*146; - - System.out.println("X1 + X2 : " +numEtuX1 + " " + numEtuX2); - System.out.println("Y1 + Y2 : " +numEtuY1 + " " + numEtuY2); + int numEtuY2 = ratioY*146 + 310; BufferedImage temp = imgOriginale.getSubimage(numEtuX1, numEtuY1, numEtuX2-numEtuX1, numEtuY2-numEtuY1); @@ -56,14 +53,13 @@ public abstract class Rogneur { int ratioX = (imgOriginale.getWidth()/595); int ratioY = (imgOriginale.getWidth()/841); - int numNoteX1 = ratioX*((595/4) + 4); - int numNoteY1 = ratioY*160; + int numNoteX1 = ratioX*((595/4) + 4)+60; + int numNoteY1 = ratioY*160+400; + + int numNoteX2 = ratioX*((595/4) +80); + int numNoteY2 = ratioY*200+400; - int numNoteX2 = ratioX*((595/4) +75); - int numNoteY2 = ratioY*200; - System.out.println("X1 + X2 : " +numNoteX1 + " " + numNoteX2); - System.out.println("Y1 + Y2 : " +numNoteY1 + " " + numNoteY2); BufferedImage temp = imgOriginale.getSubimage(numNoteX1, numNoteY1, numNoteX2-numNoteX1, numNoteY2-numNoteY1); JFrame frame = new JFrame();