在ubuntu中使用tesseract 我下载了TESSACT,我想用C++代码使用它。 但我得到了这些错误: TessOp.cpp:6:39: fatal error: tesseract-ocr/api/baseapi.h: No such file or directory
在我的代码中,我也使用OpenCV,这是我的代码:在ubuntu中使用tesseract 我下载了TESSACT,我想用C++代码使用它。 但我得到了这些错误: TessOp.cpp:6:39: fatal error: tesseract-ocr/api/baseapi.h: No such file or directory,c++,opencv,ubuntu,tesseract,C++,Opencv,Ubuntu,Tesseract,在我的代码中,我也使用OpenCV,这是我的代码: #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <tesseract-ocr/api/baseapi.h> #include <iostream> int main(int argc, char** argv) { // Load image cv::Ma
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <tesseract-ocr/api/baseapi.h>
#include <iostream>
int main(int argc, char** argv)
{
// Load image
cv::Mat im = cv::imread("1.png");
if (im.empty())
{
std::cout << "Cannot open source image!" << std::endl;
return -1;
}
cv::Mat gray;
cv::cvtColor(im, gray, CV_BGR2GRAY);
// ...other image pre-processing here...
//Mat binary_image;
//threshold(gray,binary_image, 25, 255, CV_THRESH_BINARY);
//imshow("binary_image",binary_image);
// Pass it to Tesseract API
tesseract::TessBaseAPI tess;
//tess.Init("C:/Tesseract-OCR/tessdata/", "eng");
tess.Init(NULL, "eng", tesseract::OEM_DEFAULT);
tess.SetPageSegMode(tesseract::PSM_SINGLE_BLOCK);
tess.SetImage((uchar*)gray.data, gray.cols, gray.rows, 1, gray.cols);
// Get the text
char* out = tess.GetUTF8Text();
std::cout << out << std::endl;
return 0;
}
您没有添加tesseract的include目录,也没有链接它。 将以下内容添加到命令行
-I/usr/local/include/tesseract -ltesseract
我也面临同样的问题。让我知道如何解决这个问题?
-I/usr/local/include/tesseract -ltesseract