mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-08 13:28:39 +00:00
check dependencies
This commit is contained in:
parent
6e6aa16f84
commit
eb3449f308
|
|
@ -102,14 +102,22 @@ final class TesseractOcr
|
||||||
. ' -l ' . \implode('+', $languages)
|
. ' -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) {
|
if ($parsed === false) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo: auto flip image if x% of text are garbage words?
|
// @todo: auto flip image if x% of text are garbage words?
|
||||||
|
|
||||||
\unlink($temp);
|
\unlink($filepath);
|
||||||
|
|
||||||
return \trim($parsed);
|
return \trim($parsed);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,18 @@ use phpOMS\Image\Thresholding;
|
||||||
*/
|
*/
|
||||||
final class TesseractOcrTest extends \PHPUnit\Framework\TestCase
|
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
|
private function outputTest(string $name, float $m1, float $m2) : void
|
||||||
{
|
{
|
||||||
if (false) {
|
if (false) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user