2011-07-23 89 views
1

使用上using the API和鏈接另一how to get the image data into a format recognizable by Tesseract C API構建的錯誤,我寫了下面的代碼,並在包括我的Visual C目錄++項目添加...tesseract/ccmain/目錄(已用於OpenCV的。與正方體OCR

#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); 

它編譯沒有任何錯誤,但是當我嘗試建立它有這個錯誤每個正方體相關的函數調用:「未解析的外部符號XXXXX。「 我是否在鏈接和包括Tesseract中出現任何錯誤,這些錯誤不會在編譯時顯示,而只會在編譯時顯示?

任何幫助將是偉大的。

編輯:這些都是錯誤信息:

Linking... 
image.obj : error LNK2001: unresolved external symbol "public: static void __cdecl TessBaseAPI::End(void)" ([email protected]@@SAXXZ) 
image.obj : error LNK2001: unresolved external symbol "public: static char * __cdecl TessBaseAPI::TesseractRect(unsigned char const *,int,int,int,int,int,int)" ([email protected]@@[email protected]) 
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)" ([email protected]@@[email protected]) 
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) 
+1

好的,我通過使用該系統通過「正方體image.tif文本-l工程」到shell中運行的Tesseract的命令行()函數在stdlib.h中。這是一件非常艱難的事情,但API真的比它的價值更麻煩! – AruniRC

回答

1

你需要找出相關的.lib文件,並將其鏈接到您的項目。

+0

僅找到tessdll.lib並將其包含在內。仍然有相同的構建錯誤。有任何想法嗎? – AruniRC

0

嗨能否請你嘗試下面的代碼...

#define TESSDLL_IMPORTS 
#include "stdafx.h" 
#include "baseapi.h" 
#include <string> 

using namespace std; 

int main(int argc, char **argv) 
{ 
    string outfile; 
    tesseract::TessBaseAPI api; 

    return 0; 
} 
+0

仍然存在構建錯誤,我必須在包含庫時犯一些錯誤。無論如何,儘管我在程序中使用了Tesseract的命令行參數。這樣很好地工作。 API似乎比它的價值更麻煩! – AruniRC