在标记为复制或重复问题之前,请先阅读整个问题.
我能够在现有的情况下做到如下:
tesseract和处理图像leptonica.例如,如果输入是这张照片:
照片开始

照片结束
我想要的是能够为这张照片获得相同的准确度
没有生成块.
我用来初始化从图像中提取和提取文本的代码如下:
对于tesseract的初始化
在.h文件中
tesseract::TessBaseAPI *tesseract;
uint32_t *pixels;
Run Code Online (Sandbox Code Playgroud)
在.m文件中
tesseract = new tesseract::TessBaseAPI();
tesseract->Init([dataPath cStringUsingEncoding:NSUTF8StringEncoding], "eng");
tesseract->SetPageSegMode(tesseract::PSM_SINGLE_LINE);
tesseract->SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
tesseract->SetVariable("language_model_penalty_non_freq_dict_word", "1");
tesseract->SetVariable("language_model_penalty_non_dict_word ", "1");
tesseract->SetVariable("tessedit_flip_0O", "1");
tesseract->SetVariable("tessedit_single_match", "0");
tesseract->SetVariable("textord_noise_normratio", "5");
tesseract->SetVariable("matcher_avg_noise_size", "22");
tesseract->SetVariable("image_default_resolution", "450");
tesseract->SetVariable("editor_image_text_color", "40");
tesseract->SetVariable("textord_projection_scale", "0.25");
tesseract->SetVariable("tessedit_minimal_rejection", "1");
tesseract->SetVariable("tessedit_zero_kelvin_rejection", "1");
Run Code Online (Sandbox Code Playgroud)
从图像中获取文本
- (void)processOcrAt:(UIImage *)image
{
[self setTesseractImage:image];
tesseract->Recognize(NULL);
char* utf8Text = tesseract->GetUTF8Text();
int conf = tesseract->MeanTextConf();
NSArray *arr = [[NSArray alloc]initWithObjects:[NSString stringWithUTF8String:utf8Text],[NSString stringWithFormat:@"%d%@",conf,@"%"], nil]; …Run Code Online (Sandbox Code Playgroud)
我正在编写一个处理原生C(NDK r10d)图片的Android应用程序.该代码运行良好,直到最近的ART介绍对JNI更严格.因此代码与Dalvik一起工作正常(例如在Lolipop之前的设备上),但ii在最新的手机上创建了一个SIGENV.
我现在得到错误:
04-26 16:18:34.169: E/art(21443): 0xb4a2dd00 SpaceTypeMallocSpace begin=0x12c00000,end=0x12e01000,limit=0x32c00000,size=2MB,capacity=192MB,non_growth_limit_capacity=512MB,name="main rosalloc space"]
04-26 16:18:34.170: E/art(21443): 0xb4ae5640 allocspace main rosalloc space live-bitmap 3[begin=0x12c00000,end=0x32c00000]
04-26 16:18:34.170: E/art(21443): 0xb4ae5660 allocspace main rosalloc space mark-bitmap 3[begin=0x12c00000,end=0x32c00000]
04-26 16:18:34.170: E/art(21443): 0xb4874120 SpaceTypeImageSpace begin=0x6f5ab000,end=0x6ff21e58,size=9MB,name="/data/dalvik-cache/arm/system@framework@boot.art"]
04-26 16:18:34.170: E/art(21443): 0xb4875220 imagespace /data/dalvik-cache/arm/system@framework@boot.art live-bitmap 0[begin=0x6f5ab000,end=0x6ff21f00]
04-26 16:18:34.170: E/art(21443): 0xb4875220 imagespace /data/dalvik-cache/arm/system@framework@boot.art live-bitmap 0[begin=0x6f5ab000,end=0x6ff21f00]
04-26 16:18:34.170: E/art(21443): 0xb49d9dd0 SpaceTypeZygoteSpace begin=0x72f09000,end=0x740c7000,size=17MB,name="Zygote space"]
04-26 16:18:34.170: E/art(21443): 0xb4875440 allocspace zygote / non moving space live-bitmap 0[begin=0x72f09000,end=0x740c7000]
04-26 16:18:34.170: E/art(21443): 0xb4875460 allocspace zygote / non …Run Code Online (Sandbox Code Playgroud) 我正在使用 python-tesseract 包装器对图像进行 OCR。但是,对于某些图像,我得到的结果与命令行中的 tesseract 命令获取的结果不同。在命令行我做tesseract myimg.png myimg && more myimg.txt
但是,python tesseract 包装器的结果是不同的。
我怀疑这是因为可能没有从包装器中找到 liblept,因为这一行结果为 False:
import tesseract
import ctypes
import os
print "HAVE_LIBLEPT=",tesseract.isLibLept()
Run Code Online (Sandbox Code Playgroud)
有时我在使用包装器时会收到这些错误,但我不会从命令行 tesseract:
Error in pixReduceRankBinary2: hs must be at least 2
Error in pixDilateBrick: pixs not defined
Error in pixExpandReplicate: pixs not defined
Error in pixAnd: pixs1 not defined
Error in pixDilateBrick: pixs not defined
Error in pixExpandReplicate: pixs not defined
Error in pixAnd: pixs2 not defined
Telephone Company Suspicious Activity
Run Code Online (Sandbox Code Playgroud)
有谁知道不匹配的可能原因是什么?以及如何告诉包装器找到 liblept,因为命令行 tesseract …
我已经在我的MBP上运行了tesseract和Tess4J一段时间了.今天我开始将我的应用程序迁移到服务器并开始在服务器上安装所有内容.在tomcat中运行Tess4J之前,我尝试运行一个简单的java程序,以确保一切都很好,花花公子.不是...
tesseract myimage.jpg mytext产生数据但是,运行使用Tess4j的简单类会产生以下错误:
线程"main"中的异常java.lang.UnsatisfiedLinkError:无法加载库'tesseract':libtesseract.so:无法打开共享对象文件:没有这样的文件或目录
到目前为止我做了什么
sudo ldconfig在安装tesseract后跑了/usr/local/lib/libtesseract.so服务器上的文件夹包含以下文件
myimge.png
ghost4j-0.3.1.jar
jai_imageio.jar
jna.jar
maslab.jar
pngj.jar
tess4j.jar
TesseractExample.class
TesseractExample.java
Run Code Online (Sandbox Code Playgroud)
tesseract -v产生:
tesseract -v
tesseract 3.02.02
leptonica-1.69
libjpeg 6b : libpng 1.2.49 : libtiff 3.9.4 : zlib 1.2.3
Run Code Online (Sandbox Code Playgroud)
题
如何让Tess4J知道libtesseract.so确实存在?enter code here
我正在遵循这个 tesseract 教程中的教程,并且一切都很顺利,直到我实际运行 Java 代码。当我尝试时
new TessBaseApi();
Run Code Online (Sandbox Code Playgroud)
它抛出以下错误
Error Code: 2
Output:
In file included from tesstwo/src/main/jni/com_googlecode_leptonica_android/box.cpp:17:0:
tesstwo/src/main/jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
make: ***
Run Code Online (Sandbox Code Playgroud)
我已经调查/jni/com_googlecode_leptonica_android/src/src并找到了allheaders.h那里的文件。我有一种感觉,我的道路是错误的,但我几乎尝试了一切,但没有成功。有什么问题吗?
我目前正在尝试将现有项目静态链接到其主要依赖项,以减少生成的输出库的大小.我试图改变的项目是依赖于Leptonica图像处理库的Tesseract OCR.
目前,Leptonica有2481个功能,但Tesseract仅使用其中的163个.换句话说,在Tesseract中只使用了6.5%的Leptonica功能,但是整堆代码(3,5 MB +附加库)将被加载并保存在内存中.这可能不是桌面系统的问题.但是在内存有限的移动设备上,使用未使用的代码占用几个MB成本太高.
我希望使用静态链接减少这个Tesseract + Leptonica对的整体尺寸.这两个项目都使用autoconfig/automake/libtool构建系统.
Leptonica的构建产生静态和动态库.Tesseract在其configure.ac中使用以下行来声明Leptonica依赖:
AC_CHECK_LIB(lept,pixCreate,[],AC_MSG_ERROR([Leptonica library missing]))
Run Code Online (Sandbox Code Playgroud)
因为上面提到的行确实自动将Leptonica添加到$ LIBS,所以我将其改为如下:
AC_CHECK_LIB(lept,pixCreate,[LIBS="-Bstatic -llept -Bdynamic $LIBS"],AC_MSG_ERROR([Leptonica library missing])))
Run Code Online (Sandbox Code Playgroud)
当我运行./configure和make时,一切正常,但Tesseract仍将动态链接到Leptonica.
在检查相应的make日志时,我注意到g ++链接调用只是忽略了我的"-Bstatic"属性并链接到共享库(liblept.so):
libtool: link: g++ -m32 -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.8/crtbeginS.o -Wl,--whole-archive ./.libs/libtesseract_api.a ../ccmain/.libs/libtesseract_main.a ../cube/.libs/libtesseract_cube.a ../neural_networks/runtime/.libs/libtesseract_neural.a ../textord/.libs/libtesseract_textord.a ../wordrec/.libs/libtesseract_wordrec.a ../classify/.libs/libtesseract_classify.a ../dict/.libs/libtesseract_dict.a ../ccstruct/.libs/libtesseract_ccstruct.a ../cutil/.libs/libtesseract_cutil.a ../viewer/.libs/libtesseract_viewer.a ../ccutil/.libs/libtesseract_ccutil.a ../opencl/.libs/libtesseract_opencl.a -Wl,--no-whole-archive -Wl,-rpath -Wl,/home/maxpol/Dokumente/javacpp-presets-myfork/tesseract/cppbuild/linux-x86/lib -Wl,-rpath -Wl,/home/maxpol/Dokumente/javacpp-presets-myfork/tesseract/cppbuild/linux-x86/lib -L/home/maxpol/Dokumente/javacpp-presets-myfork/tesseract/cppbuild/linux-x86/lib/ -lz /home/maxpol/Dokumente/javacpp-presets-myfork/tesseract/cppbuild/linux-x86/lib/liblept.so -lpthread -L/usr/lib/gcc/i686-linux-gnu/4.8 -L/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.8/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.8/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/i686-linux-gnu/4.8/crtendS.o /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crtn.o -m32 -pthread -Wl,-soname -Wl,libtesseract.so.3 -o .libs/libtesseract.so.3.0.4
Run Code Online (Sandbox Code Playgroud)
我已经咨询过autotools文档和其他几个项目,但找不到任何有用的东西.因此我决定在这里提出这个问题.
我错过了重要的事吗?
非常感谢您的帮助!最好的问候Max
我正在尝试使用 openFrameworks (0.9.0) 和 Xcode 7 构建 OSX OCR C++ 应用程序。
OCR 库是 Tesseract,它需要 Leptonica,我已经通过 Homebrew 安装了这两个库。Tesseract 被编译和链接为一个静态库(.a 文件),并且 Leptonica 被添加到项目中,方法是根据此链接上的说明仅添加 allheaders.h 。
问题是:在我添加 之后allheaders.h,Xcode 自动将一个参数匹配allheaders.h到另一个宏定义中FixMath.h,这是 OSX CarbonCore 框架中的一个文件。这会在编译过程中导致错误。
allheaders.h冲突中的线是:
LEPT_DLL extern NUMA * numaFindPeaks ( NUMA *nas, l_int32 nmax, l_float32 fract1, l_float32 fract2 );
FixMath.h冲突中的宏是:
#define fract1 ((Fract) 0x40000000L)
似乎编译器将宏引用为函数中参数的定义,但我不知道如何切断这种联系。任何人都可以就如何解决这个问题提出一些建议吗?
我们最初在centos 7中安装了tesseract 3.04,并且知道切换到tesseract 3.05.我们已经卸载了旧版本,并且已经安装了从leptonica主页下载的leptonica-1.75.3.
但是,当我们去安装tesseract 3.05时,我们会对LEPTONICA进行以下错误检查...没有配置:错误:需要Leptonica 1.74或更高版本.尝试安装libleptonica-dev软件包.
在tesseract-3.05.01文件夹中的控制台中运行./configure时.
需要知道问题出在哪里.
我有一个Leptonica Pix对象返回
TessBaseApi.getThresholdedImage();
Run Code Online (Sandbox Code Playgroud)
现在,我怎么能将它转换为位图,以便我可以通过它显示它ImageView.
leptonica.android.Pix 至 android.graphics.Bitmap;
我没有找到查看API文件的转换方法.
我想从图像中执行文本识别,我想使用Python.我安装了Anaconda.现在我想安装Tesseract但我还需要安装Leptonica.我没有找到任何明确的说明如何在Windows中执行此操作.对于Leptonica我不想安装Visual Studio.那么有人可以提供明确的说明如何在Windows上安装leptonica和tesseract而不使用Visual Studio在anaconda中使用吗?谢谢.