-
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.
- Loading branch information
1 parent
c894c6a
commit 6058425
Showing
16 changed files
with
145 additions
and
31 deletions.
There are no files selected for viewing
Binary file not shown.
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,8 @@ | ||
import os.path | ||
|
||
import matplotlib.font_manager as fm | ||
|
||
|
||
def get_cn_fp() -> fm.FontProperties: | ||
ttf_file = os.path.join(os.path.dirname(__file__), 'SimHei.ttf') | ||
return fm.FontProperties(fname=ttf_file) |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
imgutils.ocr | ||
======================== | ||
|
||
.. currentmodule:: imgutils.ocr | ||
|
||
.. automodule:: imgutils.ocr | ||
|
||
|
||
detect_text_with_ocr | ||
------------------------------------------------------ | ||
|
||
.. autofunction:: detect_text_with_ocr | ||
|
||
|
||
|
||
ocr | ||
------------------------------------------------------ | ||
|
||
.. autofunction:: ocr | ||
|
||
|
||
|
||
list_det_models | ||
------------------------------------------------------ | ||
|
||
.. autofunction:: list_det_models | ||
|
||
|
||
|
||
list_rec_models | ||
------------------------------------------------------ | ||
|
||
.. autofunction:: list_rec_models | ||
|
||
|
||
|
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,30 @@ | ||
import font | ||
from imgutils.data import load_image | ||
from imgutils.detect.visual import detection_visualize | ||
from imgutils.ocr import ocr | ||
from plot import image_plot | ||
|
||
_max_size = 480 | ||
|
||
|
||
def _detect(img, **kwargs): | ||
img = load_image(img, mode='RGB', force_background='white') | ||
if 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()) | ||
|
||
|
||
if __name__ == '__main__': | ||
image_plot( | ||
(_detect('post_text.jpg', recognize_model='japan_PP-OCRv3_rec'), 'Text of Post'), | ||
(_detect('anime_subtitle.jpg'), 'Subtitle of Anime'), | ||
(_detect('comic.jpg'), 'Comic'), | ||
(_detect('plot.png'), 'Complex'), | ||
columns=2, | ||
figsize=(12, 9), | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1 +1 @@ | ||
from .entry import detect_text_with_ocr, ocr | ||
from .entry import detect_text_with_ocr, ocr, list_det_models, list_rec_models | ||
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