Publishing 2019 R1 content
[platform/upstream/dldt.git] / tools / accuracy_checker / accuracy_checker / representation / text_detection_representation.py
1 """
2 Copyright (c) 2019 Intel Corporation
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 """
16
17 import numpy as np
18 from ..utils import remove_difficult
19 from .base_representation import BaseRepresentation
20
21
22 class TextDetectionRepresentation(BaseRepresentation):
23     def __init__(self, identifier='', points=None):
24         super().__init__(identifier)
25         self.points = points or []
26
27     def remove(self, indexes):
28         self.points = np.delete(self.points, indexes, axis=0)
29         difficult = self.metadata.get('difficult_boxes')
30         if not difficult:
31             return
32         self.metadata['difficult_boxes'] = remove_difficult(difficult, indexes)
33
34
35 class TextDetectionAnnotation(TextDetectionRepresentation):
36     def __init__(self, identifier='', points=None, description=''):
37         super().__init__(identifier, points)
38         self.description = description
39
40     def remove(self, indexes):
41         super().remove(indexes)
42         self.description = np.delete(self.description, indexes)
43
44
45 class TextDetectionPrediction(TextDetectionRepresentation):
46     pass