ocr-stream 2.2__tar.gz → 2.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ocr_stream-2.2 → ocr_stream-2.2.7}/PKG-INFO +2 -2
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream/ocr/__init__.py +0 -1
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream/recognize.py +28 -13
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream.egg-info/PKG-INFO +2 -2
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream.egg-info/requires.txt +1 -1
- {ocr_stream-2.2 → ocr_stream-2.2.7}/pyproject.toml +2 -2
- {ocr_stream-2.2 → ocr_stream-2.2.7}/README.md +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream/__init__.py +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream/bin_tess/__init__.py +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream/modules/__init__.py +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream.egg-info/SOURCES.txt +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream.egg-info/dependency_links.txt +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/ocr_stream.egg-info/top_level.txt +0 -0
- {ocr_stream-2.2 → ocr_stream-2.2.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ocr_stream
|
|
3
|
-
Version: 2.2
|
|
3
|
+
Version: 2.2.7
|
|
4
4
|
Summary: Extrair textos de documentos digitalizados e imagens.
|
|
5
5
|
Author: Bruno Chaves
|
|
6
6
|
Requires-Python: >=3.11
|
|
@@ -11,7 +11,7 @@ Requires-Dist: openpyxl
|
|
|
11
11
|
Requires-Dist: pandas
|
|
12
12
|
Requires-Dist: requests>=2.32.4
|
|
13
13
|
Requires-Dist: opencv-python
|
|
14
|
-
Requires-Dist: convert_stream>=2.2.
|
|
14
|
+
Requires-Dist: convert_stream>=2.2.7
|
|
15
15
|
Requires-Dist: soup_files
|
|
16
16
|
|
|
17
17
|
# ocrlib
|
|
@@ -150,7 +150,6 @@ class IPytesseract(ABCOcrTesseract):
|
|
|
150
150
|
# Modulo OCR pyocr
|
|
151
151
|
# ======================================================================#
|
|
152
152
|
|
|
153
|
-
|
|
154
153
|
class IPyOcr(ABCOcrTesseract):
|
|
155
154
|
|
|
156
155
|
def __init__(self, bin_tess: BinTesseract, *, lang: str = None, tess_data_dir: str = None):
|
|
@@ -13,7 +13,11 @@ class RecognizeImage(object):
|
|
|
13
13
|
Reconhecer textos em imagens com pytesseract|pyocr usando o tesseract
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
def __init__(
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
bin_tess: BinTesseract = BinTesseract(), *,
|
|
19
|
+
lib_ocr: LibOcr = DEFAULT_LIB_OCR
|
|
20
|
+
):
|
|
17
21
|
super().__init__()
|
|
18
22
|
self.module_ocr: TesseractOcr = TesseractOcr.create(
|
|
19
23
|
bin_tess,
|
|
@@ -65,28 +69,36 @@ class RecognizeImage(object):
|
|
|
65
69
|
|
|
66
70
|
class RecognizePdf(object):
|
|
67
71
|
|
|
68
|
-
def __init__(
|
|
72
|
+
def __init__(
|
|
73
|
+
self,
|
|
74
|
+
bin_tess: BinTesseract = BinTesseract(), *,
|
|
75
|
+
lib_ocr: LibOcr = DEFAULT_LIB_OCR,
|
|
76
|
+
):
|
|
69
77
|
self.recognize_image: RecognizeImage = RecognizeImage(bin_tess, lib_ocr=lib_ocr)
|
|
70
78
|
self.pbar: ProgressBarAdapter = CreatePbar().get()
|
|
71
79
|
|
|
72
80
|
def set_pbar(self, p: ProgressBarAdapter):
|
|
73
81
|
self.pbar = p
|
|
74
82
|
|
|
75
|
-
def recognize_page_pdf(self, page: PageDocumentPdf) -> DocumentPdf:
|
|
83
|
+
def recognize_page_pdf(self, page: PageDocumentPdf, *, dpi: int = 350) -> DocumentPdf:
|
|
76
84
|
"""
|
|
77
85
|
Converte a página em Imagem, reconhece o texto com OCR e
|
|
78
86
|
retorna uma nova página com o texto reconhecido.
|
|
79
87
|
"""
|
|
80
88
|
_doc = DocumentPdf.create_from_pages([page])
|
|
81
89
|
_conv = ConvertPdfToImages.create(_doc)
|
|
82
|
-
img: ImageObject = _conv.to_images()[0]
|
|
90
|
+
img: ImageObject = _conv.to_images(dpi=dpi)[0]
|
|
83
91
|
text_recognized: TextRecognized = self.recognize_image.image_recognize(img)
|
|
92
|
+
del _doc
|
|
93
|
+
del _conv
|
|
94
|
+
del img
|
|
84
95
|
return text_recognized.to_document()
|
|
85
96
|
|
|
86
|
-
def recognize_document(self, doc: DocumentPdf) -> DocumentPdf:
|
|
87
|
-
|
|
97
|
+
def recognize_document(self, doc: DocumentPdf, *, dpi: int = 350) -> DocumentPdf:
|
|
98
|
+
_pages: list[PageDocumentPdf] = []
|
|
99
|
+
_pages.clear()
|
|
88
100
|
_conv = ConvertPdfToImages.create(doc)
|
|
89
|
-
images: list[ImageObject] = _conv.to_images()
|
|
101
|
+
images: list[ImageObject] = _conv.to_images(dpi=dpi)
|
|
90
102
|
max_num: int = len(images)
|
|
91
103
|
for num, img in enumerate(images):
|
|
92
104
|
self.pbar.update(
|
|
@@ -94,12 +106,15 @@ class RecognizePdf(object):
|
|
|
94
106
|
f'Aplicando OCR [{num+1} de {max_num}]'
|
|
95
107
|
)
|
|
96
108
|
text_recognized = self.recognize_image.image_recognize(img)
|
|
97
|
-
|
|
109
|
+
_pages.append(text_recognized.to_page_pdf())
|
|
98
110
|
print()
|
|
99
111
|
self.pbar.stop()
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
new_doc = DocumentPdf.create_from_pages(_pages)
|
|
113
|
+
return new_doc
|
|
114
|
+
|
|
115
|
+
def recognize_file_pdf(self, file: File, *, dpi: int = 300) -> DocumentPdf:
|
|
116
|
+
file_doc = DocumentPdf.create_from_file(file)
|
|
117
|
+
recognized_doc = self.recognize_document(file_doc, dpi=dpi)
|
|
118
|
+
del file_doc
|
|
119
|
+
return recognized_doc
|
|
105
120
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ocr_stream
|
|
3
|
-
Version: 2.2
|
|
3
|
+
Version: 2.2.7
|
|
4
4
|
Summary: Extrair textos de documentos digitalizados e imagens.
|
|
5
5
|
Author: Bruno Chaves
|
|
6
6
|
Requires-Python: >=3.11
|
|
@@ -11,7 +11,7 @@ Requires-Dist: openpyxl
|
|
|
11
11
|
Requires-Dist: pandas
|
|
12
12
|
Requires-Dist: requests>=2.32.4
|
|
13
13
|
Requires-Dist: opencv-python
|
|
14
|
-
Requires-Dist: convert_stream>=2.2.
|
|
14
|
+
Requires-Dist: convert_stream>=2.2.7
|
|
15
15
|
Requires-Dist: soup_files
|
|
16
16
|
|
|
17
17
|
# ocrlib
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ocr_stream"
|
|
7
|
-
version = "2.2"
|
|
7
|
+
version = "2.2.7"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Bruno Chaves"},
|
|
10
10
|
]
|
|
@@ -20,7 +20,7 @@ dependencies = [
|
|
|
20
20
|
"pandas",
|
|
21
21
|
"requests>=2.32.4",
|
|
22
22
|
"opencv-python",
|
|
23
|
-
"convert_stream>=2.2.
|
|
23
|
+
"convert_stream>=2.2.7",
|
|
24
24
|
"soup_files",
|
|
25
25
|
]
|
|
26
26
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|