PHP 空白页的 Tesseract OCR
Tesseract OCR for PHP blank page
返回空白页。使用 thiagoalessio Tesseract OCR PHP.
Tesseract 安装在我的 Homestead VM 上:
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.
使用 laravel 和 PHP 的 Tesseract OCR,接收图像路径的 TesseractOCR
的构造函数似乎不接受 URL 作为一个参数。由于图像的asset()
returns URL,这将不起作用。这应该是一个严格的路径。
$tesseract = new TesseractOCR(asset('storage/app/public/text.png')); // Incorrect
应该是:
$tesseract = new TesseractOCR(storage_path('app/public/text.png')); // Correct
返回空白页。使用 thiagoalessio Tesseract OCR PHP.
Tesseract 安装在我的 Homestead VM 上:
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.
使用 laravel 和 PHP 的 Tesseract OCR,接收图像路径的 TesseractOCR
的构造函数似乎不接受 URL 作为一个参数。由于图像的asset()
returns URL,这将不起作用。这应该是一个严格的路径。
$tesseract = new TesseractOCR(asset('storage/app/public/text.png')); // Incorrect
应该是:
$tesseract = new TesseractOCR(storage_path('app/public/text.png')); // Correct