thiagoalessio / tesseract-ocr-for-php

A wrapper to work with Tesseract OCR inside PHP.
https://packagist.org/packages/thiagoalessio/tesseract_ocr
MIT License
2.86k stars 551 forks source link

Fatal error: The command did not produce any output. #173

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello buddy. How can I solve this problem?

My Code:


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require_once '../../../vendor/autoload.php';

use thiagoalessio\TesseractOCR\TesseractOCR;

$executable='/home/***/webapps/pub/thiagoalessio/tesseract_ocr';
$dir = $executable.'/temp_php';

if( chmod($dir, 0777) )
{

    echo (new TesseractOCR('text.png'))
        ->executable($executable)
        ->tempDir($dir)
        ->run();

    chmod($dir, 0755);

}
else
{
    echo "Couldn't do it.";
}

And the result:


Fatal error:
Uncaught thiagoalessio\TesseractOCR\UnsuccessfulCommandException: Error! The command did not produce any output.

Generated command:
"/home/***/webapps/pub/thiagoalessio/tesseract_ocr" "text.png" "/home/***/webapps/pub/thiagoalessio/tesseract_ocr/temp_php/ocro4YJIe"

Returned message:
sh: 1: /home/***/webapps/pub/thiagoalessio/tesseract_ocr: Permission denied in /home/***/webapps/pub/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php:67

Stack trace:
#0 /home/***/webapps/pub/thiagoalessio/tesseract_ocr/src/TesseractOCR.php(32): thiagoalessio\TesseractOCR\FriendlyErrors::checkCommandExecution(Object(thiagoalessio\TesseractOCR\Command), '', 'sh: 1: /home/...')
#1 /home/***/webapps/pub/thiagoalessio/tesseract_ocr/test.php(20): thiagoalessio\TesseractOCR\TesseractOCR->run()
#2 {main} th in /home/***/webapps/pub/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php on line 67
thiagoalessio commented 5 years ago

Hi @MabutasGroup , $executable='/home/***/webapps/pub/thiagoalessio/tesseract_ocr'; is not the executable you need ... what my library provides is only a convenient way of generating valid tesseract commands, but you still need the real tesseract installed on your server: https://github.com/tesseract-ocr/tesseract and the real tesseract is what you should put in executable ;D

Since this is a usage question rather than a bug on the library, I'm going to close this and invite you to join https://gitter.im/thiagoalessio/tesseract-ocr-for-php in case you have further questions, sound good ?

ghost commented 4 years ago

Thank you for your responding.

https://github.com/tesseract-ocr/tesseract/issues/751 It seems Blacklist and whitelist no longer work in 4.00alpha. They used to work in 3.04. If I want to use them, I should downgrade to tesseract 3.04 ?

akbarjondev commented 4 years ago

Hi @thiagoalessio . Recently I have installed tesseract ocr php to my web hosting server. After some tests, I have had this error. Please help.

Fatal error: Uncaught thiagoalessio\TesseractOCR\UnsuccessfulCommandException: Error! The command did not produce any output. Generated command: "/home/g/gimmick/@@@.ru/public_html/bots/../tesseract/vendor/thiagoalessio/tesseract_ocr/src/TesseractOCR.php" "frame.jpg" "/tmp/ocrJvi4pJ" Returned message: sh: 1: /home/g/gimmick/@@@.ru/public_html/bots/../tesseract/vendor/thiagoalessio/tesseract_ocr/src/TesseractOCR.php: Permission denied in /home/g/gimmick/@@@.ru/public_html/tesseract/vendor/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php:74 Stack trace: #0 /home/g/gimmick/@@@.ru/public_html/tesseract/vendor/thiagoalessio/tesseract_ocr/src/TesseractOCR.php(39): thiagoalessio\TesseractOCR\FriendlyErrors::checkCommandExecution(Object(thiagoalessio\TesseractOCR\Command), '', 'sh: 1: /home/g/...') #1 /home/g/gimmick/@@@.ru/public_html/bots/testejarimabot.php(409): thiagoalessio\TesseractOCR\TesseractOCR->run() #2 {main} thrown in /home/g/gimmick/@@@.ru/public_html/tesseract/vendor/thiagoalessio/tesseract_ocr/src/FriendlyErrors.php on line 74 err