Skip to content

Commit 3355e6a

Browse files
committed
feat(TaskProcessing): Add OCR TaskType
Signed-off-by: Marcel Klehr <[email protected]>
1 parent c0a4098 commit 3355e6a

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@
893893
'OCP\\TaskProcessing\\TaskTypes\\ContextAgentInteraction' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php',
894894
'OCP\\TaskProcessing\\TaskTypes\\ContextWrite' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ContextWrite.php',
895895
'OCP\\TaskProcessing\\TaskTypes\\GenerateEmoji' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php',
896+
'OCP\\TaskProcessing\\TaskTypes\\ImageToTextOpticalCharacterRecognition' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ImageToTextOpticalCharacterRecognition.php',
896897
'OCP\\TaskProcessing\\TaskTypes\\TextToImage' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToImage.php',
897898
'OCP\\TaskProcessing\\TaskTypes\\TextToSpeech' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToSpeech.php',
898899
'OCP\\TaskProcessing\\TaskTypes\\TextToText' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToText.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
934934
'OCP\\TaskProcessing\\TaskTypes\\ContextAgentInteraction' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php',
935935
'OCP\\TaskProcessing\\TaskTypes\\ContextWrite' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ContextWrite.php',
936936
'OCP\\TaskProcessing\\TaskTypes\\GenerateEmoji' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php',
937+
'OCP\\TaskProcessing\\TaskTypes\\ImageToTextOpticalCharacterRecognition' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ImageToTextOpticalCharacterRecognition.php',
937938
'OCP\\TaskProcessing\\TaskTypes\\TextToImage' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToImage.php',
938939
'OCP\\TaskProcessing\\TaskTypes\\TextToSpeech' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToSpeech.php',
939940
'OCP\\TaskProcessing\\TaskTypes\\TextToText' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToText.php',
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCP\TaskProcessing\TaskTypes;
11+
12+
use OCP\IL10N;
13+
use OCP\L10N\IFactory;
14+
use OCP\TaskProcessing\EShapeType;
15+
use OCP\TaskProcessing\ITaskType;
16+
use OCP\TaskProcessing\ShapeDescriptor;
17+
18+
/**
19+
* This is the task processing task type for OCR
20+
* @since 33.0.0
21+
*/
22+
class ImageToTextOpticalCharacterRecognition implements ITaskType {
23+
/**
24+
* @since 33.0.0
25+
*/
26+
public const ID = 'core:image2text:ocr';
27+
28+
private IL10N $l;
29+
30+
/**
31+
* @since 33.0.0
32+
*/
33+
public function __construct(
34+
IFactory $l10nFactory,
35+
) {
36+
$this->l = $l10nFactory->get('lib');
37+
}
38+
39+
40+
/**
41+
* @since 33.0.0
42+
*/
43+
public function getName(): string {
44+
return $this->l->t('Optical character recognition');
45+
}
46+
47+
/**
48+
* @since 33.0.0
49+
*/
50+
public function getDescription(): string {
51+
return $this->l->t('Extract text from an image');
52+
}
53+
54+
/**
55+
* @since 33.0.0
56+
*/
57+
public function getId(): string {
58+
return self::ID;
59+
}
60+
61+
/**
62+
* @return ShapeDescriptor[]
63+
* @since 33.0.0
64+
*/
65+
public function getInputShape(): array {
66+
return [
67+
'input' => new ShapeDescriptor(
68+
$this->l->t('Input Image'),
69+
$this->l->t('The image to extract text from'),
70+
EShapeType::Image
71+
),
72+
];
73+
}
74+
75+
/**
76+
* @return ShapeDescriptor[]
77+
* @since 33.0.0
78+
*/
79+
public function getOutputShape(): array {
80+
return [
81+
'output' => new ShapeDescriptor(
82+
$this->l->t('Output text'),
83+
$this->l->t('The text that was extracted from the image'),
84+
EShapeType::Text
85+
),
86+
];
87+
}
88+
}

0 commit comments

Comments
 (0)