starting work on image module
This commit is contained in:
parent
2a726a96b7
commit
f9b0b75062
|
@ -19,6 +19,7 @@ set(PROJECT_SOURCES
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
qt_add_executable(checks-parser
|
qt_add_executable(checks-parser
|
||||||
MANUAL_FINALIZATION
|
MANUAL_FINALIZATION
|
||||||
|
@ -48,14 +49,12 @@ else()
|
||||||
ofd/ofd.h ofd/ofd.cpp
|
ofd/ofd.h ofd/ofd.cpp
|
||||||
ofd/module.h ofd/module.cpp
|
ofd/module.h ofd/module.cpp
|
||||||
utils/utils.h utils/utils.cpp
|
utils/utils.h utils/utils.cpp
|
||||||
|
image/checkimage.h image/checkimage.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(checks-parser PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
target_link_libraries(checks-parser PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||||
# If you are developing for iOS or macOS you should consider setting an
|
# If you are developing for iOS or macOS you should consider setting an
|
||||||
# explicit, fixed bundle identifier manually though.
|
# explicit, fixed bundle identifier manually though.
|
||||||
|
@ -86,3 +85,12 @@ FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
|
||||||
GIT_TAG 3b15fa82ea74739b574d705fea44959b58142eb8)
|
GIT_TAG 3b15fa82ea74739b574d705fea44959b58142eb8)
|
||||||
FetchContent_MakeAvailable(cpr)
|
FetchContent_MakeAvailable(cpr)
|
||||||
target_link_libraries(checks-parser PRIVATE cpr::cpr)
|
target_link_libraries(checks-parser PRIVATE cpr::cpr)
|
||||||
|
|
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
|
pkg_search_module(opencv REQUIRED IMPORTED_TARGET opencv)
|
||||||
|
target_link_libraries(checks-parser PRIVATE PkgConfig::opencv)
|
||||||
|
target_link_libraries(checks-parser PRIVATE -ltesseract)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <string>
|
||||||
|
#include <tesseract/baseapi.h>
|
||||||
|
#include <leptonica/allheaders.h>
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include "checkimage.h"
|
||||||
|
|
||||||
|
CheckImage::CheckImage(std::string path) {
|
||||||
|
this->path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CheckImage::parse_text() {
|
||||||
|
std::string result;
|
||||||
|
|
||||||
|
tesseract::TessBaseAPI *ocr = new tesseract::TessBaseAPI();
|
||||||
|
ocr->Init(NULL, "rus", tesseract::OEM_LSTM_ONLY);
|
||||||
|
ocr->SetPageSegMode(tesseract::PSM_AUTO);
|
||||||
|
|
||||||
|
cv::Mat im = cv::imread(this->path, cv::IMREAD_COLOR);
|
||||||
|
ocr->SetImage(im.data, im.cols, im.rows, 3, im.step);
|
||||||
|
result = std::string(ocr->GetUTF8Text());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef CHECKIMAGE_H
|
||||||
|
#define CHECKIMAGE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class CheckImage {
|
||||||
|
std::string path;
|
||||||
|
public:
|
||||||
|
CheckImage(std::string path);
|
||||||
|
|
||||||
|
std::string parse_text();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CHECKIMAGE_H
|
5
main.cpp
5
main.cpp
|
@ -1,14 +1,11 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ofd/ofd.h"
|
|
||||||
#include "utils/utils.h"
|
|
||||||
#include <iostream>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,10 @@ void MainWindow::setupStoresList() {
|
||||||
void MainWindow::on_checkType_currentIndexChanged(int index) {
|
void MainWindow::on_checkType_currentIndexChanged(int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
ui->checkInfo->setVisible(true);
|
ui->checkInfoText->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ui->checkInfo->setVisible(false);
|
ui->checkInfoText->setVisible(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
112
mainwindow.ui
112
mainwindow.ui
|
@ -37,12 +37,48 @@
|
||||||
<string>Store</string>
|
<string>Store</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="checkInfo" native="true">
|
<widget class="QLabel" name="checkTypeLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>81</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Check type</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="checkType">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>211</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Image (not yet implemented)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="checkInfoText" native="true">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>90</y>
|
<y>70</y>
|
||||||
<width>801</width>
|
<width>421</width>
|
||||||
<height>511</height>
|
<height>511</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -86,38 +122,58 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="storeTypeLabel_2">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>460</x>
|
||||||
<y>50</y>
|
<y>270</y>
|
||||||
<width>81</width>
|
<width>301</width>
|
||||||
<height>20</height>
|
<height>221</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="tabPosition">
|
||||||
<string>Check type</string>
|
<enum>QTabWidget::TabPosition::North</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="tabShape">
|
||||||
<widget class="QComboBox" name="checkType">
|
<enum>QTabWidget::TabShape::Rounded</enum>
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>90</x>
|
|
||||||
<y>50</y>
|
|
||||||
<width>211</width>
|
|
||||||
<height>26</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<property name="currentIndex">
|
||||||
<property name="text">
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="elideMode">
|
||||||
|
<enum>Qt::TextElideMode::ElideNone</enum>
|
||||||
|
</property>
|
||||||
|
<property name="documentMode">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="tabsClosable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="tabBarAutoHide">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
<string>Text</string>
|
<string>Text</string>
|
||||||
</property>
|
</attribute>
|
||||||
</item>
|
</widget>
|
||||||
<item>
|
<widget class="QWidget" name="tab_2">
|
||||||
<property name="text">
|
<attribute name="title">
|
||||||
<string>Image (not yet implemented)</string>
|
<string>Image</string>
|
||||||
</property>
|
</attribute>
|
||||||
</item>
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>460</x>
|
||||||
|
<y>60</y>
|
||||||
|
<width>241</width>
|
||||||
|
<height>151</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="page_5"/>
|
||||||
|
<widget class="QWidget" name="page_6"/>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
|
Loading…
Reference in New Issue