From e5435c67e3341bda1d729b6061598e02126a236d Mon Sep 17 00:00:00 2001 From: leca Date: Sun, 1 Sep 2024 16:57:25 +0300 Subject: [PATCH] completed image ocr --- README.md | 2 +- mainwindow.cpp | 29 ++++++++++++++++++----------- mainwindow.ui | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7d10bb5..8863491 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # checks-parser -C++/QT desktop program for parsing checks to xlsx/csv \ No newline at end of file +C++/QT desktop program for parsing checks to csv diff --git a/mainwindow.cpp b/mainwindow.cpp index 4d6a1a7..a076d20 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6,6 +6,7 @@ #include "settings.h" #include #include +#include "image/checkimage.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { @@ -36,20 +37,20 @@ void MainWindow::setupStoresList() { } void MainWindow::on_checkType_currentIndexChanged(int index) { - ui->inputHolder->setCurrentIndex(index); - // switch (index) { - // case 0: - // ui->checkInfoText->setVisible(true); - // break; - // case 1: - // ui->checkInfoText->setVisible(false); - // break; - // } } void MainWindow::on_parseButton_clicked() { - QString s(ui->checkContent->toPlainText()); + QString s; + switch (ui->checkType->currentIndex()) { + case 0: + s = ui->checkContent->toPlainText(); + break; + case 1: + s = ui->checkContentFromImage->toPlainText(); + break; + } + std::wstring check_plaintext = s.toStdWString(); parser.set_module(parser.search_modules()[0]); @@ -81,6 +82,12 @@ void MainWindow::on_chooseImageButton_clicked() { std::cout << filename.toStdString() << std::endl; // this->options.set_path(filename.toStdString()); - ui->pathLabel->setText("Path to export: " + filename); + std::string new_text = "Path to export: " + filename.toStdString(); + ui->pathLabel->setText(QString::fromStdString(new_text)); + + CheckImage i(filename.toStdString()); + std::string parsed = i.parse_text(); + + ui->checkContentFromImage->setPlainText(QString::fromStdString(parsed)); } diff --git a/mainwindow.ui b/mainwindow.ui index 4ef0e51..c977265 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -113,7 +113,7 @@ 110 20 - 161 + 381 18 @@ -134,8 +134,44 @@ Choose + + + + 10 + 50 + 571 + 18 + + + + Here is recognised check text. Please, edit it if something's wrong: + + + + + + 10 + 80 + 471 + 371 + + + + + + + 30 + 560 + 80 + 26 + + + + Parse + +