-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from deepghs/dev/ocr
dev(narugo): deprecate imgutils.detect.detect_text
- Loading branch information
Showing
7 changed files
with
382 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
docs/source/api_doc/detect/text_detect_deprecate_demo.plot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import font | ||
from imgutils.data import load_image | ||
from imgutils.detect import detect_text | ||
from imgutils.detect.visual import detection_visualize | ||
from imgutils.ocr import ocr | ||
from plot import image_plot | ||
|
||
|
||
def _detect_with_ocr(img, *, max_size=None, **kwargs): | ||
img = load_image(img, mode='RGB', force_background='white') | ||
if max_size is not None and min(img.height, img.width) > max_size: | ||
r = max_size / min(img.height, img.width) | ||
img = img.resize(( | ||
int(round(img.width * r)), | ||
int(round(img.height * r)), | ||
)) | ||
|
||
return detection_visualize(img, ocr(img, **kwargs), fp=font.get_cn_fp()) | ||
|
||
|
||
def _detect_with_deprecated(img, **kwargs): | ||
return detection_visualize(img, detect_text(img, **kwargs)) | ||
|
||
|
||
if __name__ == '__main__': | ||
image_plot( | ||
(_detect_with_deprecated('text/ml2.jpg'), 'detect_text'), | ||
(_detect_with_ocr('text/ml2.jpg'), 'detect_text_with_ocr'), | ||
columns=2, | ||
figsize=(13, 3.8), | ||
) |
299 changes: 299 additions & 0 deletions
299
docs/source/api_doc/detect/text_detect_deprecate_demo.plot.py.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ scipy | |
emoji>=2.5.0 | ||
pilmoji>=1.3.0 | ||
shapely | ||
pyclipper | ||
pyclipper | ||
deprecation>=2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters