ocr-stream 2.2.6__tar.gz → 2.2.8__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.6 → ocr_stream-2.2.8}/PKG-INFO +2 -2
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream/ocr/__init__.py +2 -3
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream/recognize.py +19 -8
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream.egg-info/PKG-INFO +2 -2
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream.egg-info/requires.txt +1 -1
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/pyproject.toml +2 -2
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/README.md +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream/__init__.py +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream/bin_tess/__init__.py +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream/modules/__init__.py +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream.egg-info/SOURCES.txt +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream.egg-info/dependency_links.txt +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/ocr_stream.egg-info/top_level.txt +0 -0
- {ocr_stream-2.2.6 → ocr_stream-2.2.8}/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.8
|
|
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
|
|
@@ -20,7 +20,7 @@ from ocr_stream.bin_tess import BinTesseract
|
|
|
20
20
|
try:
|
|
21
21
|
import pyocr.tesseract
|
|
22
22
|
except:
|
|
23
|
-
pyocr
|
|
23
|
+
pyocr = None
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class TextRecognized(object):
|
|
@@ -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):
|
|
@@ -163,7 +162,7 @@ class IPyOcr(ABCOcrTesseract):
|
|
|
163
162
|
# The tools are returned in the recommended order of usage
|
|
164
163
|
self._pyOcr = pyocr_modules[0]
|
|
165
164
|
langs: list[str] = self._pyOcr.get_available_languages()
|
|
166
|
-
if lang in
|
|
165
|
+
if lang in langs:
|
|
167
166
|
self.lang = lang
|
|
168
167
|
else:
|
|
169
168
|
self.lang = langs[0]
|
|
@@ -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,29 +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:
|
|
97
|
+
def recognize_document(self, doc: DocumentPdf, *, dpi: int = 350) -> DocumentPdf:
|
|
87
98
|
_pages: list[PageDocumentPdf] = []
|
|
88
99
|
_pages.clear()
|
|
89
100
|
_conv = ConvertPdfToImages.create(doc)
|
|
90
|
-
images: list[ImageObject] = _conv.to_images()
|
|
101
|
+
images: list[ImageObject] = _conv.to_images(dpi=dpi)
|
|
91
102
|
max_num: int = len(images)
|
|
92
103
|
for num, img in enumerate(images):
|
|
93
104
|
self.pbar.update(
|
|
@@ -101,9 +112,9 @@ class RecognizePdf(object):
|
|
|
101
112
|
new_doc = DocumentPdf.create_from_pages(_pages)
|
|
102
113
|
return new_doc
|
|
103
114
|
|
|
104
|
-
def recognize_file_pdf(self, file: File) -> DocumentPdf:
|
|
115
|
+
def recognize_file_pdf(self, file: File, *, dpi: int = 300) -> DocumentPdf:
|
|
105
116
|
file_doc = DocumentPdf.create_from_file(file)
|
|
106
|
-
recognized_doc = self.recognize_document(file_doc)
|
|
117
|
+
recognized_doc = self.recognize_document(file_doc, dpi=dpi)
|
|
107
118
|
del file_doc
|
|
108
119
|
return recognized_doc
|
|
109
120
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ocr_stream
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.8
|
|
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.8"
|
|
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
|