使用有关使用 API的链接以及如何将图像数据转换为 Tesseract 可识别的格式的链接,我编写了以下代码并将目录添加到...tesseract/ccmain/
我的 Visual C++ 项目的包含目录中(已用于 OpenCV)。
#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)