feat: 新增识别和接口联调,已经可以完成识别
Description: 新增识别和接口联调,已经可以完成识别 Log: 新增识别和接口联调,已经可以完成识别 Change-Id: I1ccceae34b29d22c931e77440c5848125e60f8a5
This commit is contained in:
parent
a7326a4165
commit
23d7a5a3a9
|
@ -9,6 +9,8 @@
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
|
@ -151,7 +153,6 @@ void MainWidget::setupUi(QWidget *Widget)
|
||||||
m_pwidget->setFixedSize(this->width(), this->height() - 23);
|
m_pwidget->setFixedSize(this->width(), this->height() - 23);
|
||||||
m_pwidget->move(0, 0);
|
m_pwidget->move(0, 0);
|
||||||
|
|
||||||
createLoadingUi();
|
|
||||||
// deleteLoadingUi();
|
// deleteLoadingUi();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -215,6 +216,7 @@ void MainWidget::loadingUi()
|
||||||
|
|
||||||
void MainWidget::openImage(const QString &path)
|
void MainWidget::openImage(const QString &path)
|
||||||
{
|
{
|
||||||
|
createLoadingUi();
|
||||||
if (m_imageview) {
|
if (m_imageview) {
|
||||||
QImage img(path);
|
QImage img(path);
|
||||||
m_imageview->openFilterImage(img);
|
m_imageview->openFilterImage(img);
|
||||||
|
@ -222,6 +224,18 @@ void MainWidget::openImage(const QString &path)
|
||||||
m_imgName = 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)
|
void MainWidget::openImage(const QImage &img)
|
||||||
|
@ -231,6 +245,17 @@ void MainWidget::openImage(const QImage &img)
|
||||||
m_imageview->fitWindow();
|
m_imageview->fitWindow();
|
||||||
m_imgName = "";
|
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)
|
void MainWidget::loadHtml(const QString &html)
|
||||||
|
|
|
@ -7,8 +7,13 @@
|
||||||
#include <DLabel>
|
#include <DLabel>
|
||||||
#include <DGuiApplicationHelper>
|
#include <DGuiApplicationHelper>
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
#include "resulttextview.h"
|
#include "resulttextview.h"
|
||||||
#include "textloadwidget.h"
|
#include "textloadwidget.h"
|
||||||
|
#include "tessocrutils/tessocrutils.h"
|
||||||
|
|
||||||
|
class QThread;
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class ImageView;
|
class ImageView;
|
||||||
|
@ -65,6 +70,10 @@ private:
|
||||||
DLabel *m_loadingTip{nullptr};
|
DLabel *m_loadingTip{nullptr};
|
||||||
|
|
||||||
bool m_isLoading{false};
|
bool m_isLoading{false};
|
||||||
|
|
||||||
|
QThread *m_loadImagethread{nullptr};
|
||||||
|
QMutex m_mutex;
|
||||||
|
RecognitionResult m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIDGET_H
|
#endif // WIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user