用tesseract调用程序调用出现问题,后面改用飞桨paddleocr,捣鼓了三周才弄好。
将自己的过程总结一下:
paddleocr:https://github.com/PaddlePaddle/PaddleOCR
一、准备:
- 1. PaddleOCR2.6
- 2. VS2017,因为在windows下开发,配置相关驱动环境,就不推荐cmake编译paddleocr
- 3. QT5.15.2 安装时选择MSVC编译器 VC2015对应VS2017
- 4. Opencv4.5.0
二、环境搭建
qt+opencv+paddleocr环境搭建这块主要参考使用qt+PaddleOCR做一个OCR软件demo
截图程序参考Qt项目中,实现屏幕截图功能的模块详细实现(可通用)
注意事项:
1.查看paddleocr 2.6 cpp程序,目前找到config.txt对应的解析代码,所以只能在自己的代码中指定各种参数。
2.qt编程环境的详细设置,直接给出qt的.pro配置文件:
QT += core gui \
serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG(debug, debug|release) {
QMAKE_CXXFLAGS_DEBUG += /MTd
}
CONFIG(release, debug|release) {
QMAKE_CXXFLAGS_RELEASE += /MT
}
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp \
screenocr.cpp \
screenwidget.cpp \
src/args.cpp \
src/clipper.cpp \
src/ocr_cls.cpp \
src/ocr_det.cpp \
src/ocr_rec.cpp \
src/paddleocr.cpp \
src/paddlestructure.cpp \
src/postprocess_op.cpp \
src/preprocess_op.cpp \
src/structure_layout.cpp \
src/structure_table.cpp \
src/utility.cpp
HEADERS += \
include/args.h \
include/clipper.h \
include/dirent.h \
include/ocr_cls.h \
include/ocr_det.h \
include/ocr_rec.h \
include/paddleocr.h \
include/paddlestructure.h \
include/postprocess_op.h \
include/preprocess_op.h \
include/structure_layout.h \
include/structure_table.h \
include/utility.h \
mainwindow.h \
screenocr.h \
screenwidget.h
FORMS += \
mainwindow.ui
#Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\paddle\fluid\inference
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\paddle\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\protobuf\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\glog\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\gflags\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\xxhash\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\zlib\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\boost
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\eigen3
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\mklml\include
INCLUDEPATH += $$PWD\3rdparty\paddle_inference_install_dir\third_party\install\mkldnn\include
INCLUDEPATH += D:\opencv4.5.0\opencv\build\include \
D:\opencv4.5.0\opencv\build\include\opencv2 \
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\paddle\lib -lpaddle_inference
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\mklml\lib -lmklml
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\mklml\lib -llibiomp5md
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\mkldnn\lib -lmkldnn
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\glog\lib -lglog
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\gflags\lib -lgflags_static
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\protobuf\lib -llibprotobuf
LIBS += -L$$PWD\3rdparty\paddle_inference_install_dir\third_party\install\xxhash\lib -lxxhash
LIBS += -LD:\opencv4.5.0\opencv\build\x64\vc15\lib -lopencv_world450
win32:CONFIG(release, debug|release): LIBS += -L'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64/' -lShLwApi
else:win32:CONFIG(debug, debug|release): LIBS += -L'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64/' -lShLwApid
INCLUDEPATH += 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64'
DEPENDPATH += 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64'
三、部署,安装环境变量
在release文件夹下生产了可执行程序,但是要在其他电脑上运行,需要做哪些工作?
qt msvc编译器 对应的windeployqt.exe 找到对应的程序和库文件等。
在目标计算机上安装MSVC++ 2015
D:\Qt\Qt5.12.12\5.12.12\msvc2017_64\bin
D:\opencv4.5.0\opencv\build\x64\vc15\bin
最后识别文字可能会出现乱码:
将ppocr_keys_v1.txt的编码改成ANSI,完美解决。
这篇文章将自己的所有程序设计和移植过程作了详细介绍,里面有些多余步骤,读者可以根据自己的要求作取舍。
本站所有文章均为原创,欢迎转载,请注明文章出处:(20条消息) QT5+VS2017+PaddleOCR2.6总结_爱养生的程序猿的博客-CSDN博客, 本人会不定期对自己的博文进行修改更正,请访问本文的最新版本。