如何使用 OCR (TesseractOCR) php 库 [英] How to use the OCR (TesseractOCR) php library

查看:57
本文介绍了如何使用 OCR (TesseractOCR) php 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此链接克隆了 OCR 的 git 库.

git clone git://github.com/thiagoalessio/tesseract-ocr-for-php.git

然后我按照这个示例 >

这是我尝试运行的示例代码

require_once './src/TesseractOCR.php';$tesseract = new TesseractOCR('text.png');$text = $tesseract->recognize();echo "识别出的文本是:", $text;

但它总是触发一个致命的错误

<块引用>

致命错误:未捕获的错误:调用未定义的方法 TesseractOCR::recognize()

编辑 我尝试使用 run() 而不是 recognize()

require_once './src/TesseractOCR.php';$tesseract = new TesseractOCR('text.png');$text = $tesseract->run();var_dump($text);echo PHP_EOL, "识别的文本是:", $text, PHP_EOL;

则结果为:string(0) "" 识别的文本为:

我已尽力寻找合适的解决方案,但未能找到真正的解决方案

解决方案

这个示例代码可能来自 这篇文章 或一些类似的文章.但我可以看到它已经超过 1.5 年了,而且显然已经过时了.

查看他们的 github 页面.现在看起来是 run() 而不是 recognize():

运行();

I had clone git library of OCR using this link .

git clone git://github.com/thiagoalessio/tesseract-ocr-for-php.git

then simply i include the required file by following this example

here is the example code which i m trying to run

require_once './src/TesseractOCR.php';
$tesseract = new TesseractOCR('text.png');
$text = $tesseract->recognize();
echo "The recognized text is:", $text;

But always it fires a fatal Error

Fatal error: Uncaught Error: Call to undefined method TesseractOCR::recognize()

Edit I tried to use run() instead of recognize()

require_once './src/TesseractOCR.php';
$tesseract = new TesseractOCR('text.png');
$text = $tesseract->run();
var_dump($text);
echo PHP_EOL, "The recognized text is:", $text, PHP_EOL;

Then result is : string(0) "" The recognized text is:

I had tried my best to find some appropriate solution but failed to find some authentic solution

解决方案

This sample code probably comes from this article or some similar. But I can see that it's over 1,5 year old and apparently it's outdated.

Take a look at their github's page. It looks like it's run() instead of recognize() right now:

<?php
echo (new TesseractOCR('german.png'))
    ->run();

这篇关于如何使用 OCR (TesseractOCR) php 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆