我使用此链接克隆了 OCR 的 git 库。
git clone git://github.com/thiagoalessio/tesseract-ocr-for-php.git
然后我只需按照以下步骤包含所需的文件example http://thiagoalessio.me/tesseractocr-for-php-on-windows/
这是我尝试运行的示例代码
require_once './src/TesseractOCR.php';
$tesseract = new TesseractOCR('text.png');
$text = $tesseract->recognize();
echo "The recognized text is:", $text;
但总是会引发致命错误
致命错误:未捕获错误:调用未定义的方法 TesseractOCR::recognize()
Edit我尝试使用run()
代替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;
那么结果是:string(0) "" The recognized text is:
我已尽力找到一些合适的解决方案,但未能找到一些真实的解决方案
该示例代码可能来自本文 http://thiagoalessio.me/tesseractocr-for-php-on-windows/或者一些类似的。但我可以看到它已经超过 1.5 年了,显然已经过时了。
看看他们的github 的页面 https://github.com/thiagoalessio/tesseract-ocr-for-php。看起来好像是run()
代替recognize()
现在:
<?php
echo (new TesseractOCR('german.png'))
->run();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)