簡體   English   中英

PHP / Laravel-Tesseract OCR-文件的完整路徑

[英]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/..文件夾中查找?

如果您在https://github.com/thiagoalessio/tesseract-ocr-for-php/blob/ea31d13143683c1b76e622f2b76be4c3e2e6c1af/src/FriendlyErrors.php檢查代碼

你會看到的:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM