Ajout d'un ocr plus agile

This commit is contained in:
Hugo 2019-09-27 08:51:47 +02:00
parent 228c16c7fe
commit 5b062f11d7
6 changed files with 52 additions and 19 deletions

View File

@ -10,6 +10,7 @@ public abstract class ImagesCopie {
public ImagesCopie(BufferedImage imgOriginale) {
hMapImgs = Rogneur.createHMapImgs(imgOriginale);
}

View File

@ -2,7 +2,7 @@ package ocr;
import java.awt.image.BufferedImage;
import ocr_orm.OCR;
public class ImgNote extends Img{
@ -13,7 +13,7 @@ public class ImgNote extends Img{
@Override
public void applyOcrImg() {
setDescription(OCR.applyOcrNumber(getImg()));;
setDescription(OCR.applyOcrNumber(getImg()));
}
}

View File

@ -2,7 +2,7 @@ package ocr;
import java.awt.image.BufferedImage;
import ocr_orm.OCR;
public class ImgNumEtu extends Img{
@ -12,7 +12,7 @@ public class ImgNumEtu extends Img{
@Override
public void applyOcrImg() {
setDescription(OCR.applyOcrNumber(getImg()));;
setDescription(OCR.applyOcrNumber(getImg()));
}
}

28
NGCC/src/ocr/OCR.java Normal file
View File

@ -0,0 +1,28 @@
package ocr;
import java.awt.image.BufferedImage;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
public class OCR {
public static String applyOcrNumber(BufferedImage img) {
//FAIRE L'OCR
Tesseract tesseract = new Tesseract();
String str="";
try {
tesseract.setOcrEngineMode(2);
tesseract.setTessVariable("tessedit_char_whitelist","0-9");
str=tesseract.doOCR(img);
} catch (TesseractException e) {
e.printStackTrace();
}
return str;
}
}

View File

@ -10,34 +10,28 @@ public class Rogneur {
public static Map<String, Img> createHMapImgs(BufferedImage imgOriginale) {
Map<String,Img> temp = new HashMap<>();
temp.put("NumEtu", rogneurFormatNote(BufferedImage imgOriginale));
temp.put("Note", rogneurFormatNote(BufferedImage imgOriginale));
temp.put("FormatNote", rogneurFormatNote(BufferedImage imgOriginale));
temp.put("NumEtu", rogneurFormatNote(imgOriginale));
temp.put("Note", rogneurFormatNote(imgOriginale));
temp.put("FormatNote", rogneurFormatNote(imgOriginale));
return temp;
}
// rogne la partie du numEtu
public Img rogneurNumEtu(BufferedImage imgOriginale)
public static Img rogneurNumEtu(BufferedImage imgOriginale)
{
// A FAIRE
//return new ImgNum();
return imgOriginale.getSubimage(x, y, w, h);
}
// rogne la partie de la note
public Img rogneurNote(BufferedImage imgOriginale)
public static Img rogneurNote(BufferedImage imgOriginale)
{
// A FAIRE
//return new ImgNum();
return imgOriginale.getSubimage(x, y, w, h);
}
// rogne la partie du format de la note
public Img rogneurFormatNote(BufferedImage imgOriginale)
public static Img rogneurFormatNote(BufferedImage imgOriginale)
{
// A FAIRE
//return new ImgNum();
return imgOriginale.getSubimage(x, y, w, h);
}
}

10
NGCC/src/ocr/diag.ucls Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.2.3" icons="true" always-add-relationships="false" generalizations="true" realizations="true"
associations="true" dependencies="false" nesting-relationships="true">
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>