【发布时间】:2018-08-09 08:51:14
【问题描述】:
它返回一个空白页。使用 PHP 的 thiagoalessio Tesseract OCR。
Tesseract 安装在我的 Homestead 虚拟机上:
vagrant@xxx-yyy-zzz:/usr/bin$ ./tesseract -v
tesseract 3.04.01
空白页:
use thiagoalessio\TesseractOCR\TesseractOCR;
class OCRController extends Controller
{
public function analyze() {
echo (new TesseractOCR(asset('storage/text.png')))
->executable('/usr/bin/tesseract')->run();
}
}
调试 PHP 代码:
use thiagoalessio\TesseractOCR\TesseractOCR;
class OCRController extends Controller
{
public function analyze() {
$tesseract = new TesseractOCR(asset('storage/text.png'));
$tesseract->executable('/usr/bin/tesseract');
var_dump($tesseract);
}
}
输出:
/home/vagrant/code/project-io/app/Http/Controllers/OCRController.php:13:
object(thiagoalessio\TesseractOCR\TesseractOCR)[444]
private 'image' => string 'http://project.test/storage/text.png' (length=38)
private 'command' => null
private 'executable' => string '/usr/bin/tesseract' (length=18)
private 'options' =>
array (size=0)
empty
知道http://project.test/storage/text.png实际上是在返回图片。
Tesseract 正在使用命令行:
vagrant@xxx-yyy-zzz:~/code/project-io/public/storage$ tesseract text.png stdout
The quick brown fox
jumps over
the lazy dog.
【问题讨论】:
-
没有足够的代码 imo。虽然应该分析重新调整一些东西?
-
当我
var_dump (new TesseractOCR(asset('storage/text.png')))->executable('/usr/bin/tesseract')->run();它返回"Call to a member function executable() on null"我不明白,因为当我var_dump()在可执行方法之前它返回TesseractOCR对象