summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlisaLinUwU <alisalinuwu@gmail.com>2025-01-26 11:44:59 +0500
committerAlisaLinUwU <alisalinuwu@gmail.com>2025-01-26 11:44:59 +0500
commit7b8c476700f995c81a43ec46a14efdb42ea11b32 (patch)
tree3667f55209aa0dc50b46342b336f71ddc7aac883 /src
Initializemain
Diffstat (limited to 'src')
-rw-r--r--src/main/java/info/selflearner/ocr/OcrApplication.java13
-rw-r--r--src/main/java/info/selflearner/ocr/config/AppConfig.java13
-rw-r--r--src/main/java/info/selflearner/ocr/config/MainWebAppInitializer.java27
-rw-r--r--src/main/java/info/selflearner/ocr/config/ThymeleafConfiguration.java25
-rw-r--r--src/main/java/info/selflearner/ocr/controller/ApiController.java80
-rw-r--r--src/main/java/info/selflearner/ocr/model/Passport.java69
-rw-r--r--src/main/java/info/selflearner/ocr/util/Excel.java56
-rw-r--r--src/main/java/info/selflearner/ocr/util/OCR.java167
-rw-r--r--src/main/resources/META-INF/MANIFEST.MF3
-rw-r--r--src/main/resources/application.properties3
-rw-r--r--src/main/resources/templates/index.html172
-rw-r--r--src/main/resources/tessdata/configs/alto1
-rw-r--r--src/main/resources/tessdata/configs/ambigs.train7
-rw-r--r--src/main/resources/tessdata/configs/api_config1
-rw-r--r--src/main/resources/tessdata/configs/bigram5
-rw-r--r--src/main/resources/tessdata/configs/box.train12
-rw-r--r--src/main/resources/tessdata/configs/box.train.stderr13
-rw-r--r--src/main/resources/tessdata/configs/digits1
-rw-r--r--src/main/resources/tessdata/configs/get.images1
-rw-r--r--src/main/resources/tessdata/configs/hocr2
-rw-r--r--src/main/resources/tessdata/configs/inter2
-rw-r--r--src/main/resources/tessdata/configs/kannada4
-rw-r--r--src/main/resources/tessdata/configs/linebox2
-rw-r--r--src/main/resources/tessdata/configs/logfile1
-rw-r--r--src/main/resources/tessdata/configs/lstm.train11
-rw-r--r--src/main/resources/tessdata/configs/lstmbox1
-rw-r--r--src/main/resources/tessdata/configs/lstmdebug4
-rw-r--r--src/main/resources/tessdata/configs/makebox1
-rw-r--r--src/main/resources/tessdata/configs/page3
-rw-r--r--src/main/resources/tessdata/configs/pdf1
-rw-r--r--src/main/resources/tessdata/configs/quiet1
-rw-r--r--src/main/resources/tessdata/configs/rebox2
-rw-r--r--src/main/resources/tessdata/configs/strokewidth12
-rw-r--r--src/main/resources/tessdata/configs/tsv1
-rw-r--r--src/main/resources/tessdata/configs/txt3
-rw-r--r--src/main/resources/tessdata/configs/unlv2
-rw-r--r--src/main/resources/tessdata/configs/wordstrbox1
-rw-r--r--src/main/resources/tessdata/eng.traineddatabin0 -> 23466654 bytes
-rw-r--r--src/main/resources/tessdata/osd.traineddatabin0 -> 10562874 bytes
-rw-r--r--src/main/resources/tessdata/pdf.ttfbin0 -> 572 bytes
-rw-r--r--src/main/resources/tessdata/rus.traineddatabin0 -> 19920885 bytes
-rw-r--r--src/main/resources/tessdata/tessconfigs/batch1
-rw-r--r--src/main/resources/tessdata/tessconfigs/batch.nochop2
-rw-r--r--src/main/resources/tessdata/tessconfigs/matdemo7
-rw-r--r--src/main/resources/tessdata/tessconfigs/msdemo12
-rw-r--r--src/main/resources/tessdata/tessconfigs/nobatch1
-rw-r--r--src/main/resources/tessdata/tessconfigs/segdemo9
-rw-r--r--src/main/resources/tessdata/uzb.traineddatabin0 -> 10757098 bytes
-rw-r--r--src/main/resources/tessdata/uzb_cyrl.traineddatabin0 -> 4905658 bytes
-rw-r--r--src/test/java/info/selflearner/ocr/OcrApplicationTests.java13
50 files changed, 768 insertions, 0 deletions
diff --git a/src/main/java/info/selflearner/ocr/OcrApplication.java b/src/main/java/info/selflearner/ocr/OcrApplication.java
new file mode 100644
index 0000000..527cdf9
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/OcrApplication.java
@@ -0,0 +1,13 @@
+package info.selflearner.ocr;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class OcrApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(OcrApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/info/selflearner/ocr/config/AppConfig.java b/src/main/java/info/selflearner/ocr/config/AppConfig.java
new file mode 100644
index 0000000..b26cf27
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/config/AppConfig.java
@@ -0,0 +1,13 @@
+package info.selflearner.ocr.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.multipart.support.StandardServletMultipartResolver;
+
+@Configuration
+public class AppConfig {
+ @Bean
+ public StandardServletMultipartResolver multipartResolver() {
+ return new StandardServletMultipartResolver();
+ }
+}
diff --git a/src/main/java/info/selflearner/ocr/config/MainWebAppInitializer.java b/src/main/java/info/selflearner/ocr/config/MainWebAppInitializer.java
new file mode 100644
index 0000000..ea74ca7
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/config/MainWebAppInitializer.java
@@ -0,0 +1,27 @@
+package info.selflearner.ocr.config;
+
+import jakarta.servlet.MultipartConfigElement;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.ServletRegistration;
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.support.GenericWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+public class MainWebAppInitializer implements WebApplicationInitializer {
+
+ private static final String TMP_FOLDER = System.getProperty("java.io.tmpdir");
+ private static final int MAX_UPLOAD_SIZE = 5 * 1024 * 1024;
+
+ @Override
+ public void onStartup(ServletContext sc) {
+ ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(
+ new GenericWebApplicationContext()));
+
+ appServlet.setLoadOnStartup(1);
+
+ MultipartConfigElement multipartConfigElement = new MultipartConfigElement(TMP_FOLDER,
+ MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2L, MAX_UPLOAD_SIZE / 2);
+
+ appServlet.setMultipartConfig(multipartConfigElement);
+ }
+}
diff --git a/src/main/java/info/selflearner/ocr/config/ThymeleafConfiguration.java b/src/main/java/info/selflearner/ocr/config/ThymeleafConfiguration.java
new file mode 100644
index 0000000..507e140
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/config/ThymeleafConfiguration.java
@@ -0,0 +1,25 @@
+package info.selflearner.ocr.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
+import org.thymeleaf.spring6.SpringTemplateEngine;
+import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
+
+@Configuration
+@EnableWebMvc
+public class ThymeleafConfiguration {
+ @Autowired
+ SpringResourceTemplateResolver springResourceTemplateResolver;
+
+ @Bean
+ public SpringTemplateEngine templateEngine() {
+ SpringTemplateEngine templateEngine = new SpringTemplateEngine();
+ templateEngine.addDialect(new Java8TimeDialect());
+ templateEngine.setTemplateResolver(springResourceTemplateResolver);
+ return templateEngine;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/info/selflearner/ocr/controller/ApiController.java b/src/main/java/info/selflearner/ocr/controller/ApiController.java
new file mode 100644
index 0000000..d3723ca
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/controller/ApiController.java
@@ -0,0 +1,80 @@
+package info.selflearner.ocr.controller;
+
+import info.selflearner.ocr.util.Excel;
+import info.selflearner.ocr.util.OCR;
+import info.selflearner.ocr.model.Passport;
+import net.sourceforge.tess4j.TesseractException;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import java.io.*;
+import java.util.ArrayList;
+
+@Controller
+public class ApiController {
+
+ @GetMapping("/")
+ public String index(Model model) {
+ String ocr = (String) model.asMap().get("ocr");
+ model.addAttribute("ocr", ocr);
+ return "index";
+ }
+
+ @PostMapping("/api/files")
+ public String files(@RequestParam("files") MultipartFile[] files, String eng, String rus, String uzb, String uzb_cyrl, String documentType, RedirectAttributes redirectAttributes) throws IOException {
+ ArrayList<String> ocrResults = new ArrayList<>();
+ ArrayList<Passport> passportArrayList = new ArrayList<>();
+ StringBuilder languages = new StringBuilder();
+
+ if ("other".equals(documentType)) {
+ if (eng != null) languages.append(eng).append("+");
+ if (rus != null) languages.append(rus).append("+");
+ if (uzb != null) languages.append(uzb).append("+");
+ if (uzb_cyrl != null) languages.append(uzb_cyrl).append("+");
+ languages.deleteCharAt(languages.toString().length() - 1);
+ }
+
+ for (MultipartFile file : files) {
+ File savedFile = new File(System.getProperty("java.io.tmpdir") + "/" + file.getOriginalFilename());
+ savedFile.createNewFile();
+ try (InputStream inputStream = file.getInputStream();
+ OutputStream outputStream = new FileOutputStream(savedFile)) {
+ int read;
+ byte[] bytes = new byte[1024];
+
+ while ((read = inputStream.read(bytes)) != -1) {
+ outputStream.write(bytes, 0, read);
+ }
+ if ("other".equals(documentType)) {
+ ocrResults.add(OCR.perform(savedFile, languages.toString()));
+ } else if ("passport".equals(documentType)) {
+ passportArrayList.add(OCR.performPassport(savedFile));
+ }
+ } catch (IOException | TesseractException | InterruptedException exception) {
+ throw new RuntimeException(exception);
+ }
+ }
+ if ("other".equals(documentType)) {
+ redirectAttributes.addFlashAttribute("ocrs", ocrResults);
+ } else if ("passport".equals(documentType)) {
+ redirectAttributes.addFlashAttribute("passports", passportArrayList);
+ Excel.write(passportArrayList);
+ }
+
+ return "redirect:/";
+ }
+
+ @GetMapping("/api/passport/excel")
+ @ResponseBody
+ public FileSystemResource downloadPassportExcel(@RequestParam(value = "filename") String filename) {
+ return new FileSystemResource(new File(System.getProperty("java.io.tmpdir") + "/" + filename));
+ }
+
+}
diff --git a/src/main/java/info/selflearner/ocr/model/Passport.java b/src/main/java/info/selflearner/ocr/model/Passport.java
new file mode 100644
index 0000000..8bd928f
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/model/Passport.java
@@ -0,0 +1,69 @@
+package info.selflearner.ocr.model;
+
+import java.time.LocalDate;
+
+public class Passport {
+ public char type;
+ public Character subtype;
+ public String issuer;
+ public String surname;
+ public String givenNames;
+ public String number;
+ public String nationality;
+ public LocalDate dateOfBirth;
+ public Character sex;
+ public LocalDate expirationDate;
+ public String personalNumber;
+ public int[] mrzLinesConfidence;
+
+ public Passport(char type, Character subtype, String issuer, String surname, String givenNames, String number, String nationality, LocalDate dateOfBirth, Character sex, LocalDate expirationDate, String personalNumber, int[] mrzLinesConfidence) {
+ this.type = type;
+ this.subtype = subtype;
+ this.issuer = issuer;
+ this.surname = surname;
+ this.givenNames = givenNames;
+ this.number = number;
+ this.nationality = nationality;
+ this.dateOfBirth = dateOfBirth;
+ this.sex = sex;
+ this.expirationDate = expirationDate;
+ this.personalNumber = personalNumber;
+ this.mrzLinesConfidence = mrzLinesConfidence;
+ }
+
+ public Passport(String[] mrzLines, int[] mrzLinesConfidence) {
+ this.type = mrzLines[0].charAt(0);
+ this.subtype = mrzLines[0].charAt(1) == '<' ? null : mrzLines[0].charAt(0);
+ this.issuer = mrzLines[0].substring(2, 5);
+ this.surname = mrzLines[0].substring(5, mrzLines[0].indexOf('<', 6));
+ this.givenNames = mrzLines[0].substring(surname.length() + 7, mrzLines[0].indexOf('<', surname.length() + 8));
+ this.number = mrzLines[1].substring(0, 9);
+ this.nationality = mrzLines[1].substring(10, 13);
+ if (Integer.parseInt("20" + mrzLines[1].substring(13, 15)) < LocalDate.now().getYear()) {
+ this.dateOfBirth = LocalDate.of(Integer.parseInt("20" + mrzLines[1].substring(13, 15)), Integer.parseInt(mrzLines[1].substring(15, 17)), Integer.parseInt(mrzLines[1].substring(17, 19)));
+ } else {
+ this.dateOfBirth = LocalDate.of(Integer.parseInt("19" + mrzLines[1].substring(13, 15)), Integer.parseInt(mrzLines[1].substring(15, 17)), Integer.parseInt(mrzLines[1].substring(17, 19)));
+ }
+ this.sex = mrzLines[1].charAt(20) != '<' ? mrzLines[1].charAt(20) : null;
+ this.expirationDate = LocalDate.of(Integer.parseInt("20" + mrzLines[1].substring(21, 23)), Integer.parseInt(mrzLines[1].substring(23, 25)), Integer.parseInt(mrzLines[1].substring(25, 27)));
+ this.personalNumber = mrzLines[1].substring(28, 42);
+ this.mrzLinesConfidence = mrzLinesConfidence;
+ }
+
+ @Override
+ public String toString() {
+ return "Passport{" +
+ "type=" + type +
+ ", subtype=" + subtype +
+ ", issuer='" + issuer + '\'' +
+ ", surname='" + surname + '\'' +
+ ", givenNames='" + givenNames + '\'' +
+ ", number='" + number + '\'' +
+ ", nationality='" + nationality + '\'' +
+ ", dateOfBirth=" + dateOfBirth +
+ ", sex=" + sex +
+ ", expirationDate=" + expirationDate +
+ ", personalNumber='" + personalNumber + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/info/selflearner/ocr/util/Excel.java b/src/main/java/info/selflearner/ocr/util/Excel.java
new file mode 100644
index 0000000..d924aaa
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/util/Excel.java
@@ -0,0 +1,56 @@
+package info.selflearner.ocr.util;
+
+import info.selflearner.ocr.model.Passport;
+import org.dhatim.fastexcel.Workbook;
+import org.dhatim.fastexcel.Worksheet;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.Optional;
+
+public class Excel {
+ public static void write(List<Passport> passportList) throws IOException {
+ String filePath = System.getProperty("java.io.tmpdir") + "/Dokumentlar.xlsx";
+
+ try (OutputStream os = Files.newOutputStream(Paths.get(filePath)); Workbook wb = new Workbook(os, "OCR web", "1.0")) {
+ Worksheet worksheet = wb.newWorksheet("Dokumentlar");
+ worksheet.width(0, 25);
+ worksheet.width(1, 15);
+
+ worksheet.range(0, 0, 0, 12).style().bold().set();
+ worksheet.value(0, 0, "1-inchi turi");
+ worksheet.value(0, 1, "2-inchi turi");
+ worksheet.value(0, 2, "Bergan davlat/firma");
+ worksheet.value(0, 3, "Familiyasi");
+ worksheet.value(0, 4, "Ismi(-lari)");
+ worksheet.value(0, 5, "Pasport raqami");
+ worksheet.value(0, 6, "Fuqaroligi");
+ worksheet.value(0, 7, "Tug'ilgan sanasi");
+ worksheet.value(0, 8, "Jinsi");
+ worksheet.value(0, 9, "Amal qilish muddati");
+ worksheet.value(0, 10, "JSHSHIR");
+ worksheet.value(0, 11, "MRZ 1-inchi qatorining ishonchlilik darajasi");
+ worksheet.value(0, 12, "MRZ 2-inchi qatorining ishonchlilik darajasi");
+
+ for (int i = 0; i < passportList.size(); i++) {
+ worksheet.value(i + 1, 0, String.valueOf(passportList.get(i).type));
+ worksheet.value(i + 1, 1, String.valueOf(Optional.ofNullable(passportList.get(i).subtype).orElse(' ')));
+ worksheet.value(i + 1, 2, passportList.get(i).issuer);
+ worksheet.value(i + 1, 3, passportList.get(i).surname);
+ worksheet.value(i + 1, 4, passportList.get(i).givenNames);
+ worksheet.value(i + 1, 5, passportList.get(i).number);
+ worksheet.value(i + 1, 6, passportList.get(i).nationality);
+ worksheet.value(i + 1, 7, DateTimeFormatter.ofPattern("dd.MM.yyyy").format(passportList.get(i).dateOfBirth));
+ worksheet.value(i + 1, 8, String.valueOf(passportList.get(i).sex));
+ worksheet.value(i + 1, 9, DateTimeFormatter.ofPattern("dd.MM.yyyy").format(passportList.get(i).expirationDate));
+ worksheet.value(i + 1, 10, passportList.get(i).personalNumber);
+ worksheet.value(i + 1, 11, passportList.get(i).mrzLinesConfidence[0] + "%");
+ worksheet.value(i + 1, 12, passportList.get(i).mrzLinesConfidence[1] + "%");
+ }
+ }
+ }
+}
diff --git a/src/main/java/info/selflearner/ocr/util/OCR.java b/src/main/java/info/selflearner/ocr/util/OCR.java
new file mode 100644
index 0000000..1999cd9
--- /dev/null
+++ b/src/main/java/info/selflearner/ocr/util/OCR.java
@@ -0,0 +1,167 @@
+package info.selflearner.ocr.util;
+
+import cn.easyproject.easyocr.EasyOCR;
+import info.selflearner.ocr.model.Passport;
+import net.sourceforge.tess4j.*;
+import net.sourceforge.tess4j.util.LoadLibs;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class OCR {
+ private static final ITesseract TESSERACT = new Tesseract();
+ private static final EasyOCR EASY_OCR = new EasyOCR();
+
+ static {
+ TESSERACT.setDatapath("src/main/resources/tessdata/");
+ TESSERACT.setVariable("user_defined_dpi", "300");
+ System.setProperty("java.library.path", LoadLibs.extractTessResources("win32-x86-64").getPath());
+ }
+
+ public static String perform(File file, String languages) throws TesseractException {
+ TESSERACT.setLanguage(languages);
+ String ocrResult = TESSERACT.doOCR(file);
+ file.delete();
+ return ocrResult;
+ }
+
+ public static Passport performPassport(File file) throws IOException, InterruptedException {
+ for (int imageRotateAngle = 0; imageRotateAngle <= 270; imageRotateAngle += 90) {
+ if (imageRotateAngle == 90) {
+ System.out.println("Rotating image to 90 degrees...");
+ rotateImageVertically(file, true);
+ } else if (imageRotateAngle == 180) {
+ System.out.println("Rotating image to 180 degrees...");
+ rotateImageHorizontally(file);
+ } else if (imageRotateAngle == 270) {
+ System.out.println("Rotating image to 270 degrees...");
+ rotateImageVertically(file, false);
+ }
+
+ Runtime.getRuntime().exec(new String[]{"surya_ocr", file.getPath(), "--results_dir", System.getProperty("java.io.tmpdir"), "--langs=en"}).waitFor();
+ JSONArray jsonTextLines = new JSONObject(Files.readAllLines(Path.of(System.getProperty("java.io.tmpdir"), "/", file.getName().split("\\.")[0], "/results.json")).getFirst())
+ .getJSONArray(file.getName().split("\\.")[0]).getJSONObject(0).getJSONArray("text_lines");
+ int mrzStartingIndex = -1;
+
+ for (int arrayIndex = 0; arrayIndex < jsonTextLines.length() && mrzStartingIndex == -1; arrayIndex++) {
+ if (jsonTextLines.getJSONObject(arrayIndex).getString("text").indexOf("P<") == 0) {
+ mrzStartingIndex = arrayIndex;
+ }
+ }
+
+ if (mrzStartingIndex != -1) {
+ System.out.println("MRZ1: " + jsonTextLines.getJSONObject(mrzStartingIndex).getString("text"));
+ System.out.println("MRZ2: " + jsonTextLines.getJSONObject(mrzStartingIndex + 1).getString("text"));
+ try {
+ return new Passport(new String[]{jsonTextLines.getJSONObject(mrzStartingIndex).getString("text"), jsonTextLines.getJSONObject(mrzStartingIndex + 1).getString("text")},
+ new int[]{(int) (jsonTextLines.getJSONObject(mrzStartingIndex).getDouble("confidence") * 100), (int) (jsonTextLines.getJSONObject(mrzStartingIndex + 1).getDouble("confidence") * 100)});
+ } catch (Exception _) {
+
+ }
+ }
+ }
+ throw new IOException("Passport not found");
+ }
+
+ private static void rotateImageVertically(File image, boolean counterClockwise) throws IOException {
+ BufferedImage bufferedImage = ImageIO.read(image);
+ BufferedImage output = new BufferedImage(bufferedImage.getHeight(), bufferedImage.getWidth(), bufferedImage.getType());
+
+ AffineTransform affineTransform = getAffineTransform(counterClockwise, bufferedImage);
+
+ AffineTransformOp affineTransformOp = new AffineTransformOp(affineTransform, AffineTransformOp.TYPE_BILINEAR);
+ affineTransformOp.filter(bufferedImage, output);
+
+ ImageIO.write(output, "jpg", image);
+ }
+
+ public static void rotateImageHorizontally(File image) throws IOException {
+ BufferedImage imageToRotate = ImageIO.read(image);
+
+ int widthOfImage = imageToRotate.getWidth();
+ int heightOfImage = imageToRotate.getHeight();
+ int typeOfImage = imageToRotate.getType();
+
+ BufferedImage output = new BufferedImage(widthOfImage, heightOfImage, typeOfImage);
+
+ Graphics2D graphics2D = output.createGraphics();
+
+ graphics2D.rotate(Math.toRadians(180), widthOfImage / 2.0, heightOfImage / 2.0);
+ graphics2D.drawImage(imageToRotate, null, 0, 0);
+
+ ImageIO.write(output, "jpg", image);
+ }
+
+ private static AffineTransform getAffineTransform(boolean counterClockwise, BufferedImage bufferedImage) {
+ int imageWidth = bufferedImage.getWidth();
+ int imageHeight = bufferedImage.getHeight();
+
+ AffineTransform affineTransform = new AffineTransform();
+ affineTransform.rotate((!counterClockwise ? Math.PI : -Math.PI) / 2, imageWidth / 2.0, imageHeight / 2.0);
+
+ double offset = (imageWidth - imageHeight) / 2.0;
+ if (!counterClockwise) {
+ affineTransform.translate(offset, offset);
+ } else {
+ affineTransform.translate(-offset, -offset);
+ }
+ return affineTransform;
+ }
+
+// public static Passport performPassport(File file) throws TesseractException, IOException {
+// TESSERACT.setLanguage("eng");
+//
+// for (int i = 0; i < 4; i++) {
+// String ocrResult = null;
+//
+// switch (i) {
+// case 0 -> ocrResult = TESSERACT.doOCR(file);
+// case 1 -> ocrResult = EASY_OCR.discern(file);
+// case 2 -> ocrResult = EASY_OCR.discernAndAutoCleanImage(file, ImageType.CAPTCHA_INTERFERENCE_LINE);
+// }
+//
+// for (double imageWidthRatio = 0.8; imageWidthRatio <= 1.6; imageWidthRatio += 0.2) {
+// for (double imageHeightRatio = 0.8; imageHeightRatio <= 1.6; imageHeightRatio += 0.2) {
+// if (i == 3) {
+// ocrResult = EASY_OCR.discernAndAutoCleanImage(file, ImageType.CAPTCHA_NORMAL, imageWidthRatio, imageHeightRatio);
+// System.out.println("imageWidthRatio: " + imageWidthRatio + ", imageHeightRatio: " + imageHeightRatio);
+// }
+//
+// int mrzStartingIndex = ocrResult.indexOf("P<");
+//
+// if (mrzStartingIndex != -1 && mrzStartingIndex + 89 <= ocrResult.length()) {
+// String[] mrz = ocrResult.substring(mrzStartingIndex, mrzStartingIndex + 89).split("\n");
+//
+// if (mrz[0].length() >= 44 && mrz[1].length() >= 44) {
+// System.out.println("mrz: " + Arrays.toString(mrz));
+// Passport passport;
+//
+// try {
+// passport = new Passport(mrz);
+// } catch (StringIndexOutOfBoundsException | NumberFormatException exception) {
+// continue;
+// }
+//
+// return passport;
+// }
+// }
+//
+// if (i != 3) break;
+// }
+// if (i != 3) break;
+// }
+// }
+//
+// throw new IOException("Passport not found");
+// }
+
+}
diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..b9ceb2b
--- /dev/null
+++ b/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: info.selflearner.ocr.OcrApplication
+
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
new file mode 100644
index 0000000..6e2fc3b
--- /dev/null
+++ b/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+spring.application.name=ocr
+spring.servlet.multipart.max-file-size=50MB
+spring.servlet.multipart.max-request-size=50MB
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
new file mode 100644
index 0000000..9d63f8b
--- /dev/null
+++ b/src/main/resources/templates/index.html
@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>OCR</title>
+ <style>
+ button { display: none}
+
+ #passport:checked ~ #rus {
+ display: none;
+ }
+ </style>
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
+</head>
+<body>
+ <div class="container col-xl-12 col-xxl-8 px-4 py-5">
+ <div class="form-group mx-sm-3 mb-2 p-md-5 border rounded-3 bg-body-tertiary" th:each="passport, iStat: ${passports}">
+ <div class="form-group row mb-2" th:if="${passport.subtype}">
+ <label th:for="passportSubType + ${iStat.index}" class="col-sm-2 col-form-label">Pasport turi:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportSubtype + ${iStat.index}" th:id="passportSubtype + ${iStat.index}" th:value="|${passport.subtype}|" th:onclick="'copyToClipboard(\'passportSubtype' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[0]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportIssuer + ${iStat.index}" class="col-sm-2 col-form-label">Bergan davlat/firma:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportIssuer + ${iStat.index}" th:id="passportIssuer + ${iStat.index}" th:value="|${passport.issuer}|" th:onclick="'copyToClipboard(\'passportIssuer' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[0]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportSurname + ${iStat.index}" class="col-sm-2 col-form-label">Familiyasi:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportSurname + ${iStat.index}" th:id="passportSurname + ${iStat.index}" th:value="|${passport.surname}|" th:onclick="'copyToClipboard(\'passportSurname' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[0]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportGivenNames + ${iStat.index}" class="col-sm-2 col-form-label">Ismi(-lari):</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportGivenNames + ${iStat.index}" th:id="passportGivenNames + ${iStat.index}" th:value="|${passport.givenNames}|" th:onclick="'copyToClipboard(\'passportGivenNames' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[0]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportNumber + ${iStat.index}" class="col-sm-2 col-form-label">Pasport raqami:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportNumber + ${iStat.index}" th:id="passportNumber + ${iStat.index}" th:value="|${passport.number}|" th:onclick="'copyToClipboard(\'passportNumber' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[1]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportNationality + ${iStat.index}" class="col-sm-2 col-form-label">Fuqaroligi:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportNationality + ${iStat.index}" th:id="passportNationality + ${iStat.index}" th:value="|${passport.nationality}|" th:onclick="'copyToClipboard(\'passportNationality' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[1]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportDateOfBirth + ${iStat.index}" class="col-sm-2 col-form-label">Tug'ilgan sanasi:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportDateOfBirth + ${iStat.index}" th:id="passportDateOfBirth + ${iStat.index}" th:value="|${#temporals.format(passport.dateOfBirth, 'dd.MM.yyyy')}|" th:onclick="'copyToClipboard(\'passportDateOfBirth' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[1]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportSex + ${iStat.index}" class="col-sm-2 col-form-label">Jinsi:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportSex + ${iStat.index}" th:id="passportSex + ${iStat.index}" th:value="|${passport.sex}|" th:onclick="'copyToClipboard(\'passportSex' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[1]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-2">
+ <label th:for="passportExpirationDate + ${iStat.index}" class="col-sm-2 col-form-label">Amal qilish muddati:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportExpirationDate + ${iStat.index}" th:id="passportExpirationDate + ${iStat.index}" th:value="|${#temporals.format(passport.expirationDate, 'dd.MM.yyyy')}|" th:onclick="'copyToClipboard(\'passportExpirationDate' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[1]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ <div class="form-group row mb-3">
+ <label th:for="passportPersonalNumber + ${iStat.index}" class="col-sm-2 col-form-label">JSHSHIR:</label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" th:name="passportPersonalNumber + ${iStat.index}" th:id="passportPersonalNumber + ${iStat.index}" th:value="|${passport.personalNumber}|" th:onclick="'copyToClipboard(\'passportPersonalNumber' + ${iStat.index} + '\')'" readonly>
+ </div>
+ <div class="col-sm-1 text-center my-auto" th:text="|(${passport.mrzLinesConfidence[1]}%)|" data-toggle="tooltip" data-placement="top" title="Ishonchlilik darajasi"></div>
+ </div>
+ </div>
+ <a th:href="@{|/api/passport/excel?filename=Dokumentlar.xlsx|}" th:download="|Dokumentlar.xlsx|" th:if="${passports}">
+ <button class="btn btn-lg btn-success mx-sm-3" type="submit">Excel</button>
+ </a>
+ <div class="col-lg-12 text-lg-start" th:each="ocr, iStat: ${ocrs}">
+ <textarea class="form-control mt-3 fs-4 p-4 p-md-5 border rounded-3 bg-body-tertiary" th:name="text + ${iStat.index}" th:id="text + ${iStat.index}" rows="10" th:text="|${ocr}|" readonly></textarea>
+ <button class="mt-2 w-20 btn btn-lg btn-secondary" th:onclick="'copyToClipboard(\'text' + ${iStat.index} + '\')'">Nusxa olish</button>
+ </div>
+ <div class="col-md-10 mx-auto col-lg-5 mt-5">
+ <form class="p-4 p-md-5 border rounded-3 bg-body-tertiary" action="/api/files" method="post" enctype="multipart/form-data">
+ <div class="form-floating mb-3">
+ <input type="file" class="form-control" id="files" name="files" multiple>
+ <label for="files">Fayllar</label>
+ </div>
+ <p>Tilni(-larni) tanlang:</p>
+ <div class="form-check form-check-inline mb-3">
+ <input class="form-check-input" type="checkbox" id="eng" name="eng" value="eng" checked>
+ <label class="form-check-label" for="eng">Ingliz</label>
+ </div>
+ <div class="form-check form-check-inline mb-3">
+ <input class="form-check-input" type="checkbox" id="rus" name="rus" value="rus" checked>
+ <label class="form-check-label" for="rus">Rus</label>
+ </div>
+ <div class="form-check form-check-inline mb-3">
+ <input class="form-check-input" type="checkbox" id="uzb" name="uzb" value="uzb" checked>
+ <label class="form-check-label" for="uzb">Uzbek</label>
+ </div>
+ <div class="form-check form-check-inline mb-3">
+ <input class="form-check-input" type="checkbox" id="uzb_cyrl" name="uzb_cyrl" value="uzb_cyrl" checked>
+ <label class="form-check-label" for="uzb_cyrl">Uzbek (kirilcha)</label>
+ </div>
+ <p>Dokumen turini tanlang:</p>
+ <div class="form-check form-check-inline mb-3">
+ <input class="form-check-input" type="radio" id="other" name="documentType" value="other" onclick="enableAllLanguages()" checked>
+ <label class="form-check-label" for="other">Boshqa</label>
+ </div>
+ <div class="form-check form-check-inline mb-3">
+ <input class="form-check-input" type="radio" id="passport" name="documentType" value="passport" onclick="disableAllLanguages()">
+ <label class="form-check-label" for="passport">Pasport</label>
+ </div>
+ <button class="w-100 btn btn-lg btn-primary" type="submit">Yuborish</button>
+ </form>
+ </div>
+ </div>
+ <script>
+ function copyToClipboard(id) {
+ var text = document.getElementById(id);
+
+ text.select();
+ text.setSelectionRange(0, 99999); // For mobile devices
+
+ navigator.clipboard.writeText(text.value);
+
+ alert("Nusxa olindi!");
+ }
+
+ function disableAllLanguages() {
+ document.getElementById("eng").disabled = true;
+ document.getElementById("rus").disabled = true;
+ document.getElementById("uzb").disabled = true;
+ document.getElementById("uzb_cyrl").disabled = true;
+ }
+
+ function enableAllLanguages() {
+ document.getElementById("eng").disabled = false;
+ document.getElementById("rus").disabled = false;
+ document.getElementById("uzb").disabled = false;
+ document.getElementById("uzb_cyrl").disabled = false;
+ }
+
+ if (document.getElementById('other').checked) {
+ document.getElementById("eng").disabled = false;
+ document.getElementById("rus").disabled = false;
+ document.getElementById("uzb").disabled = false;
+ document.getElementById("uzb_cyrl").disabled = false;
+ } else if (document.getElementById('passport').checked) {
+ document.getElementById("eng").disabled = true;
+ document.getElementById("rus").disabled = true;
+ document.getElementById("uzb").disabled = true;
+ document.getElementById("uzb_cyrl").disabled = true;
+ }
+ </script>
+</body>
+</html> \ No newline at end of file
diff --git a/src/main/resources/tessdata/configs/alto b/src/main/resources/tessdata/configs/alto
new file mode 100644
index 0000000..0dd12a7
--- /dev/null
+++ b/src/main/resources/tessdata/configs/alto
@@ -0,0 +1 @@
+tessedit_create_alto 1
diff --git a/src/main/resources/tessdata/configs/ambigs.train b/src/main/resources/tessdata/configs/ambigs.train
new file mode 100644
index 0000000..23035a1
--- /dev/null
+++ b/src/main/resources/tessdata/configs/ambigs.train
@@ -0,0 +1,7 @@
+tessedit_ambigs_training 1
+load_freq_dawg 0
+load_punc_dawg 0
+load_system_dawg 0
+load_number_dawg 0
+ambigs_debug_level 3
+load_fixed_length_dawgs 0
diff --git a/src/main/resources/tessdata/configs/api_config b/src/main/resources/tessdata/configs/api_config
new file mode 100644
index 0000000..5cd6ec0
--- /dev/null
+++ b/src/main/resources/tessdata/configs/api_config
@@ -0,0 +1 @@
+tessedit_zero_rejection T
diff --git a/src/main/resources/tessdata/configs/bigram b/src/main/resources/tessdata/configs/bigram
new file mode 100644
index 0000000..5d6c2d0
--- /dev/null
+++ b/src/main/resources/tessdata/configs/bigram
@@ -0,0 +1,5 @@
+load_bigram_dawg True
+tessedit_enable_bigram_correction True
+tessedit_bigram_debug 3
+save_raw_choices True
+save_alt_choices True
diff --git a/src/main/resources/tessdata/configs/box.train b/src/main/resources/tessdata/configs/box.train
new file mode 100644
index 0000000..d39f268
--- /dev/null
+++ b/src/main/resources/tessdata/configs/box.train
@@ -0,0 +1,12 @@
+disable_character_fragments T
+file_type .bl
+textord_fast_pitch_test T
+tessedit_zero_rejection T
+tessedit_minimal_rejection F
+tessedit_write_rep_codes F
+edges_children_fix F
+edges_childarea 0.65
+edges_boxarea 0.9
+tessedit_resegment_from_boxes T
+tessedit_train_from_boxes T
+textord_no_rejects T
diff --git a/src/main/resources/tessdata/configs/box.train.stderr b/src/main/resources/tessdata/configs/box.train.stderr
new file mode 100644
index 0000000..82754e9
--- /dev/null
+++ b/src/main/resources/tessdata/configs/box.train.stderr
@@ -0,0 +1,13 @@
+file_type .bl
+#tessedit_use_nn F
+textord_fast_pitch_test T
+tessedit_zero_rejection T
+tessedit_minimal_rejection F
+tessedit_write_rep_codes F
+edges_children_fix F
+edges_childarea 0.65
+edges_boxarea 0.9
+tessedit_resegment_from_boxes T
+tessedit_train_from_boxes T
+#textord_repeat_extraction F
+textord_no_rejects T
diff --git a/src/main/resources/tessdata/configs/digits b/src/main/resources/tessdata/configs/digits
new file mode 100644
index 0000000..6a329f8
--- /dev/null
+++ b/src/main/resources/tessdata/configs/digits
@@ -0,0 +1 @@
+tessedit_char_whitelist 0123456789-.
diff --git a/src/main/resources/tessdata/configs/get.images b/src/main/resources/tessdata/configs/get.images
new file mode 100644
index 0000000..7d00b61
--- /dev/null
+++ b/src/main/resources/tessdata/configs/get.images
@@ -0,0 +1 @@
+tessedit_write_images T
diff --git a/src/main/resources/tessdata/configs/hocr b/src/main/resources/tessdata/configs/hocr
new file mode 100644
index 0000000..5ab372e
--- /dev/null
+++ b/src/main/resources/tessdata/configs/hocr
@@ -0,0 +1,2 @@
+tessedit_create_hocr 1
+hocr_font_info 0
diff --git a/src/main/resources/tessdata/configs/inter b/src/main/resources/tessdata/configs/inter
new file mode 100644
index 0000000..252f1a1
--- /dev/null
+++ b/src/main/resources/tessdata/configs/inter
@@ -0,0 +1,2 @@
+interactive_display_mode T
+tessedit_display_outwords T
diff --git a/src/main/resources/tessdata/configs/kannada b/src/main/resources/tessdata/configs/kannada
new file mode 100644
index 0000000..c6ac105
--- /dev/null
+++ b/src/main/resources/tessdata/configs/kannada
@@ -0,0 +1,4 @@
+textord_skewsmooth_offset 8
+textord_skewsmooth_offset2 8
+textord_merge_desc 0.5
+textord_no_rejects 1
diff --git a/src/main/resources/tessdata/configs/linebox b/src/main/resources/tessdata/configs/linebox
new file mode 100644
index 0000000..bd9c114
--- /dev/null
+++ b/src/main/resources/tessdata/configs/linebox
@@ -0,0 +1,2 @@
+tessedit_resegment_from_line_boxes 1
+tessedit_make_boxes_from_boxes 1
diff --git a/src/main/resources/tessdata/configs/logfile b/src/main/resources/tessdata/configs/logfile
new file mode 100644
index 0000000..a160f9b
--- /dev/null
+++ b/src/main/resources/tessdata/configs/logfile
@@ -0,0 +1 @@
+debug_file tesseract.log
diff --git a/src/main/resources/tessdata/configs/lstm.train b/src/main/resources/tessdata/configs/lstm.train
new file mode 100644
index 0000000..5ff3772
--- /dev/null
+++ b/src/main/resources/tessdata/configs/lstm.train
@@ -0,0 +1,11 @@
+file_type .bl
+textord_fast_pitch_test T
+tessedit_zero_rejection T
+tessedit_minimal_rejection F
+tessedit_write_rep_codes F
+edges_children_fix F
+edges_childarea 0.65
+edges_boxarea 0.9
+tessedit_train_line_recognizer T
+textord_no_rejects T
+tessedit_init_config_only T
diff --git a/src/main/resources/tessdata/configs/lstmbox b/src/main/resources/tessdata/configs/lstmbox
new file mode 100644
index 0000000..a6f2ced
--- /dev/null
+++ b/src/main/resources/tessdata/configs/lstmbox
@@ -0,0 +1 @@
+tessedit_create_lstmbox 1
diff --git a/src/main/resources/tessdata/configs/lstmdebug b/src/main/resources/tessdata/configs/lstmdebug
new file mode 100644
index 0000000..3fa3dee
--- /dev/null
+++ b/src/main/resources/tessdata/configs/lstmdebug
@@ -0,0 +1,4 @@
+stopper_debug_level 1
+classify_debug_level 1
+segsearch_debug_level 1
+language_model_debug_level 3
diff --git a/src/main/resources/tessdata/configs/makebox b/src/main/resources/tessdata/configs/makebox
new file mode 100644
index 0000000..3d90ac2
--- /dev/null
+++ b/src/main/resources/tessdata/configs/makebox
@@ -0,0 +1 @@
+tessedit_create_boxfile 1
diff --git a/src/main/resources/tessdata/configs/page b/src/main/resources/tessdata/configs/page
new file mode 100644
index 0000000..9928884
--- /dev/null
+++ b/src/main/resources/tessdata/configs/page
@@ -0,0 +1,3 @@
+tessedit_create_page_xml 1
+# page_xml_polygon 1
+# page_xml_level 0
diff --git a/src/main/resources/tessdata/configs/pdf b/src/main/resources/tessdata/configs/pdf
new file mode 100644
index 0000000..59645d7
--- /dev/null
+++ b/src/main/resources/tessdata/configs/pdf
@@ -0,0 +1 @@
+tessedit_create_pdf 1
diff --git a/src/main/resources/tessdata/configs/quiet b/src/main/resources/tessdata/configs/quiet
new file mode 100644
index 0000000..35b59a9
--- /dev/null
+++ b/src/main/resources/tessdata/configs/quiet
@@ -0,0 +1 @@
+debug_file /dev/null
diff --git a/src/main/resources/tessdata/configs/rebox b/src/main/resources/tessdata/configs/rebox
new file mode 100644
index 0000000..f8342b4
--- /dev/null
+++ b/src/main/resources/tessdata/configs/rebox
@@ -0,0 +1,2 @@
+tessedit_resegment_from_boxes 1
+tessedit_make_boxes_from_boxes 1
diff --git a/src/main/resources/tessdata/configs/strokewidth b/src/main/resources/tessdata/configs/strokewidth
new file mode 100644
index 0000000..e95b592
--- /dev/null
+++ b/src/main/resources/tessdata/configs/strokewidth
@@ -0,0 +1,12 @@
+textord_show_blobs 0
+textord_debug_tabfind 3
+textord_tabfind_show_partitions 1
+textord_tabfind_show_initial_partitions 1
+textord_tabfind_show_columns 1
+textord_tabfind_show_blocks 1
+textord_tabfind_show_initialtabs 1
+textord_tabfind_show_finaltabs 1
+textord_tabfind_show_strokewidths 1
+textord_tabfind_show_vlines 0
+textord_tabfind_show_images 1
+tessedit_dump_pageseg_images 0
diff --git a/src/main/resources/tessdata/configs/tsv b/src/main/resources/tessdata/configs/tsv
new file mode 100644
index 0000000..dc52478
--- /dev/null
+++ b/src/main/resources/tessdata/configs/tsv
@@ -0,0 +1 @@
+tessedit_create_tsv 1
diff --git a/src/main/resources/tessdata/configs/txt b/src/main/resources/tessdata/configs/txt
new file mode 100644
index 0000000..a0cc952
--- /dev/null
+++ b/src/main/resources/tessdata/configs/txt
@@ -0,0 +1,3 @@
+# This config file should be used with other config files which create renderers.
+# usage example: tesseract eurotext.tif eurotext txt hocr pdf
+tessedit_create_txt 1
diff --git a/src/main/resources/tessdata/configs/unlv b/src/main/resources/tessdata/configs/unlv
new file mode 100644
index 0000000..d2e22f5
--- /dev/null
+++ b/src/main/resources/tessdata/configs/unlv
@@ -0,0 +1,2 @@
+tessedit_write_unlv 1
+unlv_tilde_crunching T
diff --git a/src/main/resources/tessdata/configs/wordstrbox b/src/main/resources/tessdata/configs/wordstrbox
new file mode 100644
index 0000000..38cd41c
--- /dev/null
+++ b/src/main/resources/tessdata/configs/wordstrbox
@@ -0,0 +1 @@
+tessedit_create_wordstrbox 1
diff --git a/src/main/resources/tessdata/eng.traineddata b/src/main/resources/tessdata/eng.traineddata
new file mode 100644
index 0000000..f4744c2
--- /dev/null
+++ b/src/main/resources/tessdata/eng.traineddata
Binary files differ
diff --git a/src/main/resources/tessdata/osd.traineddata b/src/main/resources/tessdata/osd.traineddata
new file mode 100644
index 0000000..183644a
--- /dev/null
+++ b/src/main/resources/tessdata/osd.traineddata
Binary files differ
diff --git a/src/main/resources/tessdata/pdf.ttf b/src/main/resources/tessdata/pdf.ttf
new file mode 100644
index 0000000..d1472b2
--- /dev/null
+++ b/src/main/resources/tessdata/pdf.ttf
Binary files differ
diff --git a/src/main/resources/tessdata/rus.traineddata b/src/main/resources/tessdata/rus.traineddata
new file mode 100644
index 0000000..8b71c2d
--- /dev/null
+++ b/src/main/resources/tessdata/rus.traineddata
Binary files differ
diff --git a/src/main/resources/tessdata/tessconfigs/batch b/src/main/resources/tessdata/tessconfigs/batch
new file mode 100644
index 0000000..a681e4a
--- /dev/null
+++ b/src/main/resources/tessdata/tessconfigs/batch
@@ -0,0 +1 @@
+# No content needed as all defaults are correct.
diff --git a/src/main/resources/tessdata/tessconfigs/batch.nochop b/src/main/resources/tessdata/tessconfigs/batch.nochop
new file mode 100644
index 0000000..ebaab94
--- /dev/null
+++ b/src/main/resources/tessdata/tessconfigs/batch.nochop
@@ -0,0 +1,2 @@
+chop_enable 0
+wordrec_enable_assoc 0
diff --git a/src/main/resources/tessdata/tessconfigs/matdemo b/src/main/resources/tessdata/tessconfigs/matdemo
new file mode 100644
index 0000000..c34567b
--- /dev/null
+++ b/src/main/resources/tessdata/tessconfigs/matdemo
@@ -0,0 +1,7 @@
+#################################################
+# Adaptive Matcher Using PreAdapted Templates
+#################################################
+
+classify_enable_adaptive_debugger 1
+matcher_debug_flags 6
+matcher_debug_level 1
diff --git a/src/main/resources/tessdata/tessconfigs/msdemo b/src/main/resources/tessdata/tessconfigs/msdemo
new file mode 100644
index 0000000..9c1184a
--- /dev/null
+++ b/src/main/resources/tessdata/tessconfigs/msdemo
@@ -0,0 +1,12 @@
+#################################################
+# Adaptive Matcher Using PreAdapted Templates
+#################################################
+
+classify_enable_adaptive_debugger 1
+matcher_debug_flags 6
+matcher_debug_level 1
+
+wordrec_display_splits 0
+wordrec_display_all_blobs 1
+wordrec_display_segmentations 2
+classify_debug_level 1
diff --git a/src/main/resources/tessdata/tessconfigs/nobatch b/src/main/resources/tessdata/tessconfigs/nobatch
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/main/resources/tessdata/tessconfigs/nobatch
@@ -0,0 +1 @@
+
diff --git a/src/main/resources/tessdata/tessconfigs/segdemo b/src/main/resources/tessdata/tessconfigs/segdemo
new file mode 100644
index 0000000..eaff69f
--- /dev/null
+++ b/src/main/resources/tessdata/tessconfigs/segdemo
@@ -0,0 +1,9 @@
+#################################################
+# Adaptive Matcher Using PreAdapted Templates
+#################################################
+
+wordrec_display_splits 0
+wordrec_display_all_blobs 1
+wordrec_display_segmentations 2
+classify_debug_level 1
+stopper_debug_level 1
diff --git a/src/main/resources/tessdata/uzb.traineddata b/src/main/resources/tessdata/uzb.traineddata
new file mode 100644
index 0000000..cf9f7e0
--- /dev/null
+++ b/src/main/resources/tessdata/uzb.traineddata
Binary files differ
diff --git a/src/main/resources/tessdata/uzb_cyrl.traineddata b/src/main/resources/tessdata/uzb_cyrl.traineddata
new file mode 100644
index 0000000..434d277
--- /dev/null
+++ b/src/main/resources/tessdata/uzb_cyrl.traineddata
Binary files differ
diff --git a/src/test/java/info/selflearner/ocr/OcrApplicationTests.java b/src/test/java/info/selflearner/ocr/OcrApplicationTests.java
new file mode 100644
index 0000000..3fe092f
--- /dev/null
+++ b/src/test/java/info/selflearner/ocr/OcrApplicationTests.java
@@ -0,0 +1,13 @@
+package info.selflearner.ocr;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class OcrApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}