mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-12 05:50:49 +08:00
Fixed issue #158
This commit is contained in:
1 parent
55bb974b5d
commit
e388bd9b03
4 files changed
+50
-2
No files matched your search
@@ -135,7 +135,12 @@ class LoadImage:
|
||||
not_a = cv2.cvtColor(not_a, cv2.COLOR_GRAY2BGR)
|
||||
|
||||
new_img = cv2.bitwise_and(new_img, new_img, mask=a)
|
||||
new_img = cv2.add(new_img, not_a)
|
||||
|
||||
mean_color = np.mean(new_img)
|
||||
if mean_color <= 0.0:
|
||||
new_img = cv2.add(new_img, not_a)
|
||||
else:
|
||||
new_img = cv2.bitwise_not(new_img)
|
||||
return new_img
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -217,7 +217,12 @@ class LoadImage:
|
||||
not_a = cv2.cvtColor(not_a, cv2.COLOR_GRAY2BGR)
|
||||
|
||||
new_img = cv2.bitwise_and(new_img, new_img, mask=a)
|
||||
new_img = cv2.add(new_img, not_a)
|
||||
|
||||
mean_color = np.mean(new_img)
|
||||
if mean_color <= 0.0:
|
||||
new_img = cv2.add(new_img, not_a)
|
||||
else:
|
||||
new_img = cv2.bitwise_not(new_img)
|
||||
return new_img
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -20,6 +20,25 @@ img_path = tests_dir / "ch_en_num.jpg"
|
||||
package_name = "rapidocr_paddle"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"img_name,gt",
|
||||
[
|
||||
(
|
||||
"black_font_color_transparent.png",
|
||||
"我是中国人",
|
||||
),
|
||||
(
|
||||
"white_font_color_transparent.png",
|
||||
"我是中国人",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_transparent_img(img_name: str, gt: str):
|
||||
img_path = tests_dir / img_name
|
||||
result, _ = engine(img_path)
|
||||
assert result[0][1] == gt
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"img_name,gt_len,gt_first_len",
|
||||
[
|
||||
|
||||
@@ -20,6 +20,25 @@ img_path = tests_dir / "ch_en_num.jpg"
|
||||
package_name = "rapidocr_openvino"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"img_name,gt",
|
||||
[
|
||||
(
|
||||
"black_font_color_transparent.png",
|
||||
"我是中国人",
|
||||
),
|
||||
(
|
||||
"white_font_color_transparent.png",
|
||||
"我是中国人",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_transparent_img(img_name: str, gt: str):
|
||||
img_path = tests_dir / img_name
|
||||
result, _ = engine(img_path)
|
||||
assert result[0][1] == gt
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"img_name,gt_len,gt_first_len",
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user