From 84c9cdbbce1779a5001c90088b043be4999ec2a1 Mon Sep 17 00:00:00 2001 From: nh805942 Date: Thu, 10 Oct 2019 20:50:08 +0200 Subject: [PATCH 1/4] =?UTF-8?q?n=C2=B0=20->=20numero?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ocr/PdfToImage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ocr/PdfToImage.java b/src/ocr/PdfToImage.java index ad08b33..71d1e94 100644 --- a/src/ocr/PdfToImage.java +++ b/src/ocr/PdfToImage.java @@ -86,7 +86,7 @@ public class PdfToImage { // noir et // blanc images.add(bim); - System.out.println("Ajout n°" + pageCounter); + System.out.println("Ajout numero" + pageCounter); } document.close(); } catch (IOException ioe) { From ac4a85295b8e70f738e4b29519fd9f5347ae61b6 Mon Sep 17 00:00:00 2001 From: ce806665 Date: Thu, 10 Oct 2019 21:00:02 +0200 Subject: [PATCH 2/4] ajout detection mauvais sens recadrage.java --- src/lecturePdf/Recadrage.java | 96 +++++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/src/lecturePdf/Recadrage.java b/src/lecturePdf/Recadrage.java index 5647497..dae81d4 100644 --- a/src/lecturePdf/Recadrage.java +++ b/src/lecturePdf/Recadrage.java @@ -1,5 +1,7 @@ package lecturePdf; + + import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; @@ -17,12 +19,11 @@ import javax.imageio.ImageIO; -public class Recadrage { +public class Recadrage { String dir=""; String filename=""; BufferedImage img; - public Recadrage(String directory,String file) { dir=directory; filename=file; @@ -40,7 +41,7 @@ public class Recadrage { public Recadrage(){ } - public boolean estDroite() { //determine si l'image png/jpg du pdf est droite (doit etre en noir et blanc) + public boolean estDroite1() { //determine si l'image png/jpg du pdf est droite (doit etre en noir et blanc) int count=0; boolean stop=false; for (int ty=0; ty<100 && !stop;ty++) { @@ -57,6 +58,77 @@ public class Recadrage { return true; return false; } + + + + public boolean estDroite(){ + int count=0; + boolean stop=false; + for (int ty=0; ty<100 && !stop;ty++) { + for (int tx=0;tximg.getWidth()/5.4 && count img.getHeight()*0.1) + stop=true; + } + if (entreeEnvers()) + this.img=Recadrage2.rotate(img, 180); + return false; + } + + public boolean aLEnvers() { + boolean stop2=false; + int count=0; + for (int ty2=img.getHeight()-100; ty2img.getWidth()/5.4 && count img.getHeight()*0.1) + stop2=true; + } + return false; + } + + public boolean entreeEnvers() { + boolean stop2=false; + int count=0; + int maxwid=img.getWidth(); + for (int ty2=img.getHeight()-100; ty2img.getHeight()*0.1) + stop2=true; + + } + if (countimg.getHeight())py=img.getHeight()-1; + if(py>=img.getHeight())py=img.getHeight()-1; if(px<0)px=0; - if (px>img.getWidth())px=img.getWidth()-1; + if (px>=img.getWidth())px=img.getWidth()-1; + //System.out.println("px ="+px+" /"+img.getWidth()); + //System.out.println("py ="+py+" /"+img.getHeight()); tmp=new Color(img.getRGB(px, py)); if (tmp.getGreen()>20) { //si pixel == blanc return false; @@ -270,7 +346,7 @@ public class Recadrage { double dadj=Math.sqrt(Math.pow(xb-pointx, 2)+Math.pow(yb-pointy, 2)); //adjacent / rapport a xb,yb - System.out.println("dadj "+dadj + " dhypo "+dhypo); + //System.out.println("dadj "+dadj + " dhypo "+dhypo); if (dhypo Date: Thu, 10 Oct 2019 21:01:35 +0200 Subject: [PATCH 3/4] Update Recadrage.java --- src/lecturePdf/Recadrage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lecturePdf/Recadrage.java b/src/lecturePdf/Recadrage.java index dae81d4..327e5b1 100644 --- a/src/lecturePdf/Recadrage.java +++ b/src/lecturePdf/Recadrage.java @@ -140,7 +140,7 @@ public class Recadrage { public BufferedImage automation() throws IOException { - if (!this.estDroite2()) { + if (!this.estDroite()) { int[][] points=RdB(); double angle=getAngle(points); From 25139d4a939cb3581280f10862dc99ce3e557fae Mon Sep 17 00:00:00 2001 From: ce806665 Date: Thu, 10 Oct 2019 21:02:33 +0200 Subject: [PATCH 4/4] Update Recadrage.java --- src/lecturePdf/Recadrage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lecturePdf/Recadrage.java b/src/lecturePdf/Recadrage.java index 327e5b1..168303b 100644 --- a/src/lecturePdf/Recadrage.java +++ b/src/lecturePdf/Recadrage.java @@ -79,7 +79,7 @@ public class Recadrage { stop=true; } if (entreeEnvers()) - this.img=Recadrage2.rotate(img, 180); + this.img=Recadrage.rotate(img, 180); return false; } @@ -146,7 +146,7 @@ public class Recadrage { img=rotate(img,angle); if (aLEnvers()) - this.img=Recadrage2.rotate(img, 180); + this.img=Recadrage.rotate(img, 180); String nomImage="sortie"; File nomfichier = new File("C:\\Users\\Xxsafirex\\Desktop\\Image\\" + nomImage + ".jpg");// ou jpg ImageIO.write(img, "JPG", nomfichier);//ou JPG