feat: 新增识别和接口联调,已经可以完成识别

Description: 新增识别和接口联调,已经可以完成识别

Log: 新增识别和接口联调,已经可以完成识别
Change-Id: I1ccceae34b29d22c931e77440c5848125e60f8a5
This commit is contained in:
liuminghang 2021-06-15 15:46:07 +08:00
parent a7326a4165
commit 23d7a5a3a9
2 changed files with 35 additions and 1 deletions

View File

@ -9,6 +9,8 @@
#include <QStandardPaths>
#include <QFileDialog>
#include <QFileInfo>
#include <QThread>
#include <QMutexLocker>
#include <DGuiApplicationHelper>
#include <DMainWindow>
@ -151,7 +153,6 @@ void MainWidget::setupUi(QWidget *Widget)
m_pwidget->setFixedSize(this->width(), this->height() - 23);
m_pwidget->move(0, 0);
createLoadingUi();
// deleteLoadingUi();
}
@ -215,6 +216,7 @@ void MainWidget::loadingUi()
void MainWidget::openImage(const QString &path)
{
createLoadingUi();
if (m_imageview) {
QImage img(path);
m_imageview->openFilterImage(img);
@ -222,6 +224,18 @@ void MainWidget::openImage(const QString &path)
m_imgName = path;
}
if (!m_loadImagethread) {
m_loadImagethread = QThread::create([ = ]() {
QMutexLocker locker(&m_mutex);
m_result = TessOcrUtils::instance()->getRecogitionResult(path, ResultType::RESULT_HTML);
loadHtml(m_result.result);
deleteLoadingUi();
});
}
connect(m_loadImagethread, &QThread::finished, m_loadImagethread, &QObject::deleteLater);
m_loadImagethread->start();
}
void MainWidget::openImage(const QImage &img)
@ -231,6 +245,17 @@ void MainWidget::openImage(const QImage &img)
m_imageview->fitWindow();
m_imgName = "";
}
if (!m_loadImagethread) {
m_loadImagethread = QThread::create([ = ]() {
QMutexLocker locker(&m_mutex);
QImage a = img;
m_result = TessOcrUtils::instance()->getRecogitionResult(&a, ResultType::RESULT_HTML);
loadHtml(m_result.result);
deleteLoadingUi();
});
}
connect(m_loadImagethread, &QThread::finished, m_loadImagethread, &QObject::deleteLater);
m_loadImagethread->start();
}
void MainWidget::loadHtml(const QString &html)

View File

@ -7,8 +7,13 @@
#include <DLabel>
#include <DGuiApplicationHelper>
#include <QMutex>
#include "resulttextview.h"
#include "textloadwidget.h"
#include "tessocrutils/tessocrutils.h"
class QThread;
class QGridLayout;
class QHBoxLayout;
class ImageView;
@ -65,6 +70,10 @@ private:
DLabel *m_loadingTip{nullptr};
bool m_isLoading{false};
QThread *m_loadImagethread{nullptr};
QMutex m_mutex;
RecognitionResult m_result;
};
#endif // WIDGET_H