Tesseract运行时错误:pixReadMemPng中的错误:函数不存在

时间:2016-07-01 15:52:27

标签: cygwin tesseract libpng leptonica

我在Cygwin上建立了Tesseract 3.04.01。它可以识别.bmp文件,但它在.png文件上失败:

$ tesseract.exe testing/phototest.png output
Tesseract Open Source OCR Engine v3.04.01 with Leptonica
Error in pixReadMemPng: function not present
Error in pixReadMem: png: no pix returned
Error during processing.

我认为leptopnica增加了对png的支持?

2 个答案:

答案 0 :(得分:2)

经过一番挖掘后,事实证明leptonica更像是libpng和libtiff等标准库的包装器,如果它的lib可以'它将默默地禁用对图像类型的支持。找到了。

在运行./configure

时,它正在给我这个
checking for png_read_png in -lpng... no

所以我不得不下载并构建libpng。之后它仍然无法正常工作,因为libpng安装在/usr/local/lib中,显然这不是cygwin的默认库路径。所以我不得不使用LDFLAGS添加它:

LDFLAGS=-L/usr/local/lib ./configure

之后它最终建立了PNG支持,给出了这样的信息:

checking for png_read_png in -lpng... yes

由于某种原因,链接顺序在Makefile中混淆 - -lpng -lz,导致链接liblept.la失败:

png.c:(.text+0x13ab): undefined reference to `crc32'

我能解决的唯一方法是运行make V=1(详细模式)来查看实际命令,即:

make[2]: Entering directory '/home/sasho/leptonica-1.73/src'
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -O2 -no-undefined -version-info 5:0:0 -Wl,--as-needed -L/usr/local/lib -o liblept.la -rpath /usr/local/lib adaptmap.lo affine.lo affinecompose.lo arrayaccess.lo bardecode.lo baseline.lo bbuffer.lo bilateral.lo bilinear.lo binarize.lo binexpand.lo binreduce.lo blend.lo bmf.lo bmpio.lo bmpiostub.lo bootnumgen1.lo bootnumgen2.lo boxbasic.lo boxfunc1.lo boxfunc2.lo boxfunc3.lo boxfunc4.lo bytearray.lo ccbord.lo ccthin.lo classapp.lo colorcontent.lo coloring.lo colormap.lo colormorph.lo colorquant1.lo colorquant2.lo colorseg.lo colorspace.lo compare.lo conncomp.lo convertfiles.lo convolve.lo correlscore.lo dewarp1.lo dewarp2.lo dewarp3.lo dewarp4.lo dnabasic.lo dwacomb.2.lo dwacomblow.2.lo edge.lo encoding.lo enhance.lo fhmtauto.lo fhmtgen.1.lo fhmtgenlow.1.lo finditalic.lo flipdetect.lo fliphmtgen.lo fmorphauto.lo fmorphgen.1.lo fmorphgenlow.1.lo fpix1.lo fpix2.lo gifio.lo gifiostub.lo gplot.lo graphics.lo graymorph.lo grayquant.lo grayquantlow.lo heap.lo jbclass.lo jp2kheader.lo jp2kheaderstub.lo jp2kio.lo jp2kiostub.lo jpegio.lo jpegiostub.lo kernel.lo leptwin.lo libversions.lo list.lo map.lo maze.lo morph.lo morphapp.lo morphdwa.lo morphseq.lo numabasic.lo numafunc1.lo numafunc2.lo pageseg.lo paintcmap.lo parseprotos.lo partition.lo pdfio1.lo pdfio1stub.lo pdfio2.lo pdfio2stub.lo pix1.lo pix2.lo pix3.lo pix4.lo pix5.lo pixabasic.lo pixacc.lo pixafunc1.lo pixafunc2.lo pixalloc.lo pixarith.lo pixcomp.lo pixconv.lo pixlabel.lo pixtiling.lo pngio.lo pngiostub.lo pnmio.lo pnmiostub.lo projective.lo psio1.lo psio1stub.lo psio2.lo psio2stub.lo ptabasic.lo ptafunc1.lo ptra.lo quadtree.lo queue.lo rank.lo rbtree.lo readbarcode.lo readfile.lo recogbasic.lo recogdid.lo recogident.lo recogtrain.lo regutils.lo rop.lo ropiplow.lo roplow.lo rotate.lo rotateam.lo rotateamlow.lo rotateorth.lo rotateshear.lo runlength.lo sarray.lo scale.lo scalelow.lo seedfill.lo seedfilllow.lo sel1.lo sel2.lo selgen.lo shear.lo skew.lo spixio.lo stack.lo stringcode.lo sudoku.lo textops.lo tiffio.lo tiffiostub.lo utils.lo viewfiles.lo warper.lo watershed.lo webpio.lo webpiostub.lo writefile.lo zlibmem.lo zlibmemstub.lo  -lz -lpng       

然后我执行了相同的命令(从./src开始执行当前目录,或者它不能工作),但我在最后添加了另一个-lz,这导致它成功。之后,我只是重新制作,并继续构建库的其余部分。

cd src
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -O2 -no-undefined -version-info 5:0:0 -Wl,--as-needed -L/usr/local/lib -o liblept.la -rpath /usr/local/lib adaptmap.lo affine.lo affinecompose.lo arrayaccess.lo bardecode.lo baseline.lo bbuffer.lo bilateral.lo bilinear.lo binarize.lo binexpand.lo binreduce.lo blend.lo bmf.lo bmpio.lo bmpiostub.lo bootnumgen1.lo bootnumgen2.lo boxbasic.lo boxfunc1.lo boxfunc2.lo boxfunc3.lo boxfunc4.lo bytearray.lo ccbord.lo ccthin.lo classapp.lo colorcontent.lo coloring.lo colormap.lo colormorph.lo colorquant1.lo colorquant2.lo colorseg.lo colorspace.lo compare.lo conncomp.lo convertfiles.lo convolve.lo correlscore.lo dewarp1.lo dewarp2.lo dewarp3.lo dewarp4.lo dnabasic.lo dwacomb.2.lo dwacomblow.2.lo edge.lo encoding.lo enhance.lo fhmtauto.lo fhmtgen.1.lo fhmtgenlow.1.lo finditalic.lo flipdetect.lo fliphmtgen.lo fmorphauto.lo fmorphgen.1.lo fmorphgenlow.1.lo fpix1.lo fpix2.lo gifio.lo gifiostub.lo gplot.lo graphics.lo graymorph.lo grayquant.lo grayquantlow.lo heap.lo jbclass.lo jp2kheader.lo jp2kheaderstub.lo jp2kio.lo jp2kiostub.lo jpegio.lo jpegiostub.lo kernel.lo leptwin.lo libversions.lo list.lo map.lo maze.lo morph.lo morphapp.lo morphdwa.lo morphseq.lo numabasic.lo numafunc1.lo numafunc2.lo pageseg.lo paintcmap.lo parseprotos.lo partition.lo pdfio1.lo pdfio1stub.lo pdfio2.lo pdfio2stub.lo pix1.lo pix2.lo pix3.lo pix4.lo pix5.lo pixabasic.lo pixacc.lo pixafunc1.lo pixafunc2.lo pixalloc.lo pixarith.lo pixcomp.lo pixconv.lo pixlabel.lo pixtiling.lo pngio.lo pngiostub.lo pnmio.lo pnmiostub.lo projective.lo psio1.lo psio1stub.lo psio2.lo psio2stub.lo ptabasic.lo ptafunc1.lo ptra.lo quadtree.lo queue.lo rank.lo rbtree.lo readbarcode.lo readfile.lo recogbasic.lo recogdid.lo recogident.lo recogtrain.lo regutils.lo rop.lo ropiplow.lo roplow.lo rotate.lo rotateam.lo rotateamlow.lo rotateorth.lo rotateshear.lo runlength.lo sarray.lo scale.lo scalelow.lo seedfill.lo seedfilllow.lo sel1.lo sel2.lo selgen.lo shear.lo skew.lo spixio.lo stack.lo stringcode.lo sudoku.lo textops.lo tiffio.lo tiffiostub.lo utils.lo viewfiles.lo warper.lo watershed.lo webpio.lo webpiostub.lo writefile.lo zlibmem.lo zlibmemstub.lo  -lz -lpng -lz      
cd -
make

答案 1 :(得分:2)

发生上述错误时,可能是在编译和安装leptonica之前未安装libpng-devel。您可以尝试

yum install libpng-devel

然后编译并安装leptonica

cd leptonica/ make clean ./configure make make install 它在我的centos7上工作。