OCR(一) windows 下编译 Opencv4.9.0+TessRact5.2.3 识别图片文字

本文详细介绍了在Windows环境下编译Tesseract OCR库和Leptonica图像处理库的步骤,包括下载依赖库、配置编译环境、编译各个组件、设置环境变量以及最终的测试验证。涉及的库包括zlib、JPEG、PNG、libgif、tifflib、nasm、libjpeg-turbo、leptonica和tesseract。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

1.下载

2. 编译tesseract

2.1 编译基础依赖库

2.1.1 zlib  

 2.1.2  jpegsr9f

2.1.3  lpng1643

2.1.4  libgif

2.2 编译tifflib  

2.3  配置nasm到系统环境中

2.4  编译 libjpeg-turbo

2.5  编译leptonica

2.6  编译tesseract

2.7  tessdata下载

2.8 demo验证

3. opencv +tesseract编译

3.1 opencv 编译

3.2 报错

3.2.1 报错1

3.2.2 报错2

3.3 Demo示例


1.下载

tesseract5.3.2

leptonica1.83.1

libjpeg-turbo-2.1.5.1

nasm-2.16.01

libtiff-4.5.0 

zlib1.3.1
jpegsr9f

lpng643

libtiff-4.5.0

libgif

或者点击全部下载

2. 编译tesseract

2.1 编译基础依赖库

这里只编译release版本的,debug或者32位的可参考自行编译。

2.1.1 zlib  

解压后,调用cmake ,输入相关路径,点击【configure】如图:

配置编译环境(这里都是x64为例,后续不再复缀),然后点击【finish】

点击【generate】

点击【open project】, 打开VS,

编译成功

 2.1.2  jpegsr9f

解压后使用 VS 工具,进入项目所在目录, 输入 NMAKE /f makefile.vc  setup-v16  (vs2022 其余版本命令自行查找)生成项目

开发人员命令提示符 - 将环境设置为使用 32 位 x86 本机工具生成 32 位 x86 本机代码。
x86 本机工具命令提示符 - 将环境设置为使用 32 位 x86 本机工具生成 32 位 x86 本机代码。
x64 本机工具命令提示符 - 将环境设置为使用 64 位 x64 本机工具生成 64 位 x64 本机代码。
x86_x64 兼容工具命令提示符 - 将环境设置为使用 32 位 x86 本机工具生成 64 位 x64 本机代码。
x64_x86 兼容工具命令提示符 - 将环境设置为使用 64 位 x64 本机工具生成 32 位 x86 本机代码。

​​

解决1:

可以先用everything查找,没有,创建构建我win32.mak文件,内容如下:

# Win32.Mak - Win32 application master NMAKE definitions file for the
#     Microsoft Windows SDK programming samples
#           Copyright (C) Microsoft Corporation
# -------------------------------------------------------------------------
# This files should be included at the top of all MAKEFILEs as follows:
#  !include <Win32.Mak>
# -------------------------------------------------------------------------
#
# Define APPVER = [ 4.0 | 5.0 | 5.01 | 5.02 | 6.0 | 6.1] prior to including win32.mak to get
#  build time checking for version dependencies and to mark the executable
#  with version information.
#
# Define TARGETOS = [ WIN95 | WINNT | BOTH ] prior to including win32.mak
#  to get some build time checking for platform dependencies.
#
# Define TARGETLANG = [ LANG_JAPANESE | LANG_CHINESE | LANG_KOREAN ] prior
#  to including win32.mak to getcompile & link flags for building
#  applications to run on Far-East Windows. (This is an optional parameter.
#  The system locale is the default.)
#
# Define _WIN32_IE = [ 0x0300 | 0x0400 | 0x0500 | 0x0600 | 0x0700 | 0x0800] prior to including win32.mak to
#  get compile and link flags for building applications and components to
#  run on Internet Explorer. (This is an optional parameter.  IE 4.0 is
#  the default.)
#
# -------------------------------------------------------------------------
# NMAKE Options
#
# Use the table below to determine the additional options for NMAKE to
# generate various application debugging, profiling and performance tuning
# information.
#
# Application Information Type         Invoke NMAKE
# ----------------------------         ------------
# For No Debugging Info                nmake nodebug=1
# For Working Set Tuner Info           nmake tune=1
# For Call Attributed Profiling Info   nmake profile=1
#
# Note: The three options above are mutually exclusive (you may use only
#       one to compile/link the application).
#
# Note: creating the environment variables NODEBUG, TUNE, and PROFILE is an
#       alternate method to setting these options via the nmake command line.
#
# Note: TUNE and PROFILE do nothing for 64bit compilation
#
# Additional NMAKE Options             Invoke NMAKE
# ----------------------------         ------------
# For No ANSI NULL Compliance          nmake no_ansi=1
# (ANSI NULL is defined as PVOID 0)
#
# =========================================================================
# Build Rules Quick Start
#
# To build one of the following types of executables, use the specified
# compiler and linker command-line options.
#
#  ---------------------------------------------------------------------------
#   To build:         |  Compiler Options      | Linker options (pick one
#                     |                        | line. con = console,
#                     |                        | gui = GUI, ole = GUI OLE)
#  ---------------------------------------------------------------------------
#  Single threaded    | cdebug cflags cvars    | ldebug guilflags guilibs
#  app with static    |                        | ldebug conlflags conlibs
#  CRT                |                        | ldebug guilflags olelibs
#  ---------------------------------------------------------------------------
#  Multithreaded app  | cdebug cflags cvarsmt  | ldebug guilflags guilibsmt
#  with static CRT    |                        | ldebug conlflags conlibsmt
#                     |                        | ldebug guilflags olelibsmt
#  ---------------------------------------------------------------------------
#  Single or multi-   | cdebug cflags cvarsdll | ldebug guilflags guilibsdll
#  threaded app with  |                        | ldebug conlflags conlibsdll
#  DLL version of CRT |                        | ldebug guilflags olelibsdll
#  (MSVCRT.DLL)       |                        |
#  ---------------------------------------------------------------------------
#  DLL with static    | cdebug cflags cvarsmt  | ldebug dlllflags guilibsmt
#  CRT*               |                        | ldebug dlllflags conlibsmt
#                     |                        | ldebug dlllflags olelibsmt
#  ---------------------------------------------------------------------------
#  DLL with DLL       | cdebug cflags cvarsdll | ldebug dlllflags guilibsdll
#  version of CRT     |                        | ldebug dlllflags conlibsdll
#  (MSVCRT.DLL)       |                        | ldebug dlllflags olelibsdll
#  ---------------------------------------------------------------------------
#
#  * Always make DLLs multithreaded because a DLL has no way to know whether
#    the calling application has multiple threads, and has no way to prevent
#    multithreaded apps from loading it.
#
#  To specify an Intel x86 build that defaults to stdcall, add scall to the
#  list of compiler options.
#
# =================================&

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值