将 tesseract 库与 QtCreator 链接 [英] Link tesseract libs with QtCreator
本文介绍了将 tesseract 库与 QtCreator 链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行一个基于 tesseract API 的 C++ 程序,我在 Ubuntu 上使用 QtCreator 作为 IDE,以便执行页面布局分析:
I'm trying to run a C++ program which is based on tesseract API and I'm using QtCreator as IDE on Ubuntu, in order to perfom page layout analysis :
int main(void)
{
int left, top, right, bottom;
tesseract::TessBaseAPI tessApi;
tessApi.InitForAnalysePage();
cv::Mat img = cv::imread("document.png");
tessApi.SetImage(reinterpret_cast<const uchar*>(img.data), img.size().width, img.size().height, img.channels(), img.step1());
tesseract::PageIterator *iter = tessApi.AnalyseLayout();
while (iter->Next(tesseract::RIL_BLOCK))
iter->BoundingBox( tesseract::RIL_BLOCK, &left, &top, &right, &bottom);
return EXIT_SUCCESS;
}
但反过来我得到了这些类型的错误,确认tesseract和Qt没有链接:
But in turn I got these kind of errors confirming that tesseract and Qt aren't linked :
main.cpp:11: error: undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
main.cpp:12: error: undefined reference to `tesseract::TessBaseAPI::InitForAnalysePage()'
main.cpp:16: error: undefined reference to `tesseract::TessBaseAPI::SetImage(unsigned char const*, int, int, int, int)'
main.cpp:18: error: undefined reference to `tesseract::TessBaseAPI::AnalyseLayout()'
这是我的 .pro 文件:
Here is my .pro file :
INCLUDEPATH += /usr/local/include/opencv \
/usr/include/tesseract
LIBS += -L"/usr/local/opencv/lib" -lopencv_calib3d \
-lopencv_contrib \
-lopencv_core \
-lopencv_features2d \
-lopencv_flann \
-lopencv_gpu \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_legacy \
-lopencv_ml \
-lopencv_nonfree \
-lopencv_objdetect \
-lopencv_ocl \
-lopencv_photo \
-lopencv_stitching \
-lopencv_superres \
-lopencv_video \
-lopencv_videostab
LIBS += -L"/usr/bin/tesseract"
推荐答案
您只有 lib -L"/usr/bin/tesseract"
的路径,您忘记将 lib 包含为出色地.只需像添加 openCV 库一样添加它即可.
You only have the path for the lib -L"/usr/bin/tesseract"
, you forgot to include the lib as well. Just add it like you did for the openCV libs.
这篇关于将 tesseract 库与 QtCreator 链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文