fix async

This commit is contained in:
Dennis Eichhorn 2022-03-17 17:16:25 +01:00
parent a03fd72dbd
commit 4cb31cc3ed
3 changed files with 14 additions and 5 deletions

View File

@ -91,6 +91,7 @@ final class TesseractOcr
self::$bin,
$image . ' '
. ($temp = \tempnam(\sys_get_temp_dir(), 'ocr_'))
. ' -c preserve_interword_spaces=1'
. ' --psm ' . $psm
. ' --oem ' . $oem
. ' -l ' . \implode('+', $languages)

View File

@ -156,7 +156,7 @@ final class SystemUtils
. $cmd;
if ($async) {
$cmd .= ' > nul 2>&1';
$cmd .= ' > nul 2>&1 &';
}
} else {
$cmd = \escapeshellarg($executable)
@ -164,7 +164,7 @@ final class SystemUtils
. $cmd;
if ($async) {
$cmd .= ' > /dev/null 2>&1';
$cmd .= ' > /dev/null 2>&1 &';
}
}
@ -180,8 +180,16 @@ final class SystemUtils
throw new \Exception();
}
$stdout = \stream_get_contents($pipes[1]);
$stderr = \stream_get_contents($pipes[2]);
$stdout = '';
$stderr = '';
if ($async) {
\stream_set_blocking($pipes[1], false);
\stream_set_blocking($pipes[2], false);
} else {
$stdout = \stream_get_contents($pipes[1]);
$stderr = \stream_get_contents($pipes[2]);
}
foreach ($pipes as $pipe) {
\fclose($pipe);

View File

@ -81,7 +81,7 @@ class PdfParser
SystemUtils::runProc(
__DIR__ . '/../../../cOMS/Tools/InvoicePreprocessing/App',
\escapeshellarg($file) . ' '
. \escapeshellarg($file)
. \escapeshellarg($file)
);
$ocr = new TesseractOcr();