Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
da4d40b
chore: Sync by https://github.com/linuxdeepin/.github/commit/2e5e092b…
May 10, 2023
484a27c
chore: Sync by https://github.com/linuxdeepin/.github/commit/559e9116…
Jul 10, 2023
268596b
fix: set CMAKE_INSTALL_LIBDIR as lib (#25)
wineee Jan 30, 2023
d6a1cd0
chore: 安装路径Prefix规范化
starhcq Jan 30, 2023
eea88ce
feat: 后端切换至dtkocr (#27)
Mar 10, 2023
60faff4
feat: 更新翻译文件 (#29)
Mar 27, 2023
bbb81f2
chore(CI): add OBS workflows
tsic404 Mar 23, 2023
7ebab20
chore(CI): fix lintian error
tsic404 Apr 13, 2023
8a1dd54
fix: 修改changelog
pengfeixx Apr 13, 2023
d8bb86b
fix: 修复编译错误
pengfeixx Apr 13, 2023
7f8a72b
chore: Sync by https://github.com/linuxdeepin/.github/commit/2e5e092b…
May 10, 2023
53bfd5c
chore: Sync by https://github.com/linuxdeepin/.github/commit/559e9116…
Jul 10, 2023
c6bb17b
fix: Update changelog
pengfeixx Aug 16, 2023
f28e57c
fix: wrong combobox window palette
rb-union Jul 22, 2024
2402086
feat: [translation]add transifex config
add-uos Sep 19, 2024
c196fa9
feat: Adapt Treeland
lzwind Oct 21, 2024
e64f221
chore: update version
lzwind Oct 22, 2024
096135f
fix: Fixed the Compact Mode issue (#42)
pengfeixx Oct 23, 2024
4d77891
fix: rmove kwayland-shell
lzwind Nov 6, 2024
ec8f87b
fix: ui modify
myk1343 Mar 10, 2025
5ab989e
fix: 显示修改
myk1343 Mar 10, 2025
d72cf3a
fix: Optimized vulkan dependencies
pengfeixx May 19, 2025
6129799
feat: Add DConfig source code.
lichaofan2008 Sep 17, 2025
32a8c47
fix: On some device models, using GPU acceleration causes crashes.
lichaofan2008 Sep 17, 2025
6a89706
fix: Process crash caused by closing the application.
lichaofan2008 Sep 22, 2025
8c1d983
chore: merge remote-tracking branch 'upstream/master'
dengzhongyuan365-dev Nov 27, 2025
e7eef84
chore: Update build dependencies and translation file paths
dengzhongyuan365-dev Nov 27, 2025
3189776
chore: Merge remote-tracking branch 'upstream/master'
dengzhongyuan365-dev Nov 28, 2025
c05aa73
chore: Add SPDX license header to install_dconfig.cmake
dengzhongyuan365-dev Dec 2, 2025
d7f45e8
chore: Update version to 6.5.14
dengzhongyuan365-dev Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions assets/configs/deepin-ocr.common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"IsGpuEnable": {
"value": true,
"serial": 0,
"flags": ["global"],
"name": "Using GPU acceleration on special machine",
"name[zh_CN]": "在特殊机型上是否使用GPU加速",
"description": "Using GPU acceleration on special machine",
"description[zh_CN]":"在特殊机型上是否使用GPU加速",
"permissions": "readwrite",
"visibility": "private"
}
}
}
43 changes: 43 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
deepin-ocr (6.5.14) unstable; urgency=medium

* merge release/eagle to master

-- dengzhongyuan <dengzhongyuan@uniontech.com> Tue, 02 Dec 2025 14:27:14 +0800

deepin-ocr (6.5.13) unstable; urgency=medium

* chore: Update compiler flags for security enhancements
Expand Down Expand Up @@ -115,6 +121,43 @@ deepin-ocr (1.1.0) unstable; urgency=medium

-- TagBuilder <wangzhengyang@uniontech.com> Fri, 10 Mar 2023 10:16:55 +0800

deepin-ocr (1.5.2) unstable; urgency=medium

*Optimized vulkan dependencies

-- xiepengfei <xiepengfei@uniontech.com> Mon, 19 May 2025 15:33:24 +0800

deepin-ocr (1.5.1) unstable; urgency=medium

*remove env kwayland-shell

-- Liu zheng <liuzheng@uniontech.com> Wed, 06 Nov 2024 15:33:24 +0800

deepin-ocr (1.5.0) unstable; urgency=medium

* adapt treeland

-- Liu zheng <liuzheng@uniontech.com> Tue, 22 Oct 2024 20:32:59 +0800

deepin-ocr (1.1.2) unstable; urgency=medium

* New version 1.1.2.

-- xiepengfei <xiepengfei@uniontech.com> Wed, 16 Aug 2023 11:43:41 +0800

deepin-ocr (1.1.1) unstable; urgency=medium

* New version 1.1.1.

-- xiepengfei <xiepengfei@uniontech.com> Thur, 13 Apr 2023 15:08:32 +0800

deepin-ocr (1.1.0) unstable; urgency=medium

* Use dtkocr instead of PaddleOCR-NCNN
* Add language change

-- TagBuilder <wangzhengyang@uniontech.com> Fri, 10 Mar 2023 10:16:55 +0800

deepin-ocr (1.0) unstable; urgency=medium

* Pre-release for deepin-ocr 1.0
Expand Down
15 changes: 8 additions & 7 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ Priority: optional
Maintainer: Deepin Packages Builder <packages@deepin.com>
Build-Depends: debhelper (>= 11),
cmake,
pkg-config,
qt6-base-dev,
qt6-tools-dev,
qt6-tools-dev-tools,
libdtk6widget-dev,
libdtk6ocr-dev,
pkg-config,
qt6-base-dev [!mipsel !mips64el] | qtbase5-dev,
qt6-tools-dev [!mipsel !mips64el] | qttools5-dev,
qt6-tools-dev-tools [!mipsel !mips64el] | qttools5-dev-tools,
libdtk6widget-dev [!mipsel !mips64el] | libdtkwidget-dev,
libdtk6core-dev [!mipsel !mips64el] | libdtkcore-dev,
libncnn-dev,
libopencv-mobile-dev
libopencv-mobile-dev,
libdtk6ocr-dev | libdtkocr-dev
Standards-Version: 4.1.3
Homepage: http://www.deepin.org/

Expand Down
34 changes: 34 additions & 0 deletions install_dconfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

# expect that all dconfigs of plugin is saved in ./assets/configs
function(INSTALL_DCONFIG CONFIG_NAME)
set(DConfigPath ${CMAKE_SOURCE_DIR}/assets/configs)
message("DConfigPath: ${DConfigPath}")
set(AppId "deepin-ocr")
set(ConfigName ${CONFIG_NAME})

if (DEFINED DSG_DATA_DIR)
message("-- DConfig is supported by DTK")
message("---- AppId: ${AppId}")
message("---- Base: ${DConfigPath}")
message("---- Files: ${DConfigPath}/${ConfigName}")
if(COMMAND dtk_add_config_meta_files)
message(STATUS "Using dtk_add_config_meta_files")
dtk_add_config_meta_files(APPID ${AppId}
BASE ${DConfigPath}
FILES ${DConfigPath}/${ConfigName})
else()
message(STATUS "Using dconfig_meta_files")
dconfig_meta_files(APPID ${AppId}
BASE ${DConfigPath}
FILES ${DConfigPath}/${ConfigName})
endif()
else()
set(DSG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/dsg)
message("-- DConfig is NOT supported by DTK, install files into target path")
message("---- InstallTargetDir: ${DSG_DATA_DIR}/configs")
install(FILES ${DConfigPath}/${ConfigName} DESTINATION ${DSG_DATA_DIR}/configs/${AppId})
endif()
endfunction()
20 changes: 19 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
cmake_minimum_required(VERSION 3.10)
project(deepin-ocr)

#玲珑构建依赖目录
include_directories(${CMAKE_INSTALL_PREFIX}/include)

set(ENABLE_Qt6 ON CACHE BOOL "Build with Qt6")
find_package(Qt6 QUIET)

Expand All @@ -24,6 +27,7 @@ include_directories(${CMAKE_INSTALL_PREFIX}/include)
# for Qt
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
Expand Down Expand Up @@ -68,12 +72,14 @@ include_directories(view)
include_directories(service)
include_directories(engine)
include_directories(util)
include_directories(utils)

aux_source_directory(. allSource)
aux_source_directory(./view allSource)
aux_source_directory(./service allSource)
aux_source_directory(./engine allSource)
aux_source_directory(./util allSource)
aux_source_directory(./utils allSource)

# translation
file(GLOB TargetTsFiles LIST_DIRECTORIES false ../translations/${PROJECT_NAME}*.ts)
Expand Down Expand Up @@ -153,7 +159,11 @@ endif()

# for dtk
find_package(PkgConfig REQUIRED)
pkg_check_modules(ocr_lib REQUIRED dtk6ocr)
if(SUPPORT_QT6)
pkg_check_modules(ocr_lib REQUIRED dtk6ocr)
else()
pkg_check_modules(ocr_lib REQUIRED dtkocr)
endif()
pkg_check_modules(InferenceEngine REQUIRED ncnn opencv_mobile)
target_include_directories(${PROJECT_NAME} PUBLIC ${ocr_lib_INCLUDE_DIRS})
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Widget)
Expand Down Expand Up @@ -193,6 +203,11 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif()

#dde项目,期望CMAKE_INSTALL_PREFIX为/usr
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()

# install
set(PREFIX ${CMAKE_INSTALL_PREFIX})
set(TranslationDir ${PREFIX}/share/${PROJECT_NAME}/translations)
Expand All @@ -211,3 +226,6 @@ install(FILES ${LangSrcs} DESTINATION ${TranslationDir})
install(FILES ../deepin-ocr.desktop DESTINATION ${DesktopDir})
install(FILES ../assets/deepin-ocr.svg DESTINATION ${AppIconDir})
install(FILES ../com.deepin.Ocr.service DESTINATION ${DBusServiceDir})

include(${CMAKE_SOURCE_DIR}/install_dconfig.cmake)
INSTALL_DCONFIG("deepin-ocr.common.json")
28 changes: 23 additions & 5 deletions src/engine/OCREngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "OCREngine.h"
#include <QFileInfo>
#include <DOcr>

Check warning on line 6 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DOcr> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>

Check warning on line 7 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QFileInfo>

Check warning on line 8 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QFileInfo> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>

Check warning on line 9 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <dconfigmanager.h>

Check warning on line 10 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dconfigmanager.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include "util/log.h"

Check warning on line 11 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "util/log.h" not found.

OCREngine *OCREngine::instance()
{
Expand All @@ -25,7 +28,7 @@
//此处存在产品设计缺陷: 无法选择插件,无鉴权入口,无性能方面的高级设置入口
//因此此处直接硬编码使用默认插件
qCInfo(dmOcr) << "Initializing OCR driver";

ocrDriver = new Dtk::Ocr::DOcr;
const QString ocrV5 = "PPOCR_V5";
bool load = false;
Expand All @@ -47,8 +50,19 @@
}

ocrDriver->setUseMaxThreadsCount(2);
if (!isGpuEnable()) {
qWarning() << "GPU is not enabled";
return;
}

QProcess kxProc;
kxProc.setProgram("bash");
kxProc.setArguments({"-c", "lscpu | grep name"});
kxProc.start();
kxProc.waitForFinished();
QString cpuInfo = kxProc.readAllStandardOutput();
QFileInfo mtfi("/dev/mtgpu.0");
if (mtfi.exists()) {
if (mtfi.exists() | !cpuInfo.contains("KX-7000")) {

Check warning on line 65 in src/engine/OCREngine.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Suspicious expression. Boolean result is used in bitwise operation. The operator '!' and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
qCInfo(dmOcr) << "GPU device found, enabling Vulkan hardware acceleration";
ocrDriver->setUseHardware({{Dtk::Ocr::HardwareID::GPU_Vulkan, 0}});
}
Expand All @@ -67,9 +81,8 @@
m_isRunning = true;

ocrDriver->analyze();

m_isRunning = false;
QString result = ocrDriver->simpleResult();
m_isRunning = false;
qCInfo(dmOcr) << "OCR recognition completed";
return result;
}
Expand All @@ -88,3 +101,8 @@
}
return success;
}

bool OCREngine::isGpuEnable()
{
return DConfigManager::instance()->value(COMMON_GROUP, COMMON_ISGPUENABLE, true).toBool();
}
6 changes: 6 additions & 0 deletions src/engine/OCREngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class OCREngine
private:
OCREngine();
~OCREngine() = default;
// 删除拷贝构造函数和赋值运算符,防止拷贝实例
OCREngine(const OCREngine &) = delete;
OCREngine &operator=(const OCREngine &) = delete;

// 某些机型,使用GPU进行OCR识别,会导致OCR崩溃
bool isGpuEnable();

Dtk::Ocr::DOcr *ocrDriver;
std::atomic_bool m_isRunning;
Expand Down
18 changes: 16 additions & 2 deletions src/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ void MainWidget::setupUi(QWidget *Widget)
m_noResult->setAlignment(Qt::AlignCenter);
m_noResult->setText(tr("No text recognized"));
m_resultWidget->addWidget(m_noResult);
m_noResult->setVisible(false);

connect(m_loadingOcr, &loadingWidget::sigChangeSize, [ = ] {
loadingUi();
Expand Down Expand Up @@ -207,6 +208,7 @@ void MainWidget::setupUi(QWidget *Widget)
}
ocrSetting->setValue("language", resultLanguage);
runRec(false);
m_noResult->setVisible(false);
});

m_buttonHorizontalLayout->addWidget(recLabel, 0, Qt::AlignRight);
Expand Down Expand Up @@ -251,7 +253,7 @@ void MainWidget::setupUi(QWidget *Widget)
undoBtn->setIcon(DDciIcon(QString(":/assets/icon_return.dci")));
undoBtn->setMaximumSize(36, 36);
undoBtn->setIconSize(QSize(14, 14));
mainWindow->titlebar()->addWidget(undoBtn, Qt::AlignRight);
// mainWindow->titlebar()->addWidget(undoBtn, Qt::AlignRight);
connect(undoBtn, &QPushButton::clicked, m_plainTextEdit, &QPlainTextEdit::undo);
connect(m_plainTextEdit, &QPlainTextEdit::undoAvailable, undoBtn, &QPushButton::setEnabled);
undoBtn->setEnabled(false);
Expand All @@ -262,11 +264,22 @@ void MainWidget::setupUi(QWidget *Widget)
redoBtn->setIcon(DDciIcon(QString(":/assets/icon_advance.dci")));
redoBtn->setMaximumSize(36, 36);
redoBtn->setIconSize(QSize(14, 14));
mainWindow->titlebar()->addWidget(redoBtn, Qt::AlignRight);
// mainWindow->titlebar()->addWidget(redoBtn, Qt::AlignRight);
connect(redoBtn, &QPushButton::clicked, m_plainTextEdit, &QPlainTextEdit::redo);
connect(m_plainTextEdit, &QPlainTextEdit::redoAvailable, redoBtn, &QPushButton::setEnabled);
redoBtn->setEnabled(false);

QWidget *pWidget = new QWidget;
QHBoxLayout *pLay = new QHBoxLayout;
pWidget->setWindowFlags(pWidget->windowFlags() | Qt::FramelessWindowHint);
pWidget->setContentsMargins(0, 0, 0, 0);
pLay->setContentsMargins(0, 0, 0, 0);
pWidget->setLayout(pLay);
pLay->addWidget(undoBtn);
pLay->addSpacing(10);
pLay->addWidget(redoBtn);
mainWindow->titlebar()->addWidget(pWidget, Qt::AlignRight);

if (DGuiApplicationHelper::instance()->sizeMode() == DGuiApplicationHelper::CompactMode) {
languageSelectBox->setFixedSize(160, 24);
m_copyBtn->setMaximumSize(QSize(24, 24));
Expand Down Expand Up @@ -509,6 +522,7 @@ void MainWidget::loadString(const QString &string)
}
} else {
resultEmpty();
m_noResult->setVisible(true);
}
}

Expand Down
Loading