9 Commits

Author SHA1 Message Date
17a03606c5 fixed wrong setting 2024-12-03 15:24:21 +03:00
83351698d6 readme & todo updated 2024-12-03 15:02:54 +03:00
2c99f422d3 appimage deployment 2024-12-03 03:45:58 +03:00
41463c7f87 packing ocr data and handling escape on chose files 2024-12-02 14:12:03 +03:00
c941264346 remove unneeded, update gitignore 2024-12-02 13:10:36 +03:00
c471cb3f62 fixed captcha not showing up in appimage 2024-12-02 13:09:48 +03:00
7c021c90ee TOOD update 2024-12-02 12:45:20 +03:00
e6cc4b9117 using linuxdeployqt for appimage deployment 2024-12-02 03:21:24 +03:00
c8e4f5ac54 gitignore update 2024-12-02 01:14:42 +03:00
16 changed files with 133 additions and 23 deletions

3
.gitignore vendored
View File

@@ -118,3 +118,6 @@ install_manifest.txt
checks-parser_autogen
checks-parser
deploy/appimage/AppDir/usr/share/doc/
deploy/appimage/AppDir/usr/share/

View File

@@ -30,7 +30,7 @@ In general, you need to install following dependencies in order to build that ap
Please, do not hesitate to open an issue if you cannot build that. I will help and if you are building on a distro that is not listed there, we can append that list as soon as we will solve your problem!
### Linux
##### Arch Linux
##### Arch Linux-based
I recommend using aur helper (I use yay) to install dependencies. Or, if you're masochist, you can build all by yourself /shrug
```
#Install dependencies
@@ -38,16 +38,31 @@ yay -S sudo cmake git coreutils base-devel eigen qt5-base mbedtls gtkglext openc
#Clone and compile an app
git clone https://git.foxarmy.org/leca/checks-parser
cd checks-parser
mkdir build
cd build
cmake ..
cmake .
make -j{nproc}
#If you wish to install that program system-wide, run
sudo make install
```
##### Debian
apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json-dev libcurl4-openssl-dev libtesseract-dev
TODO
##### Debian-based
In debian-based distributions most, but not every, package names are the same.
Installation of dependencies for different debian-based distros:
###### Ubuntu 18.04
```apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json-dev libcurl4-openssl-dev libtesseract-dev```
###### Ubuntu 20.04, LMDE (tested only 6), Debian (tested only 12)
```apt install -y qtbase5-dev openssl libmbedtls-dev tesseract-ocr tesseract-ocr-rus libopencv-dev libzbar-dev qttools5-dev nlohmann-json3-dev libcurl4-openssl-dev libtesseract-dev```
Next steps are identical for every debian-based distro
```
#Clone and compile an app
git clone https://git.foxarmy.org/leca/checks-parser
cd checks-parser
cmake .
make -j{nproc}
#If you wish to install that program system-wide, run
sudo make install
```
### Windows
Maybe
### Mac OS

16
TODO
View File

@@ -1,9 +1,11 @@
Complete module "export": [done]
make UI; [done]
make export to .csv [done]
Complete module "image-to-text": [done]
make UI; [done]
make use of tesseract/opencv (https://learnopencv.com/deep-learning-based-text-recognition-ocr-using-tesseract-and-opencv/); [done]
Add features:
autodetect store type
auto download of stores modules [done]
@@ -11,10 +13,18 @@ Add features:
settings, a window for editing settings. [done]
add ability to control contrast and rotation of a check image before passing it to OCR [done]
add ability to scan a qr code and request data from ofd.ru [done]
add ability to change language from preferences
Refactor:
Get rid of CPR, use libcurl instead [done]
Build:
Write script for AppImage deployment
Find out dependencies packet names on different distros
Ensure success of building on most popular distros
Write script for AppImage deployment [done]
Find out dependencies packet names on different distros [done for arch, ubuntu]
Ensure success of building on most popular distros [done for arch, ubuntu]
Try to compile it on Windows
Issues:
Captcha is not showing when running in appimage [solved]
Stores modules are not being downloaded
I need to pack tesseract data for ru, en [solved]

View File

@@ -1 +0,0 @@
checks-parser.png

Before

Width:  |  Height:  |  Size: 17 B

After

Width:  |  Height:  |  Size: 627 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 B

After

Width:  |  Height:  |  Size: 627 KiB

View File

@@ -1 +0,0 @@
usr/bin/checks-parser

4
deploy/appimage/AppDir/AppRun Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
export TESSDATA_PREFIX=$APPDIR/usr/share/tesseract-ocr/4.00/tessdata
$APPDIR/usr/bin/checks-parser

View File

@@ -3,4 +3,5 @@ Name=Checks parser
Exec=usr/bin/checks-parser
Icon=checks-parser
Type=Application
Categories=Utility
Categories=Utility;
X-AppImage-Version=41463c7

View File

@@ -0,0 +1,7 @@
# Generated by linuxdeployqt
# https://github.com/probonopd/linuxdeployqt/
[Paths]
Prefix = ./
Plugins = plugins
Imports = qml
Qml2Imports = qml

View File

@@ -0,0 +1,7 @@
# Generated by linuxdeployqt
# https://github.com/probonopd/linuxdeployqt/
[Paths]
Prefix = ../
Plugins = plugins
Imports = qml
Qml2Imports = qml

View File

@@ -1,13 +1,26 @@
#!/usr/bin/env bash
mkdir -p AppDir/usr/bin
mkdir -p AppDir/usr/lib
mkdir -p AppDir/usr/share/tesseract-ocr/4.00/tessdata
cp -r /usr/share/tesseract-ocr/4.00/tessdata/* AppDir/usr/share/tesseract-ocr/4.00/tessdata
cp ../../checks-parser AppDir/usr/bin
echo \
"[Desktop Entry]
Name=Checks parser
Exec=usr/bin/checks-parser
Icon=checks-parser
Type=Application
Categories=Utility" \
Categories=Utility;" \
> AppDir/checks-parser.desktop
linuxdeploy --appdir AppDir -e AppDir/usr/bin/checks-parser --output appimage
echo \
"#!/bin/bash
export TESSDATA_PREFIX=\$APPDIR/usr/share/tesseract-ocr/4.00/tessdata
\$APPDIR/usr/bin/checks-parser" \
> AppDir/AppRun
chmod +x AppDir/AppRun
cp ../../checks-parser AppDir/usr/bin
linuxdeployqt AppDir/usr/bin/checks-parser -no-copy-copyright-files -appimage

View File

@@ -140,6 +140,15 @@ void MainWindow::on_preferencesButton_clicked() {
void MainWindow::on_chooseImageButton_ofd_clicked() {
QString filename = QFileDialog::getOpenFileName();
if (filename == "") {
QMessageBox infoDialog;
infoDialog.setText(tr("Please, select a picture where QR code that contains info about check is present"));
infoDialog.setIcon(QMessageBox::Critical);
infoDialog.setWindowTitle(tr("Picture was not selected"));
infoDialog.exec();
return;
}
std::string new_text = "Selected: " + filename.toStdString();
ui->pathLabel_ofd->setText(QString::fromStdString(new_text));
@@ -177,6 +186,15 @@ void MainWindow::on_chooseImageButton_ocr_clicked()
{
QString filename = QFileDialog::getOpenFileName();
if (filename == "") {
QMessageBox infoDialog;
infoDialog.setText(tr("Please, select a picture to scan"));
infoDialog.setIcon(QMessageBox::Critical);
infoDialog.setWindowTitle(tr("Picture was not selected"));
infoDialog.exec();
return;
}
std::string new_text = "Selected: " + filename.toStdString();
ui->pathLabel_ocr->setText(QString::fromStdString(new_text));

View File

@@ -105,5 +105,5 @@ std::string Net::fetch_check_data_from_ofdru(std::string fn, std::string fd, std
}
void Net::get_captcha_from_ofdru() {
get_file("https://check.ofd.ru/api/captcha/common/img", get_path_relative_to_home(".local/share/checks_parser/captcha.png"));
get_file("https://check.ofd.ru/api/captcha/common/img", get_path_relative_to_home(".local/share/checks_parser/captcha.jpg"));
}

View File

@@ -85,7 +85,7 @@ std::vector<std::string> Parser::check_updates() {
std::cout << file.path().filename() << " detected store module" << std::endl;
}
Net n;
std::cerr << "Downloading modules list from: " << s.get_setting("stores_modules_url");
std::cerr << "Downloading modules list from: " << s.get_setting("stores_modules_url") << std::endl;
std::vector<std::string> remote_modules = n.get_all_modules(s.get_setting("stores_modules_url"));
if (stored_modules.empty()) {
std::cout << "I need to download everything" << std::endl;

View File

@@ -23,7 +23,7 @@ Settings::Settings(std::string path) {
"ofds_modules_dir":".local/share/checks_parser/modules/ofd",
"stores_modules_dir":".local/share/checks_parser/modules/stores",
"ofds_modules_url":"https://foxarmy.org/checks-parser/modules/ofd/",
"stores_modules_url":"https://foxarmy.org/checks-parser/modules/modules/",
"stores_modules_url":"https://foxarmy.org/checks-parser/modules/stores/",
"print_header": true,
"print_total": true,
"output_order": {

View File

@@ -1,7 +1,7 @@
#include "solvecaptchadialog.h"
#include "ui_solvecaptchadialog.h"
#include "utils/utils.h"
#include <iostream>
#include <QMessageBox>
SolveCaptchaDialog::SolveCaptchaDialog(QWidget *parent, std::string* solved_captcha) :
@@ -10,7 +10,8 @@ SolveCaptchaDialog::SolveCaptchaDialog(QWidget *parent, std::string* solved_capt
solved_captcha(solved_captcha) {
ui->setupUi(this);
QString captcha_path = QString::fromStdString(get_path_relative_to_home(".local/share/checks_parser/captcha.png"));
QString captcha_path = QString::fromStdString(get_path_relative_to_home(".local/share/checks_parser/captcha.jpg"));
std::cout << captcha_path.toStdString() << std::endl;
ui->captcha_picture->setPixmap(captcha_path);
ui->captcha_picture->setScaledContents(true);
}

View File

@@ -159,6 +159,22 @@
<source>Check was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="145"/>
<source>Please, select a picture where QR code that contains info about check is present</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="147"/>
<location filename="../mainwindow.cpp" line="193"/>
<source>Picture was not selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="191"/>
<source>Please, select a picture to scan</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OutputDialog</name>
@@ -281,12 +297,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../solvecaptchadialog.cpp" line="22"/>
<location filename="../solvecaptchadialog.cpp" line="23"/>
<source>Please, enter a valid captcha</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../solvecaptchadialog.cpp" line="24"/>
<location filename="../solvecaptchadialog.cpp" line="25"/>
<source>No captcha</source>
<translation type="unfinished"></translation>
</message>

View File

@@ -159,6 +159,22 @@
<source>Check was not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="145"/>
<source>Please, select a picture where QR code that contains info about check is present</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="147"/>
<location filename="../mainwindow.cpp" line="193"/>
<source>Picture was not selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="191"/>
<source>Please, select a picture to scan</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OutputDialog</name>
@@ -281,12 +297,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../solvecaptchadialog.cpp" line="22"/>
<location filename="../solvecaptchadialog.cpp" line="23"/>
<source>Please, enter a valid captcha</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../solvecaptchadialog.cpp" line="24"/>
<location filename="../solvecaptchadialog.cpp" line="25"/>
<source>No captcha</source>
<translation type="unfinished"></translation>
</message>