ocr-stream 2.2.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ocr_stream
3
- Version: 2.2.6
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.4
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__(self, bin_tess: BinTesseract, *, lib_ocr: LibOcr = DEFAULT_LIB_OCR):
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__(self, bin_tess: BinTesseract, *, lib_ocr: LibOcr = DEFAULT_LIB_OCR):
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.6
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.4
14
+ Requires-Dist: convert_stream>=2.2.7
15
15
  Requires-Dist: soup_files
16
16
 
17
17
  # ocrlib
@@ -4,5 +4,5 @@ openpyxl
4
4
  pandas
5
5
  requests>=2.32.4
6
6
  opencv-python
7
- convert_stream>=2.2.4
7
+ convert_stream>=2.2.7
8
8
  soup_files
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ocr_stream"
7
- version = "2.2.6"
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.4",
23
+ "convert_stream>=2.2.7",
24
24
  "soup_files",
25
25
  ]
26
26
 
File without changes
File without changes