[英]PHP / Laravel - Tesseract OCR - Full path to file
我已经在我的Forge服务器上成功安装了tesseract OCR和Imagick。 但是,当我尝试读取图像时,出现以下错误:
这是错误:
Error! The image "/home/forge/domain.com/storage/app/temp_files/ocrtotext_ijP1II9th2.jpeg" was not found.
The current __DIR__ is /home/forge/domain.com/vendor/thiagoalessio/tesseract_ocr/src
这是我的代码:
$text = (new TesseractOCR(storage_path() . '/app/temp_files/'.$imageName.'.jpeg'))
->lang('eng')
->psm($psm)
->run();
return $text;
我究竟做错了什么? 为什么tesseract在/vendor/
文件夹中而不在我的storage/..
文件夹中查找?
你会看到的:
public static function checkImagePath($image)
{
if (file_exists($image)) return;
$currentDir = __DIR__;
$msg = array();
$msg[] = "Error! The image \"$image\" was not found.";
$msg[] = '';
$msg[] = "The current __DIR__ is $currentDir";
$msg = join(PHP_EOL, $msg);
throw new ImageNotFoundException($msg);
}
如您所见,TesseractOCR使用函数file_exists
此函数返回false,表示您设置了错误的文件路径,或者符号链接断开,或者用户(Apache?)无法访问该文件,或其他原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.