Buscar pacotes, repositórios e categorias de apps

Repositório GitHubkhjde1207/tesseract_ocr

tesseract_ocr

Tesseract OCR para Flutter

Capa do projeto tesseract_ocr
Estrelas
68
Forks
46
Último push (UTC)
14 de set. de 2026
Status do projeto
Ativo

README original

Texto original em inglês. Visite o GitHub para a versão atual.

Tesseract OCR for Flutter

Fork note (onestudi0/tesseract_ocr): This fork exists solely to fix android/build.gradle, which still declares the defunct jcenter() repository — current Gradle rejects the jcenter() DSL method outright, so upstream fails to build at all as of this writing. This fork replaces it with mavenCentral(). No other changes. If upstream (khjde1207/tesseract_ocr) ever merges an equivalent fix, switch back to the pub.dev release and drop the dependency_overrides pointing here.

Tesseract OCR 4.0 for flutter This plugin is based on Tesseract OCR 4 This plugin uses Tesseract4Android and SwiftyTesseract.

pub.dev link


https://pub.dev/packages/google_ml_kit

Tesseract is slower than ml_kit.

Consider whether you should use Tesseract


example

install


dev_dependencies:
  ...
  flutter_tesseract_ocr:

web

./web/index.html

use https://www.npmjs.com/package/tesseract.js/v/v4.0.2

<body>
  <script src='https://unpkg.com/tesseract.js@v4.0.2/dist/tesseract.min.js'></script>
  <script>
    async function _extractText(imagePath , mapData){
      var worker = await Tesseract.createWorker();
      await worker.load();
      await worker.loadLanguage(mapData.language)
      await worker.initialize(mapData.language)
      await worker.setParameters(mapData.args)
      var rtn = await worker.recognize(imagePath, {}, worker.id);
      await worker.terminate();
      if(mapData.args["tessjs_create_hocr"]){
        return rtn.data.hocr;
      }
      return rtn.data.text;
    }
  </script>
  ...
  ..
  .
</body>

Getting Started (Android / Ios)

You must add trained data and trained data config file to your assets directory. You can find additional language trained data files here Trained language files

add tessdata folder under assets folder, add tessdata_config.json file under assets folder:

{
  "files": [
    "eng.traineddata",
    "<other_language>.traineddata"
  ]
}

Plugin assumes you have tessdata folder in your assets directory and defined in your pubspec.yaml

Check the contents of example/assets folder and example/pubspec.yaml


IOS issues

Initialization of SwiftyTesseract has failed

Just drag tessdata folder from asset to place under Runner folder in xcode add as a reference then it will work.

Reference


Usage

Using is very simple:

//args support android / Web , i don't have a mac
String text = await FlutterTesseractOcr.extractText('/path/to/image', language: 'kor+eng',
        args: {
          "psm": "4",
          "preserve_interword_spaces": "1",
        });

You can leave language empty, it will default to `'eng'.

//---- dynamic add Tessdata (Android)---- ▼
// https://github.com/tesseract-ocr/tessdata/raw/main/dan_frak.traineddata

HttpClient httpClient = new HttpClient();

HttpClientRequest request = await httpClient.getUrl(Uri.parse(
        'https://github.com/tesseract-ocr/tessdata/raw/main/${langName}.traineddata'));

HttpClientResponse response = await request.close();
Uint8List bytes =await consolidateHttpClientResponseBytes(response);
String dir = await FlutterTesseractOcr.getTessdataPath();

print('$dir/${langName}.traineddata');
File file = new File('$dir/${langName}.traineddata');
await file.writeAsBytes(bytes);
//---- dynamic add Tessdata ---- ▲

자유해결사 GitHub avatar
Autor no GitHub

자유해결사 ↗

서울
LinguagensDartJavaShellSwiftRubyHTMLObjective-CKotlin

Pacotes publicados por este repositório

Dependências usadas

Lista de dependências 4 itens

  • flutter{"sdk":"flutter"}
  • path_provider^2.1.4
  • path^1.9.0
  • flutter_testDesenvolvimento{"sdk":"flutter"}

Como escolher um repositório para seu projeto?

Filtre pelo caso de uso, compare a atividade e confira o projeto original antes de adotá-lo.

  1. Busque por nome, autor ou descrição e filtre por tema.
  2. Compare estrelas, forks e envios recentes. Estrelas indicam interesse, mas não garantem qualidade.
  3. Confira o README, a licença e as issues no GitHub antes de usar o projeto.

Fontes e manutenção

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗