mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
check dependencies
This commit is contained in:
parent
6e6aa16f84
commit
eb3449f308
|
|
@ -102,14 +102,22 @@ final class TesseractOcr
|
|||
. ' -l ' . \implode('+', $languages)
|
||||
);
|
||||
|
||||
$parsed = \file_get_contents($temp . '.txt');
|
||||
$filepath = \is_file($temp . '.txt')
|
||||
? $temp . '.txt'
|
||||
: $temp;
|
||||
|
||||
if (!\is_file($filepath)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$parsed = \file_get_contents($filepath);
|
||||
if ($parsed === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// @todo: auto flip image if x% of text are garbage words?
|
||||
|
||||
\unlink($temp);
|
||||
\unlink($filepath);
|
||||
|
||||
return \trim($parsed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,18 @@ use phpOMS\Image\Thresholding;
|
|||
*/
|
||||
final class TesseractOcrTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
if (!\is_file('/usr/bin/tesseract')) {
|
||||
$this->markTestSkipped(
|
||||
'Couldn\'t find tesseract'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function outputTest(string $name, float $m1, float $m2) : void
|
||||
{
|
||||
if (false) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user