Tesseract + opencv 3.0 + Windows,文本模块尺寸小,链接错误 [英] Tesseract + opencv 3.0 + windows, text module small size, linking errors

查看:66
本文介绍了Tesseract + opencv 3.0 + Windows,文本模块尺寸小,链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两天前,我在answer.opencv.org中发布了此文本,现在我也将其发布在这里. http://answers.opencv.org/question/68634/text-contrib-module-and-tesseract/

I posted this text two days ago in answers.opencv.org, now I'm posting it here as well. http://answers.opencv.org/question/68634/text-contrib-module-and-tesseract/

大家下午好.首先,对不起我的英语呵呵. 我一直在尝试构建opencv contrib模块'text',但是我 没有成功.注意:诸如xfeatures2d之类的其他模块从来没有 给我一个问题.

Good afternoon to everyone. First of all, sorry for my english hehe. I've been trying to build the opencv contrib module 'text', however I haven't got sucess. Note: Other modules like xfeatures2d have never given me a problem.

我的平台是Windows 7 x64,我使用VS2013作为编译器, 跟着这个 教程( http://vorba.ch/2014/tesseract-3.03-vs2013.html)为了 将Tesseract 3.04构建为LIB,但是在成功编译之后,我 想用cmake生成vproj,问题是 以下:

My platform is windows 7 x64 and I use VS2013 as compiler, I've followed this tutorial(http://vorba.ch/2014/tesseract-3.03-vs2013.html) in order to build Tesseract 3.04 as LIB, but after compiling it succesfully, I want to generate the vproj with cmake and the problem is the following:

在CMake GUI中,以前选择过opencv源EXTRAS 目录等,我没有在"Tesseract"组下找到vars 正确地(包括并轻弹).我知道是因为当我点击 配置,日志显示"Tesseract:否".

In CMake GUI, having previously selected opencv source, EXTRAS directory, etc etc, I don't get the vars under 'Tesseract' group set correcly (INCLUDE AND LIBS). I know it because when I click on configure, The log says "Tesseract: NO".

我检查了FindTesseract cmake脚本,我认为它 不起作用......

I've inspected the FindTesseract cmake script and I think that it doesn't work....

请,任何人都可以给我一些有关发生情况的线索?如何 可以构建opencv文本模块以使用Tesseract函数吗?

Please, anyone could give me a little clue about what's happening? How can I build the opencv text module to use Tesseract functions?

我也尝试编译文本模块,将链接路径添加到Tesseract 但是当我想在程序中使用时,出现关于未定义的链接错误 符号...

Also I've tried to compile text module adding link paths to Tesseract but when I want to use in my program I get link errors about undefined symbols...

这种情况使我花了很多时间来困扰我.在那里 有人在Windows下使用文本模块?

This situation is taking me serveral days bothering me. Are there someone who is using text module under windows?


没有人可以帮助我吗?我已经取得了一些进展,现在是cmake GUI,我说:Tesseract:是的.问题是我没有找到用于链接leptonica lib的条目,该条目不在同一Tesseract组中,而在未分组的条目"中.


Nobody can help me? I've made some progress, now cmake GUI, says me Tesseract:Yes. The problem was that I hadn't found the entry for linking the leptonica lib, which's not in the same Tesseract group but in 'Ungrouped Entries'.

好吧,现在问题仍然存在,由cmake创建的VS解决方案无法正确构建文本模块,因为我可以看到Lept lib约为9Mb,TesseractLib为128Mb(在/MT和debug中),但是opencv_text300d.lib只有12Mb.出了点问题....

Ok, now the problem remains same, the VS solution created by cmake is not building the text module correctly as I can see Lept lib is about 9Mb and TesseractLib is 128Mb (in /MT and debug), however the opencv_text300d.lib is only 12Mb. Something is wrong....

我不确定我必须使用哪个tesseract版本.我有两种组合: liblept168-static-mtdll-debug.lib + libtesseract302-static-debug.lib 和 liblept171-static-mtdll-debug.lib + libtesseract304-static-debug.lib

I'm not sure about what tesseract version I must use. I've traid with two combinations: liblept168-static-mtdll-debug.lib + libtesseract302-static-debug.lib and liblept171-static-mtdll-debug.lib + libtesseract304-static-debug.lib

当然,当我将文本模块链接到程序时,它会给我链接错误.

Of course when I link text module to my program it gives me link errors.

链接错误看起来像:opencv_text300d.lib(ocr_tesseract.obj):错误LNK2019: unresolved external symbol "public: bool __cdecl tesseract::PageIterator::BoundingBox(enum tesseract::PageIteratorLevel,int *,int *,int *,int *)const " (?........................

The linking errors look like: opencv_text300d.lib(ocr_tesseract.obj) : error LNK2019: unresolved external symbol "public: bool __cdecl tesseract::PageIterator::BoundingBox(enum tesseract::PageIteratorLevel,int *,int *,int *,int *)const " (?........................

...
#include "opencv2/text.hpp"
...
string output;
cv::Mat aux;
Ptr<OCRTesseract> ocr = OCRTesseract::create();
ocr->run(aux, output);
...

很明显,我为项目设置了其他包含目录,链接器其他库目录,并向文本模块输入了其他依赖项.

Obviously I've set up my project with additional include directories, linker additional library directory and input additional dependecies to the text module.

真的,非常感谢您.

推荐答案

我遇到了同样的问题.我想出的解决方案是在文本模块中编辑CMakeLists.txt文件.

I was facing the same problem. The solution I came up with was to edit the CMakeLists.txt file in text module.

替换

if(${Tesseract_FOUND})
include_directories(${Tesseract_INCLUDE_DIR})
endif()

使用

add_definitions( -DWINDOWS)
add_definitions( -DNOMINMAX)
SET(Tesseract_DIR "C:\\tesseract-build\\tesseract-ocr")
SET(Lept_DIR "C:\\tesseract-build\\lib")
include_directories(
        ${Tesseract_DIR}/api
        ${Tesseract_DIR}/ccutil/
        ${Tesseract_DIR}/ccstruct/
        ${Tesseract_DIR}/ccmain/
    )
link_directories( ${Tesseract_DIR}/vs2013/bin/Win32/DLL_Release/
                  ${Lept_DIR}/
                  ${Lept_DIR}/Win32/
                )   

运行Cmake时,Tesseract仍为否,并且Tessaract/Lept库应该为空.

When you run Cmake, Tesseract will still be no and the Tessaract/Lept libraries should be empty.

这篇关于Tesseract + opencv 3.0 + Windows,文本模块尺寸小,链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆