Fixed issue #158

This commit is contained in:
SWHL committed 2024-03-07 08:08:58 +08:00
1 parent 55bb974b5d
commit e388bd9b03
4 files changed
+50 -2

No files matched your search

+6 -1
View File
@@ -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
+6 -1
View File
@@ -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
+19
View File
@@ -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",
[
+19
View File
@@ -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",
[