Mac os x上的Tesseract-ocr gem问题[英] Tesseract-ocr gem issue on mac os x

本文是小编为大家收集整理的关于Mac os x上的Tesseract-ocr gem问题的处理方法,想解了Mac os x上的Tesseract-ocr gem问题的问题怎么解决?Mac os x上的Tesseract-ocr gem问题问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我已经安装了tesseract-ocr(0.1.5)宝石.

依赖项也已安装(Tesseract/3.04.00和Leptonica/1.72)

mac os x yosemity.

当我做rake db:migrate出现错误时:

rake aborted!
CompilationError: compile error: see logs at /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.log
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:in `compile'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders/c.rb:114:in `shared_object'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:90:in `block in build'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `instance_eval'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `build'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:54:in `singleton_inline'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:39:in `inline'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:30:in `<module:BaseAPI>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:27:in `<module:C>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:25:in `<module:Tesseract>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:25:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:83:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:26:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/Users/user/work/project/config/application.rb:17:in `<top (required)>'
/Users/user/work/project/Rakefile:4:in `<top (required)>'

日志中:

g++ -dynamic -bundle -fPIC    -o /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.dylib /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.cpp -ltesseract 2>>/var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.log
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:171:10: error: no matching member function for call to 'SetImage'
                                api->SetImage(pix);
                                ~~~~~^~~~~~~~
/usr/local/include/tesseract/baseapi.h:354:8: note: candidate function not viable: 1st argument ('const Pix *') would lose const qualifier
  void SetImage(Pix* pix);
       ^
/usr/local/include/tesseract/baseapi.h:341:8: note: candidate function not viable: requires 5 arguments, but 1 was provided
  void SetImage(const unsigned char* imagedata, int width, int height,
       ^
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:183:49: error: cannot initialize a parameter of type 'tesseract::TessResultRenderer *' with an lvalue of type 'STRING *'
                                return api->ProcessPages(filename, NULL, 0, output);
                                                                            ^~~~~~
/usr/local/include/tesseract/baseapi.h:542:63: note: passing argument to parameter 'renderer' here
                    int timeout_millisec, TessResultRenderer* renderer);
                                                              ^
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:189:65: error: cannot initialize a parameter of type 'tesseract::TessResultRenderer *' with an lvalue of type 'STRING *'
                                return api->ProcessPage(pix, page_index, filename, NULL, 0, output);
                                                                                            ^~~~~~
/usr/local/include/tesseract/baseapi.h:558:40: note: passing argument to parameter 'renderer' here
                   TessResultRenderer* renderer);
                                       ^

我该如何解决?

更新:这不是重复的问题.它无济于事错误设置tesseract ocr铁轨中的宝石

推荐答案

Tesseract开发人员在版本3.0.4中更改了很多东西,而Tesseract-Ock Gem失去了与之兼容的兼容性.我看到的最好的解决方案是暂时降级.您可能在Mac上安装了以前的Tesseract版本,请使用brew info tesseract找到该版本.如果是这样,只需使用brew switch.我最近做了brew cleanup,所以我不得不卸载tesseract并从旧配方中安装它,就像:

:

$ brew uninstall tesseract
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/8ba134eda537d2cee7daa7ebdd9f728389d9c53e/Library/Formula/tesseract.rb

这将安装似乎正在工作的Tesseract 3.02.02_3D. 您可以在 tesseract-ocr repo .

其他推荐答案

如果您不想降级Tesseract,则另一种快速而肮脏的方法是将Tesseract执行为shell命令,并打开保存的文件以获取对内容的访问(注意:字符串Interpolation in in On外壳命令)

input_image = 'input.tif'
`tesseract #{input_image} output -l eng`
file = File.open('output.txt')

其他推荐答案

从生成的日志中,它表明我缺少标头文件,我的问题是我引用了错误的版本,所以 将这些代码添加到GEM文件中解决了我的问题

ENV['CFLAGS'] = '-I/usr/local/Cellar/tesseract/3.02.02_3/include -I/usr/local/Cellar/leptonica/1.71_1/include'
ENV['LDFLAGS'] = '-L/usr/local/Cellar/tesseract/3.02.02_3/lib -L/usr/local/Cellar/leptonica/1.71_1/lib'

还要检查您自己的Tesseract和Leptonica

的版本

本文地址:https://www.itbaoku.cn/post/786738.html