Skip to content

Commit

Permalink
Add a user-definable path for the OCR-Engines
Browse files Browse the repository at this point in the history
Signed-off-by: Christos Sidiropoulos <[email protected]>
  • Loading branch information
csidirop committed Aug 24, 2023
1 parent 6db8c67 commit 2c2b049
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/PageViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function mainAction()
{
// Load current document.
$this->loadDocument($this->requestData);
$this->parseOCRengines(GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf')['ocrEngines']);
$this->parseOCRengines(GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf')['ocrEngines']."/".GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf')['ocrEnginesConfig']);
$this->clearPageCache();
//Proccess request: Do OCR on given image(s):
if ($_POST["request"]) {
Expand Down
4 changes: 2 additions & 2 deletions Classes/Hooks/ConfigurationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public function checkOCRDConnection()
public function printActiveOCREngines()
{
$conf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('dlf');
$ocrEnginesJson = json_decode(file_get_contents("../".$conf['ocrEngines']), true); # working dir is '/var/www/typo3/public/typo3'
$ocrEnginesDir = dirname("../".$conf['ocrEngines']);
$ocrEnginesJson = json_decode(file_get_contents("../".$conf['ocrEngines']."/".$conf['ocrEnginesConfig']), true); # working dir is '/var/www/typo3/public/typo3'
$ocrEnginesDir = "../".$conf['ocrEngines'];
$files = scandir($ocrEnginesDir);
$ocrEngines = array(); // All ocrEngines in the directory
$activeOcrEngines = array(); // All active OCR engines
Expand Down
6 changes: 4 additions & 2 deletions Resources/Private/Language/Labels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@
<label index="config.ocrdConnect">OCR-D Connection</label>
<label index="config.ocrdHost">OCR-D server SSH config</label>
<label index="config.ocrEngine">Default OCR-Engine</label>
<label index="config.ocrEngines">Path to JSON with all active OCR Engines: Relative path from "/var/www/typo3/public/"</label>
<label index="config.ocrEngines">Path to all OCR Engines: Relative path from "/var/www/typo3/public/"</label>
<label index="config.ocrEnginesConfig">Path or filename to the config JSON with all active OCR Engines: Relative path from path given in `ocrEngines`</label>
<label index="config.ocrDelay">Delay until OCR start (in seconds)</label>
<label index="config.ocrThreads">Max. number of OCR processes running simultaneously</label>
<label index="config.ocrTimeout">Timeout for OCR processes (in seconds): For reference: While the fastest OCR Engines with easy layouts can complete in under 2 sec, more complex layouts and other engines may use 260s and more!</label>
Expand Down Expand Up @@ -424,7 +425,8 @@
<label index="config.ocrdConnect">OCR-D Verbindung</label>
<label index="config.ocrdHost">OCR-D Server SSH config</label>
<label index="config.ocrEngine">Standardmäßige OCR-Engine</label>
<label index="config.ocrEngines">Pfad zum JSON mit allen aktiven OCR Engines: Relativer Pfad von "/var/www/typo3/public/" aus.</label>
<label index="config.ocrEngines">Pfad zu allen OCR-Engines: Relativer Pfad von "/var/www/typo3/public/"</label>
<label index="config.ocrEnginesConfig">Pfad oder Dateiname zum Konfigurations-JSON mit allen aktiven OCR-Engines: Relativer Pfad von dem in `ocrEngines` angegebenen Pfad</label>
<label index="config.ocrDelay">Verzögerung bis zum Start der OCR (in Sekunden)</label>
<label index="config.ocrThreads">Anzahl der max. gleichzeitig laufenden OCR Prozesse</label>
<label index="config.ocrTimeout">Maximale Laufzeit der Volltexterkennung (in Sekunden): Zur Orientierung: Während die schnellsten OCR-Engines mit einfachen Layouts in weniger als 2 Sekunden fertig werden können, können komplexere Layouts und andere Engines 260s und mehr benötigen!</label>
Expand Down
4 changes: 3 additions & 1 deletion ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ fulltextLockFolder = fileadmin/_temp_/ocrTempFolder/lock
# cat=Fulltext-OCR-general; type=boolean; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.ocrDebug
ocrDebug=0
# cat=Fulltext-OCR-Engines; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.ocrEngines
ocrEngines = typo3conf/ext/dlf/Classes/Plugin/Tools/FullTextGenerationScripts/ocrEngines.json
ocrEngines = typo3conf/ext/dlf/Classes/Plugin/Tools/FullTextGenerationScripts/
# cat=Fulltext-OCR-Engines; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.ocrEnginesConfig
ocrEnginesConfig = ocrEngines.json
# cat=Fulltext-OCR-Engines; type=user[Kitodo\Dlf\Hooks\ConfigurationForm->printActiveOCREngines]; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.ocrLoadActiveOCREngines
ocrLoadActiveOCREngines = 0
# cat=Fulltext-OCR-Engines; type=string; label=LLL:EXT:dlf/Resources/Private/Language/Labels.xml:config.ocrEngine
Expand Down

0 comments on commit 2c2b049

Please sign in to comment.