kmisc 2.1.126__py3-none-any.whl → 2.1.128__py3-none-any.whl
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.
- kmisc/__init__.py +15 -12
- {kmisc-2.1.126.dist-info → kmisc-2.1.128.dist-info}/METADATA +1 -1
- kmisc-2.1.128.dist-info/RECORD +6 -0
- kmisc-2.1.126.dist-info/RECORD +0 -6
- {kmisc-2.1.126.dist-info → kmisc-2.1.128.dist-info}/LICENSE +0 -0
- {kmisc-2.1.126.dist-info → kmisc-2.1.128.dist-info}/WHEEL +0 -0
- {kmisc-2.1.126.dist-info → kmisc-2.1.128.dist-info}/top_level.txt +0 -0
kmisc/__init__.py
CHANGED
@@ -3650,8 +3650,8 @@ def web_capture(url,output_file,image_size='full',wait_time=3,ignore_certificate
|
|
3650
3650
|
if backup == 2:
|
3651
3651
|
comp_a=f'{output_file}.0'
|
3652
3652
|
comp_b=f'{output_file}.1'
|
3653
|
-
if os.path.isfile(comp_a) and os.path.isfile(comp_b):
|
3654
|
-
if filecmp.cmp(comp_a,comp_b):
|
3653
|
+
if os.path.isfile(output_file) and os.path.isfile(comp_a) and os.path.isfile(comp_b):
|
3654
|
+
if filecmp.cmp(comp_a,comp_b) and (filecmp.cmp(output_file,comp_a) or filecmp.cmp(output_file,comp_b)):
|
3655
3655
|
if log:
|
3656
3656
|
if IsIn(log,['screen','log','print',print]):
|
3657
3657
|
printf(Dot(),direct=True)
|
@@ -3742,8 +3742,8 @@ class OCR:
|
|
3742
3742
|
Import('cv2',install_name='opencv-python')
|
3743
3743
|
else:
|
3744
3744
|
Import('easyocr')
|
3745
|
-
|
3746
|
-
|
3745
|
+
Import('logging')
|
3746
|
+
logging.getLogger('easyocr').setLevel(logging.ERROR)
|
3747
3747
|
warnings.filterwarnings("ignore", category=RuntimeWarning, module="networkx.utils.backends")
|
3748
3748
|
warnings.filterwarnings("ignore", category=UserWarning, module="torch.utils.data.dataloader")
|
3749
3749
|
# Suppress EasyOCR CPU warning
|
@@ -3754,10 +3754,20 @@ class OCR:
|
|
3754
3754
|
model_storage_directory=self.model_storage_directory,
|
3755
3755
|
download_enabled=False)
|
3756
3756
|
|
3757
|
-
def Text(self,detail=0,low_text=None,contrast_ths=None,image_file=None,output=str):
|
3757
|
+
def Text(self,detail=0,low_text=None,contrast_ths=None,image_file=None,output=str,enhance=None):
|
3758
3758
|
if not image_file: image_file=self.image_file
|
3759
3759
|
if not image_file: return False
|
3760
3760
|
if not os.path.isfile(image_file): return False
|
3761
|
+
if enhance is None:
|
3762
|
+
enhance=self.enhance
|
3763
|
+
if enhance:
|
3764
|
+
Import('PIL',install_name='Pillow')
|
3765
|
+
image = PIL.Image.open(image_file)
|
3766
|
+
image = image.convert('L') #Grayscale
|
3767
|
+
image = PIL.ImageEnhance.Contrast(image).enhance(3.0) #high contrast
|
3768
|
+
image = PIL.ImageEnhance.Sharpness(image).enhance(2.0)#Sharpen
|
3769
|
+
image = image.convert('RGB').point(lambda p: 255 if p > 140 else 0) # Adjust threshold if needed
|
3770
|
+
image.save(image_file)
|
3761
3771
|
if self.ocr_module == 'pytesseract':
|
3762
3772
|
image = cv2.imread(image_file)
|
3763
3773
|
# Convert to grayscale
|
@@ -3801,13 +3811,6 @@ class OCR:
|
|
3801
3811
|
opts['allowlist']='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:/-_@,"+'
|
3802
3812
|
if isinstance(low_text,float): opts['low_text']=low_test
|
3803
3813
|
if isinstance(contrast_ths,float): opts['contrast_ths']=contrast_ths
|
3804
|
-
if self.enhance:
|
3805
|
-
image = PIL.Image.open(image_file)
|
3806
|
-
image = image.convert('L') #Grayscale
|
3807
|
-
image = PIL.ImageEnhance.Contrast(image).enhance(3.0) #high contrast
|
3808
|
-
image = PIL.ImageEnhance.Sharpness(image).enhance(2.0)#Sharpen
|
3809
|
-
image = image.convert('RGB').point(lambda p: 255 if p > 140 else 0) # Adjust threshold if needed
|
3810
|
-
image.save(image_file)
|
3811
3814
|
text=self.reader.readtext(image_file,**opts)
|
3812
3815
|
if output is str:
|
3813
3816
|
return ' '.join(text)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
kmisc/__init__.py,sha256=HyGUe_FMo91P5_9TokUZNbb5xuGcIbzZou14MI5gdgU,164285
|
2
|
+
kmisc-2.1.128.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
+
kmisc-2.1.128.dist-info/METADATA,sha256=TSjRtdKRGBUSGeTCoCXO9bdgFd6ptpwPH_QiGJTVw2o,5523
|
4
|
+
kmisc-2.1.128.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
5
|
+
kmisc-2.1.128.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
+
kmisc-2.1.128.dist-info/RECORD,,
|
kmisc-2.1.126.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
kmisc/__init__.py,sha256=9Tr1tEZPHJ7CQXPJz6bjoEwW6IEOGIl1VBrBzgTjASo,164077
|
2
|
-
kmisc-2.1.126.dist-info/LICENSE,sha256=mn9ekhb34HJxsrVhcxrLXJUzy55T62zg-Gh9Ro0mVJI,1066
|
3
|
-
kmisc-2.1.126.dist-info/METADATA,sha256=K7bGVkNJcPRqIiZeOxUUUskLANnK3p1J2agHVDBpGk8,5523
|
4
|
-
kmisc-2.1.126.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
5
|
-
kmisc-2.1.126.dist-info/top_level.txt,sha256=wvdHf5aQTqcGYvxk-F9E_BMWLMhlwC8INBmwO-V6_X4,6
|
6
|
-
kmisc-2.1.126.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|