- 注册时间
- 2013-4-19
- 最后登录
- 2026-1-21
- 阅读权限
- 200
- 积分
- 6551
- 精华
- 0
- 帖子
- 647
    
|
#代码
```
#include "iostream"
#include "tesseract/baseapi.h"
#include "leptonica/allheaders.h"
using namespace std;
int main () {
char *outText;
cout << "======>>> start" << '\n';
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
if (api->Init(NULL, "chi_sim")) {
cout << "======>>> init error" << '\n';
return -1;
} else {
cout << "======>>> init ok" << '\n';
}
Pix *image = pixRead("test.tif");
api->SetImage(image);
outText = api->GetUTF8Text();
cout << "======>>> get text : " << outText << '\n';
api-> End();
delete [] outText;
return 0;
}
```
#编译
```
g++ -o hello hell.cpp -llept -ltesseract -std=c++11
```
#验证
```
======>>> start
======>>> init ok
======>>> get text : 启 动 BALL
```
#其他
```
api->SetRectangle(left, top, width, height);
可以设置需要识别的区域
基于opencv识别出大致的信息区域之后再识别
```
|
|