#include "stdafx.h"
#include "allheaders.h"
#include "baseapi.h"
#include <time.h>
using namespace std;
using namespace tesseract;
#pragma comment(lib, "liblept168")
#pragma comment(lib, "libtesseract302")
#pragma comment(lib, "winmm.lib")
int main(int argc, char* argv[])
{
try
{
char *outText;
const char *path = "D:\\160614\\tesseract_testing\\test_texts\\tesseract_training\\";
TessBaseAPI *api = new TessBaseAPI();
if (api->Init(path, argv[2])) {
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
}
Pix *image = pixRead(argv[1]);
api->SetImage(image);
//Get OCR result outText = api->GetUTF8Text();
printf("OCR output:\n%s", outText);
api->SetImage(image);
api->SetVariable("save_blob_choices", "T");
api->SetRectangle(37, 228, 548, 31);
api->Recognize(NULL);
tesseract::ResultIterator* ri = api->GetIterator();
tesseract::PageIteratorLevel level = tesseract::RIL_SYMBOL;
if (ri != 0) {
do {
const char* symbol = ri->GetUTF8Text(level);
float conf = ri->Confidence(level);
if (symbol != 0) {
printf("symbol %s, conf: %f", symbol, conf);
bool indent = false;
tesseract::ChoiceIterator ci(*ri);
do {
if (indent) printf("\t\t ");
printf("\t- ");
const char* choice = ci.GetUTF8Text();
printf("%s conf: %f\n", choice, ci.Confidence());
indent = true;
} while (ci.Next());
}
printf("---------------------------------------------\n");
delete[] symbol;
} while ((ri->Next(level)));
}
}
catch (...)
{
printf("error!");
}
return 0;
}1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::ChoiceIterator(class tesseract::LTRResultIterator const &)" (??0ChoiceIterator@tesseract@@QAE@ABVLTRResultIterator@1@@Z)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::~ChoiceIterator(void)" (??1ChoiceIterator@tesseract@@QAE@XZ)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall tesseract::ChoiceIterator::GetUTF8Text(void)const " (?GetUTF8Text@ChoiceIterator@tesseract@@QBEPBDXZ)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: float __thiscall tesseract::ChoiceIterator::Confidence(void)const " (?Confidence@ChoiceIterator@tesseract@@QBEMXZ)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: bool __thiscall tesseract::ChoiceIterator::Next(void)" (?Next@ChoiceIterator@tesseract@@QAE_NXZ)
1>C:\(my path)\Tesseract-ocr_tutorial_160607\Release\Tesseract-ocr_tutorial_160607.exe : fatal error LNK1120: 5 unresolved externals#include "stdafx.h"
#include "allheaders.h"
#include "baseapi.h"
using namespace std;
using namespace tesseract;
#pragma comment(lib, "liblept168")
#pragma comment(lib, "libtesseract302")
int main(int argc, char* argv[])
{
tesseract::ResultIterator* ri;
tesseract::ChoiceIterator ci(*ri);
return 0;
}1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::ChoiceIterator(class tesseract::LTRResultIterator const &)" (??0ChoiceIterator@tesseract@@QAE@ABVLTRResultIterator@1@@Z)
1>Tesseract-ocr_tutorial_160607.obj : error LNK2001: unresolved external symbol "public: __thiscall tesseract::ChoiceIterator::~ChoiceIterator(void)" (??1ChoiceIterator@tesseract@@QAE@XZ)
1>C:\(my path)\Tesseract-ocr_tutorial_160607\Release\Tesseract-ocr_tutorial_160607.exe : fatal error LNK1120: 2 unresolved externals