我已经在我的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/..
文件夹中查找?
答案 0 :(得分:1)
您会看到:
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?)无法访问该文件,或其他原因。