Leptonica --> tesseract --> OpenCV
来源:互联网 发布:linux中怎么复制文件 编辑:程序博客网 时间:2024/06/11 22:28
=== 02/02/2017更 ===
在测试APIExample时居然遇到问题
1). Example of iterator over the classifier choices for a single symbol unresolved external symbol "public: float thiscall tesseract::ChoiceIterator::Confidence(void)const
Solution
必须用静态编译的 libtesseract304-static.lib
参考 error LNK2019 #36 (提供答案的matthill(Matthew Hill)是OpenALPR的作者)
The ChoiceIterator is not included in the Tesseract 3.02 DLL. Tesseract 3.03 doesn't have that problem -- but it's not supported on Windows yet.
2). 静态编译/链接通过后又出现:
unresolved external symbol closesocket/connect/gethostbyname/recv/socket 等
Solution 链接 Ws2_32.lib
Unresolved external symbol LNK2019
C++ WinSock2 Errors
=== 14/12/16 ===
Visual C++ Compiler Options /MD, /MT, /LD (Use Run-Time Library)
How to link with the correct C Run-Time (CRT) library
C Run-Time Libraries
C Run-Time Library Reference
/clr (Common Language Runtime Compilation)
There are six types of reusable libraries:
- Static Single Threaded Library (Debug/Release)
- Static Multithreaded Library (Debug/Release)
- Dynamic Link Library (DLL)(Debug/Release)
Note Each library has a debug version and a release version.
The DLL is multithread-safe and a single-thread version of the CRT library is not provided for DLLs. If the reusable library or any user of the library is using multiple threads, then the library needs to be a multithread-safe library type.
=== 13/12/16 更 ===
Tesseract ViewerDebugging
Tried 3 hours!!
- Both
tesseract-ocr-setup-3.02.02.exe
andtesseract-ocr-setup-3.05.00dev.exe
has to run as administrator in command windows otherwise not working - at least 3.02 will output an error message where 3.05 is deadly silent (so this is meant to bedev
version huh?).- Have to rename the java file
- piccolo2d-core-3.0.jar —> piccolo-1.2.jar
- piccolo2d-extras-3.0.jar —> piccolox-1.2.jar
the order doesn’t seem to matterSCROLLVIEW_PATH
cannot include any space.C:\Program Files (x86)\Tesseract-OCR\java
not working even if MANY MANY other environmental variables DO work with this kind of path, so it’s Tesseract’sScrollView.jar
not handling things properly
Copy toC:\piccolo
so it will work- The MOST CRAZY thing is:
ScrollView.jar
under 3.05 not working at all- 3.02 has to use
ScrollView.jar
from 3.05 to work - WTF?!!!
=== 09/12/16 再小更 ===
It’s really been a while back and forth with trying, give up, trying again…
Now picked this lead up again, due to a recent small project. Check the solution part!!
=== 16/11/16 小更 ===
注意32BIT 和 64 bit DLL 的调用 The application was unable to start correctly (0xc000007b)' error
ImageProcessingTest
编译为32 bit,调用时必须保证对应的DLL 被使用,否则出现上述错误
Tesseract-OCR## Dependency
Very useful links nicely contains lots lots MS related information.
Downloading liblept pre-built binaries and header files for Windows
(Optional) Building the liblept library
(Optional) Building zlib, libjpeg, libpng, libtiff and giflib
Source Downloads
Image Library Versions
as of 24/08/2016
NOTE
- libpng:
- libtiff: a bit surprise that GunWin32 version of TIFF libraries actually works! Even though being the real old version of 3.8.2 - older than the one in Leptonica’s developer package notes
Libraries not quite work
========================
tesseract
It turned out to be quite tricky to get correct tesseract and ALL its dependencies working together, On Windows.
Initially I was looking for an installer for Windows so thought should be rather simple - it’s Windows anyway!
I’ve tried:
- tesseract-3.02.02-win32-lib-include-dirs.zip from Old Downloads from official site.
- it should compiled with lept168.[lib | dll ] from the error message when invoke the library
- Currently, there is no official Windows installer for newer versions.
- **NO IDEA THOUGH which version of Visual Studio it uses to build. Shouldn’t be VS2013 since it crash!
- tesseract-core-20160524.exe
- However, it’s not development kit.
- It’s a running application, with many DLLs
- It should be build by Cygwin, not usable to VS 2013
- tesseract-ocr-setup-3.02.02.exe
- Installed into C:\Program Files (x86)\Tesseract-OCR
- Again, built with lept168 but included all dependency files (libpng, tiff, jpeg, figlib, zlib) in \lib folder
- Again, not working with VS 2013.
- There is a
vs2008
folder underTesseract-OCR\tesseract-ocr
Solution
Following How to build Tesseract 3.03 with Visual Studio 2013 by Paul Vorbach, with his fork at tesseract4java/tesseract-vs2013
- I actually checkout and follows the link tesseract-vs2012 by Charles Weld, as it looks like the repository has also been updated to
VS 2013 support, both 64 and 32 bit.
and for newer tesseract 3.04 version too.tesseract-vs2012
has instructions of applying patches to git checkout.vs2013+64bit_support-git.patch
not working. Some email format error.- Just follow the instructions to use
vs2013+64bit_support.patch
- Very strange error of
src\boxfunc1.c(90): error C2275: 'lint32' : illegal use of this type as an expression
where lint32 is just typedef of int and been used absolutely everywhere.- As some guy suggested, just replace with
int
get it all compiled!!
Behind the curtain
What happens?
- Basically, there are two VS solutions/projects: tesseract itself and its dependencies
- The above tesseract4java/tesseract-vs2013 by Paul Vorbach and tesseract-vs2012 by Charles Weld are both FOR BUILDING DEPENDENCIES!
- Tesseract is checked out from official site and patched and built against these dependencies
Top level folder
tesseract-build\
, or could be any folder
Dependency folder
tesseract-build\tesseract-vs2012
ortesseract-build\tesseract-vs2013
- Once built, the build libraries and headers will be copied to ~\release.
- Copy the previously built dependencies to the parent directory (e.g. C:\tesseract-build)
Tesseract folder
- Check out from official repo to
C:\tesseract-build\tesseract\
- Apply patches, then build!
Once all done, the patched solution will copy the built libraries (e.g. libtesseract304.lib, libtesseract304.dll, libtesseract304-static.lib, libtesseract304-static.dll etc.) to
tesseract-build\lib\
32 bit vs. 64 bit version of tesseract and corresponding dependencies
- 32 bit
- OpenALPR
- ImageProcessingTest
- 注意不要调用64位的DLL 库(
libtesseract304.dll
和liblept171.dll
),否则出错- 见文首更新
(0xc000007b) error
- OpenCV 链接的是2.4.13 版本,32位
- 将 32位
libtesseract304.dll
和liblept171.dll
直接拷贝到可执行文件同目录下!- 64 bit
- OpenCV 3.1.0 (by default built with CUDA 7.0, which only has 64 bit version available on my machine)
- opencv_text module
- TextInTheWild
Mix of libraries
- Headers
- For leptonica, use the header files that come with the above built version under
tesseract-build\include\leptonica
- For tesseract itself, use the pre-compiled version
tesseract-3.02.02-win32-lib-include-dirs\include
- Libraries
- For leptonica library, use the one (
liblept171.lib/dll
) come with the above built version undertesseract-build\lib\Win32\
- For tesseract, the newly built version of course
tesseract-build\tesseract\vs2013\bin\Win32\DLL_Release
Now work as a charm!
OpenALPR
Not working
- Pre-compiled Windows binaries
openalpr-2.3.0-win-32bit.zip
andopenalpr-2.2.0-win-64bit.zip
- Both compiled with VS 2015 (looking for MSVCP140.dll at startup)
I choose the The Harder Way from Compilation instructions (Windows) since I’ve got ALL dependency compiled except OpenALPR itself.
Working version
- The OpenALPR src code provides
FindTesseract.cmake
undersrc\cmake_modules
. Modify the contents accordingly- Again, use the include path from
tesseract-3.02.02-win32-lib-include-dirs\include
rather thantesseract-build\tesseract\api
as the latter does not include all neccessary header files (e.g. publictypes.h, thresholder.h, platform.h) - how strang!- CMake Myth: FindTesseract.cmake
automatically
figured out the correct path when only providing the library names:libtesseract304
andliblept171
- CMAKE_MODULE_PATH is for Find_package() hence FindXXX.cmake
- CMAKE_PREFIX_PATH or OpenCV_DIR is for
OpenCVConfig.cmake
oropencv-config.cmake
OpenALPR on OS X
- Deadly simply!!
- Just follow Compilation instructions (OS X)
- Install
log4cplus
via MacPorts- Done!
OpenALPR on Windows!!!!!!
ooooh my my, why things are soooooo complicated on Windows!
Two lessons mainly, two new major knowledge points:
- CMakeFiles in OpenALPR are well organised, standard, could be useful for educational purpose
- Now understand the difference between
Module Mode
andConfig Mode
- The former uses
Find<package>.cmake
file located within your project- The latter uses
<package>Config.cmake
file located outside and produced by install command of other project- CMake: Of what use is find_package() if you need to specify CMAKE_MODULE_PATH anyway?
- Library headers and #define
- Logic is easy now: CMakeLists.txt —> FindTesseract.cmake —> LibFindMacros.cmake
- LibFindMacros.cmake is for
libfind_process
MACRO which sets necessary variables, e.g. ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS, ${PREFIX}_LIBRARIES- For some reason, the man behind OpenALPR decides that for Windows system, it should use static library rather than DLL.
- alpr.exe is configured to link with openalpr-static
- which in turn, requires the static version of tesseract - thank GOD I’ve decide to build my own version of tesseract from the scatch!
Run alpr.exe
on Windows
$HOME\Software\openalpr\src\build-win[Release | Debug]
$HOME\Software\openalpr\config\ –config openalpr.conf.win
runtime_dir = $HOME/Software/openalpr/runtime_data
Problems
- Main problem
- Config file
- wrong paths in the provided windows release
- Feed program with
openalpr.conf.defaults
, remember to modifyruntime_dir
to point toopenalpr/runtime_data
- Debugging Issue
- Crashed on
cv::findContours()
- no idea why!Debug Assertion Failed! Expression: _pFirstBlock == pHead
- Debug Assertion Failed! Expression: _pFirstBlock == pHead
Run alpr
on Mac - Easy Peasy!
Manual call graph
- detectandshow( ) —> Alpr::recognize(…) —> AlprImpl::recognize( unsigned char* pixelData, int bytesPerPixel, …) —> AlprImpl::recognize(cv::Mat img, std::vector regionsOfInterest) —> AlprImpl::recognizeFullDetails(…) —> AlprImpl::analyzeSingleCountry(…) —> Detector::detect(…) —> LicensePlateCandidate lp(&pipeline_data); —> LicensePlateCandidate::recognize() —> CharacterAnalysis::analyze() —> TextContours::load(cv::Mat threshold)
About OpenALPR detector
License Plate Recognition - Determining Color Range For Pixel Comparison
Check out OpenALPR (http://www.openalpr.com). It takes a different approach for plate localization -- it uses trained LBP patterns. You may want to use this library in addition to your color-based detection for even greater accuracy. For example, OpenALPR can detect potential plate regions, and then simply verify that a certain percentage of the area is yellow-ish.
- Leptonica --> tesseract --> OpenCV
- Leptonica
- 最新Tesseract-OCR源码编译1——leptonica编译
- Tesseract + opencv
- Tesseract/OpenCV on Android
- OpenCV + Tesseract on Android
- opencv与tesseract
- Qt、tesseract、OpenCV 环境配置
- C++及OpenCV中调用Tesseract
- tesseract識別OPENCV PIL之間轉換例子
- opencv+tesseract破解教务管理验证码
- Ubuntu16.04 编译OpenCV 和 Tesseract-OCR
- OpenCV && Tesseract-OCR in Android Studio
- 【OpenCV】How to Use Tesseract with C++ or OpenCV
- leptonica 表格图像分析
- checking for LEPTONICA... no
- OpenCV+Tesseract进行OCR学习(一)文字提取
- OpenCV+Tesseract进行OCR学习(二)文字识别
- 自定义VC作为iOS程序的RootVC
- Pods-frameworks.sh: No such file or directory、Pods-resources.sh: No such file or directory
- android webview设置内容的字体大小
- liunxqu安装nginx
- 阻塞赋值和非阻塞赋值
- Leptonica --> tesseract --> OpenCV
- machine-learning:提纲
- [图形学] 纹理映射原理详解
- [读书笔记] 深入探索C++对象模型-第二章《构造函数语义学》(下)
- OpenCV 简单的图像混合和滑动条使用
- PAT.乙级1014. 福尔摩斯的约会 (20)
- 7种排序算法的C++实现
- 插入排序(2)
- Day5