File size: 1,462 Bytes
daf0288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

from typing import Any, List, Literal, Mapping, Optional, Tuple
from abc import ABC, abstractmethod

import numpy as np
import cv2
from PIL import Image
from abc import ABC, abstractmethod

from utils import cropImage


class OCRComponent:
     """
     Wrapper class for cropping images and giving it to OCR Predictor 
     """
     def predict_pdf(self, pdf_name:str="", page:int=None, bbx:List[List[float]]=None)-> List[List[float]]:
        #TODO: Preprocessing to crop interest region 
        pass


class TextDetector(ABC):
    """
    Abstract base class for text detectors that takes in bounding boxes, pdf name, and page
    and returns bounding boxes results on them.
    """
    
    def __init__(self):
        
        pass

    """
    This is for predicting given an already cropped image 
    """
    @abstractmethod
    def predict_img(self, img:np.ndarray=None)-> List[List[float]]:
        # do something with self.input and return bbx 
        pass

class textRecognizer(ABC):
    """
    class of textRecognizer that takes in bounding boxes, pdf name and page and returns 
    OCR results on them 
    """
    
    def __init__(self):
        
        pass


    """
    This is for predicting given text line detection result form text line detector 
    """
    @abstractmethod
    def predict_img(self, bxs:List[List[float]], img:Image.Image)-> List[List[float]]:
        # do something with self.input and return bbx 
        pass