使用 using the API 上的链接和另一个 how to get the image data into a format recognizable by Tesseract我编写了以下代码并在我的 Visual C++ 项目(已用于 OpenCV)的包含目录中添加了 ...tesseract/ccmain/
目录。
#include "baseapi.h"
..... [OpenCV 代码等].....
//********************* Tesseract OCR function calls *********************************************
// create a temp buffer
unsigned char *buffer,*temp2;
buffer = new unsigned char[plate->width*plate->height*plate->nChannels];
//'plate' is an IplImage*
temp2 = buffer;
// pointer to imageData
unsigned char *temp1 = (unsigned char*) plate->imageData;
// copy imagedata to buffer row by row
for(i=0;i<plate->height;i++)
{
memcpy(temp2, temp1, plate->width*plate->nChannels);
// imageData jump to next line
temp1 = temp1 + plate->widthStep;
// buffer jump to next line
temp2 = temp2+ plate->width*plate->nChannels;
}
TessBaseAPI::InitWithLanguage(NULL, NULL, "eng", NULL, false, 0, NULL);
char* Text = TessBaseAPI::TesseractRect( buffer, 8, 8,
0, 0, plate->width,plate->height);
TessBaseAPI::End();
printf("\n%s", Text );
它编译没有任何错误,但是当我尝试构建它时,每个与 Tesseract 相关的函数调用都会出现此错误:“未解析的外部符号 XXXXX。” 我在链接和包含 Tesseract 时是否犯了任何错误,它不会在编译时出现,而只会在构建时出现?
任何帮助都会很棒。
编辑:这些是错误信息:
Linking...
image.obj : error LNK2001: unresolved external symbol "public: static void __cdecl TessBaseAPI::End(void)" (?End@TessBaseAPI@@SAXXZ)
image.obj : error LNK2001: unresolved external symbol "public: static char * __cdecl TessBaseAPI::TesseractRect(unsigned char const *,int,int,int,int,int,int)" (?TesseractRect@TessBaseAPI@@SAPADPBEHHHHHH@Z)
image.obj : error LNK2001: unresolved external symbol "public: static int __cdecl TessBaseAPI::InitWithLanguage(char const *,char const *,char const *,char const *,bool,int,char * * const)" (?InitWithLanguage@TessBaseAPI@@SAHPBD000_NHQAPAD@Z)
Debug/proj.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
Creating browse info file...
proj.exe - 4 error(s), 0 warning(s)
最佳答案
您需要找到相关的 .LIB 文件并将它们链接到您的项目。
关于visual-studio - 使用 Tesseract OCR 的 C API 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6798278/