Libraries and fixed path bugs/ocr
This commit is contained in:
parent
b5b5ae276d
commit
925d7d8f6f
Binary file not shown.
@ -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 <Void> {
|
||||
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);
|
||||
|
@ -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();
|
||||
|
@ -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<BufferedImage> 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<String> files = pdfAnalyzer.listAllFiles(pdfFilesDirectory, ".pdf");
|
||||
List<String> 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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user