fix: 修复打开多窗口识别崩溃问题
Description: 采用仓库中旧版本的识别库,正在识别过程中不响应启动另外一个识别 Log: 识别过程中不打开多个识别窗口进行识别 Change-Id: Ic75933f6d016c8c045ec5252cd92172219ca9cd5
This commit is contained in:
parent
84aa3515d0
commit
ba49aab3f4
103
CMakeLists.txt
103
CMakeLists.txt
|
@ -48,12 +48,55 @@ include_directories(src)
|
|||
include_directories(./src/service)
|
||||
include_directories(./src/tessocrutils)
|
||||
include_directories(./src/view)
|
||||
#需要使用tesseract源码时添加tesseract三方库文件
|
||||
#include_directories(/usr/include/leptonica)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/include)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/api)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/arch)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/ccmain)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/ccstruct)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/ccutil)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/classify)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/cutil)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/dict)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/lstm)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/opencl)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/textord)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/viewer)
|
||||
#include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/wordrec)
|
||||
|
||||
aux_source_directory(src allSource)
|
||||
aux_source_directory(src/service allSource)
|
||||
aux_source_directory(src/tessocrutils allSource)
|
||||
aux_source_directory(src/view allSource)
|
||||
|
||||
#需要使用tesseract源码时添加tesseract三方库文件
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/api allSource)
|
||||
##aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/arch allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/ccmain allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/ccstruct allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/ccutil allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/classify allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/cutil allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/dict allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/lstm allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/opencl allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/textord allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/viewer allSource)
|
||||
#aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/wordrec allSource)
|
||||
#FILE(GLOB COMMON_FILE
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/dotproduct.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/intsimdmatrix.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/simddetect.cpp"
|
||||
# )
|
||||
#FILE(GLOB ARCH_FILE
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/dotproductavx.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/dotproductfma.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/dotproductsse.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/intsimdmatrixavx2.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/intsimdmatrixavx2.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/intsimdmatrixneon.cpp"
|
||||
# "./3rdparty/tesseract_ocr/tesseract/src/arch/intsimdmatrixsse.cpp"
|
||||
# )
|
||||
set(AllQRC
|
||||
./resource.qrc
|
||||
)
|
||||
|
@ -72,6 +115,14 @@ set_source_files_properties(${qmfiles} PROPERTIES OUTPUT_LOCATION "translations"
|
|||
set(LINK_DIR lib)
|
||||
link_directories(${LINK_DIR})
|
||||
|
||||
#如果添加tesseract源码则需要arm平台需多添加几个文件
|
||||
#message("The host system is " ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||
#if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
# add_executable(${PROJECT_NAME} ${allSource} ${COMMON_FILE} ${ARCH_FILE} ${AllQRC} ${LangSrcs} )
|
||||
#else()
|
||||
# add_executable(${PROJECT_NAME} ${allSource} ${COMMON_FILE} ${AllQRC} ${LangSrcs} )
|
||||
#endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${allSource} ${AllQRC} ${LangSrcs} )
|
||||
|
||||
if(DOTEST)
|
||||
|
@ -79,20 +130,63 @@ if(DOTEST)
|
|||
${PROJECT_NAME}_test)
|
||||
|
||||
include_directories(tests)
|
||||
include_directories(src)
|
||||
include_directories(./src/service)
|
||||
include_directories(./src/tessocrutils)
|
||||
include_directories(./src/view)
|
||||
#需要使用tesseract源码时添加tesseract三方库文件
|
||||
# include_directories(/usr/include/leptonica)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/include)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/api)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/arch)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/ccmain)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/ccstruct)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/ccutil)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/classify)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/cutil)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/dict)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/lstm)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/opencl)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/textord)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/viewer)
|
||||
# include_directories(${PROJECT_SOURCE_DIR}/3rdparty/tesseract_ocr/tesseract/src/wordrec)
|
||||
|
||||
aux_source_directory(src/service allTestSource)
|
||||
aux_source_directory(src/tessocrutils allTestSource)
|
||||
aux_source_directory(src/view allTestSource)
|
||||
aux_source_directory(tests allTestSource)
|
||||
aux_source_directory(tests/tessocrutils allTestSource)
|
||||
#需要使用tesseract源码时添加tesseract三方库文件
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/api allTestSource)
|
||||
# #aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/arch allSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/ccmain allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/ccstruct allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/ccutil allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/opencl allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/classify allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/cutil allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/dict allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/lstm allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/textord allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/viewer allTestSource)
|
||||
# aux_source_directory(3rdparty/tesseract_ocr/tesseract/src/wordrec allTestSource)
|
||||
|
||||
FILE(GLOB allTestSource1
|
||||
"src/loadingwidget.cpp"
|
||||
"src/mainwidget.cpp"
|
||||
"src/mainwindow.cpp"
|
||||
"src/ocrapplication.cpp"
|
||||
"src/resulttextview.cpp"
|
||||
"src/textloadwidget.cpp")
|
||||
#需要使用tesseract源码时添加tesseract三方库文件
|
||||
# if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
# add_executable(${PROJECT_NAME_TEST} ${allTestSource} ${COMMON_FILE} ${ARCH_FILE} ${allTestSource1} )
|
||||
# else()
|
||||
# add_executable(${PROJECT_NAME_TEST} ${allTestSource} ${COMMON_FILE} ${allTestSource1} )
|
||||
# endif()
|
||||
add_executable(${PROJECT_NAME_TEST} ${allTestSource} ${allTestSource1} )
|
||||
|
||||
add_executable(${PROJECT_NAME_TEST} ${allTestSource} ${allTestSource1})
|
||||
#add_executable(${PROJECT_NAME_TEST} ${allTestSource} ${allTestSource1})
|
||||
target_link_libraries(${PROJECT_NAME_TEST} gmock gtest pthread)
|
||||
|
||||
add_test(${PROJECT_NAME_TEST} COMMAND ${PROJECT_NAME_TEST})
|
||||
|
@ -133,10 +227,9 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${3rd_lib_INCLUDE_DIRS})
|
|||
if(DOTEST)
|
||||
target_include_directories(${PROJECT_NAME_TEST} PUBLIC ${3rd_lib_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${3rd_lib_LIBRARIES} lept)
|
||||
target_link_libraries(${PROJECT_NAME} ${3rd_lib_LIBRARIES} lept tesseract pthread)
|
||||
if(DOTEST)
|
||||
target_link_libraries(${PROJECT_NAME_TEST} ${3rd_lib_LIBRARIES} lept)
|
||||
target_link_libraries(${PROJECT_NAME_TEST} ${3rd_lib_LIBRARIES} lept tesseract pthread)
|
||||
endif()
|
||||
|
||||
qt5_use_modules(${PROJECT_NAME} ${QtModule})
|
||||
|
|
2
debian/control
vendored
2
debian/control
vendored
|
@ -2,7 +2,7 @@ Source: deepin-ocr
|
|||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: Deepin Packages Builder <packages@deepin.com>
|
||||
Build-Depends: debhelper (>= 11), cmake, qtbase5-dev, pkg-config,libdtkwidget-dev,libleptonica-dev
|
||||
Build-Depends: debhelper (>= 11), cmake, qtbase5-dev, pkg-config,libdtkwidget-dev,libleptonica-dev,libtesseract-dev
|
||||
Standards-Version: 4.1.3
|
||||
Homepage: <insert the upstream URL, if relevant>
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
TEMPLATE = app
|
||||
TARGET = deepin-ocr
|
||||
INCLUDEPATH += .
|
||||
CONFIG += C++17
|
||||
QMAKE_CXXFLAGS += -std=c++17 -std=gnu++17
|
||||
#CONFIG += C++17
|
||||
#QMAKE_CXXFLAGS += -std=c++17 -std=gnu++17
|
||||
|
||||
# The following define makes your compiler warn you if you use any
|
||||
# feature of Qt which has been marked as deprecated (the exact warnings
|
||||
|
@ -42,9 +42,9 @@ SOURCES += src/main.cpp \
|
|||
src/tessocrutils/tessocrutils.cpp \
|
||||
src/loadingwidget.cpp
|
||||
|
||||
LIBS += -llept \
|
||||
LIBS += -llept -ltesseract\
|
||||
|
||||
include(3rdparty/tesseract_ocr/tesseract_dependency.pri)
|
||||
#include(3rdparty/tesseract_ocr/tesseract_dependency.pri)
|
||||
|
||||
QT += dtkgui
|
||||
QT += dtkwidget
|
||||
|
@ -75,5 +75,5 @@ INSTALLS += target dbus_service translations tesslangs
|
|||
RESOURCES += \
|
||||
resource.qrc
|
||||
|
||||
DISTFILES += \
|
||||
3rdparty/tesseract_ocr/tesseract_dependency.pri
|
||||
#DISTFILES += \
|
||||
# 3rdparty/tesseract_ocr/tesseract_dependency.pri
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "ocrapplication.h"
|
||||
#include "mainwindow.h"
|
||||
#include "tessocrutils/tessocrutils.h"
|
||||
#include <DWidgetUtil>
|
||||
|
||||
OcrApplication::OcrApplication(QObject *parent) : QObject(parent)
|
||||
|
@ -31,9 +32,12 @@ OcrApplication::OcrApplication(QObject *parent) : QObject(parent)
|
|||
bool OcrApplication::openFile(QString filePath)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << __LINE__ << filePath;
|
||||
bool bRet = false;
|
||||
if(!TessOcrUtils::instance()->isRunning())
|
||||
{
|
||||
MainWindow *win = new MainWindow();
|
||||
//增加判断,空图片不会启动
|
||||
bool bRet = win->openFile(filePath);
|
||||
bRet = win->openFile(filePath);
|
||||
if (bRet) {
|
||||
win->show();
|
||||
//第一次启动才居中
|
||||
|
@ -42,6 +46,9 @@ bool OcrApplication::openFile(QString filePath)
|
|||
m_loadingCount++;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
qDebug() << "正在识别中!";
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
@ -51,6 +58,8 @@ void OcrApplication::openImage(QImage image)
|
|||
//增加判断,空图片不会启动
|
||||
if (!image.isNull() && image.width() >= 1) {
|
||||
qDebug() << __FUNCTION__ << __LINE__ << image.size();
|
||||
if(!TessOcrUtils::instance()->isRunning())
|
||||
{
|
||||
MainWindow *win = new MainWindow();
|
||||
win->openImage(image);
|
||||
win->show();
|
||||
|
@ -59,6 +68,9 @@ void OcrApplication::openImage(QImage image)
|
|||
Dtk::Widget::moveToCenter(win);
|
||||
m_loadingCount++;
|
||||
}
|
||||
}else {
|
||||
qDebug() << "正在识别中!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +78,7 @@ void OcrApplication::openImageAndName(QImage image, QString imageName)
|
|||
{
|
||||
//增加判断,空图片不会启动
|
||||
if (!image.isNull() && image.width() >= 1) {
|
||||
if(!TessOcrUtils::instance()->isRunning()){
|
||||
MainWindow *win = new MainWindow();
|
||||
win->openImage(image, imageName);
|
||||
win->show();
|
||||
|
@ -74,6 +87,9 @@ void OcrApplication::openImageAndName(QImage image, QString imageName)
|
|||
Dtk::Widget::moveToCenter(win);
|
||||
m_loadingCount++;
|
||||
}
|
||||
}else {
|
||||
qDebug() << "正在识别中!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ TessOcrUtils *TessOcrUtils::m_tessOcrUtils = nullptr;
|
|||
/**
|
||||
* @brief TessOcrUtils::t_Tesseract 三方库实例化
|
||||
*/
|
||||
//tesseract::TessBaseAPI *TessOcrUtils::t_Tesseract = new tesseract::TessBaseAPI();
|
||||
tesseract::TessBaseAPI *TessOcrUtils::t_Tesseract = new tesseract::TessBaseAPI();
|
||||
|
||||
|
||||
TessOcrUtils::TessOcrUtils()
|
||||
|
@ -62,6 +62,8 @@ TessOcrUtils::TessOcrUtils()
|
|||
setLanguagesPath(TESSDATA_PATH);
|
||||
//设置当前默认使用的识别语言系统语言+英语
|
||||
m_sLangs = getLanguages();
|
||||
//是否正在识别中
|
||||
m_isRunning = false;
|
||||
}
|
||||
|
||||
TessOcrUtils::~TessOcrUtils()
|
||||
|
@ -80,6 +82,7 @@ TessOcrUtils *TessOcrUtils::instance()
|
|||
//传入待识别图片的路径和想得到的返回结果类型,获取识别结果
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath,const ResultType &resultType)
|
||||
{
|
||||
m_isRunning = true;
|
||||
QString errorMessage = "";
|
||||
ErrorCode errorCode = ErrorCode::UNKNOWN;
|
||||
RecognitionResult t_result;
|
||||
|
@ -91,6 +94,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath,con
|
|||
errorMessage = "Can't pass an empty image path!";
|
||||
errorCode = ErrorCode::OCR_P_NULL;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
|
||||
|
@ -102,6 +106,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath,con
|
|||
errorMessage = "Image does not exist! imagePath: " + imagePath;
|
||||
errorCode = ErrorCode::OCR_P_NULL;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
try {
|
||||
|
@ -116,6 +121,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath,con
|
|||
errorMessage = "Failed to load picture! " + QString(e.what());
|
||||
errorCode = ErrorCode::OCR_LI_F;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
//获取识别结果
|
||||
|
@ -131,6 +137,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(const QString &imagePath)
|
|||
//传入待识别图片和想得到的返回结果类型,获取识别结果
|
||||
RecognitionResult TessOcrUtils::getRecogitionResult(QImage *image, const ResultType &resultType)
|
||||
{
|
||||
m_isRunning = true;
|
||||
QString errorMessage = "";
|
||||
ErrorCode errorCode = ErrorCode::UNKNOWN;
|
||||
RecognitionResult t_result;
|
||||
|
@ -141,6 +148,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(QImage *image, const ResultT
|
|||
errorMessage = "Can't pass an empty image!";
|
||||
errorCode = ErrorCode::OCR_P_NULL;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
Pix *p_image;
|
||||
|
@ -172,6 +180,11 @@ RecognitionResult TessOcrUtils::getRecogitionResult(QImage *image)
|
|||
return getRecogitionResult(image,ResultType::RESULT_STRING);
|
||||
}
|
||||
|
||||
bool TessOcrUtils::isRunning()
|
||||
{
|
||||
return m_isRunning;
|
||||
}
|
||||
|
||||
//获取系统当前的语言
|
||||
Languages TessOcrUtils::getSystemLang()
|
||||
{
|
||||
|
@ -230,9 +243,11 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
|||
errorMessage = "The result type does not exist! resultType: " + QString::number(resultType);
|
||||
errorCode = ErrorCode::OCR_RT_NULL;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
tesseract::TessBaseAPI *t_Tesseract = new tesseract::TessBaseAPI();
|
||||
//最新的tesseract库可以new出来,老版本的库无法在appcation后new出来
|
||||
//tesseract::TessBaseAPI *t_Tesseract = new tesseract::TessBaseAPI();
|
||||
try{
|
||||
//初始化语言包
|
||||
if (t_Tesseract->Init(m_sTessdataPath.toLatin1().data(), m_sLangs.toLatin1().data()))
|
||||
|
@ -241,6 +256,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
|||
errorMessage = "Could not initialize tesseract! Tesseract couldn't load any languages!";
|
||||
errorCode = ErrorCode::OCR_INI_F;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
}catch(const std::logic_error &e){
|
||||
|
@ -248,6 +264,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
|||
errorMessage = "Could not initialize tesseract! Tesseract internal error! " + QString(e.what());
|
||||
errorCode = ErrorCode::OCR_INI_F;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
//为Tesseract设置待识别图片
|
||||
|
@ -268,6 +285,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
|||
errorMessage = "Image recognition failed! " + QString(e.what());
|
||||
errorCode = ErrorCode::OCR_LI_F;
|
||||
setResult(errorCode,errorMessage,resultType,t_result);
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
t_Tesseract->End();
|
||||
|
@ -277,6 +295,7 @@ RecognitionResult TessOcrUtils::getRecogitionResult(Pix * image,ResultType resul
|
|||
t_result.errorCode = ErrorCode::OK;
|
||||
t_result.resultType = resultType;
|
||||
t_result.result = result;
|
||||
m_isRunning = false;
|
||||
return t_result;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,6 +166,12 @@ public:
|
|||
*/
|
||||
RecognitionResult getRecogitionResult(QImage *image);
|
||||
|
||||
/**
|
||||
* @brief 是否正在识别中
|
||||
* @return true:正在识别中 false:识别结束
|
||||
*/
|
||||
bool isRunning();
|
||||
|
||||
private :
|
||||
|
||||
/**
|
||||
|
@ -242,9 +248,14 @@ private :
|
|||
*/
|
||||
QString m_sLangs;
|
||||
|
||||
/**
|
||||
* @brief 是否正在识别中
|
||||
*/
|
||||
bool m_isRunning;
|
||||
|
||||
static TessOcrUtils *m_tessOcrUtils;
|
||||
|
||||
// static tesseract::TessBaseAPI *t_Tesseract;
|
||||
static tesseract::TessBaseAPI *t_Tesseract;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user