From 55bb974b5d93a1cf4199d182b5d446aa19f922a1 Mon Sep 17 00:00:00 2001 From: SWHL Date: Wed, 6 Mar 2024 10:40:17 +0800 Subject: [PATCH] Support transparent white font image rec in rapidocr_onnxruntime --- python/demo.py | 2 +- python/rapidocr_onnxruntime/utils.py | 7 ++++++- .../black_font_color_transparent.png | Bin 0 -> 9362 bytes .../white_font_color_transparent.png | Bin 0 -> 9446 bytes python/tests/test_ort.py | 19 ++++++++++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 python/tests/test_files/black_font_color_transparent.png create mode 100644 python/tests/test_files/white_font_color_transparent.png diff --git a/python/demo.py b/python/demo.py index 5e5d6f702..cd5cf1687 100644 --- a/python/demo.py +++ b/python/demo.py @@ -12,7 +12,7 @@ engine = RapidOCR() vis = VisRes() -image_path = "tests/test_files/test_without_det.jpg" +image_path = "tests/test_files/black_font_color_transparent.png" with open(image_path, "rb") as f: img = f.read() diff --git a/python/rapidocr_onnxruntime/utils.py b/python/rapidocr_onnxruntime/utils.py index 778066dd7..181dd91b5 100644 --- a/python/rapidocr_onnxruntime/utils.py +++ b/python/rapidocr_onnxruntime/utils.py @@ -208,7 +208,12 @@ def cvt_four_to_three(img: np.ndarray) -> np.ndarray: 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 diff --git a/python/tests/test_files/black_font_color_transparent.png b/python/tests/test_files/black_font_color_transparent.png new file mode 100644 index 0000000000000000000000000000000000000000..dfd20a14de224df22443de71405ec24f612deaf0 GIT binary patch literal 9362 zcmeHMXH-;4l&&U9QV?iBiK3!_N|sEEB$1$!l_&^G5D>|!ham|FIE*661``NP7Exjg zlA9z#BN+o3x*2lbdN{jh_w0{7``$2%OxF+YXH#S z1OT;mfDW$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CeM~@$(Y&!sO0_JH@T}HKpAU#^m8!rf2RQA}G^egJ}0kMuc2Bp3y<6y(wCC?u&rM z(5#WrnYo5YVNkoVY4?iE;A2-neFw&CPTliVUm~+ZWyjToz})XC3b)0-fBiv&O|1xx z@~x2rr!GR+dXiC7i-+%|53Z8DY_q2NW~SGZZU2XdeUPXdcEs_Bx1vw7|F$l79u8`_8hDI2C}n$tKu57a^^G|JTZF2j7E< zjy1kq5Y2&B1h3EW;cI65rp~Shk>dRN&SQa)%6bOC{k+ z0Gx-_0j&QGuVLUQNbi`OH4B7CAcMjHQRT1cf8J@q%P}ba@3r4L`0WS3V*$wnzy09< c)WME`!XrohA|?~qPXcgB(?Fv@-8Sq$0C@uScmMzZ literal 0 HcmV?d00001 diff --git a/python/tests/test_files/white_font_color_transparent.png b/python/tests/test_files/white_font_color_transparent.png new file mode 100644 index 0000000000000000000000000000000000000000..9f9f095eb9139a34cbb01ab03b99d52dbbc569e6 GIT binary patch literal 9446 zcmeHMXH=6*x1P`i=@LMsC`Zu%8bDBb02Mo^5Q1V1U783;lVU^=gb1hy=|wyU(u?$# z15$)YkzNH+KsrW>)H^Td`|kJSu66Ia|DCm1Ox{e{^X$E!{k)SW`j>S%+4r&o065Q` zJ#`fTRx{!kt%nr;C65q0jAmVrmy?9jmd0TnJ5 z{ft|mw<8n<%cIMljIDy_prm_t#^&(z{9Rkg-fZVgcd(j2BeMfxFBg zDQ^>oLPaO1iA+eHdGPibm~uIQ27YS%Y%M1R zR6Bz0O6TV9Z0-U)qupzrF;8xmil^0YFimQ~#T}gwxE$T&^tO7zKH}sX7~j;%FjHfF z6esRS03KTJS#Xip;uLa5iPi4k^#GZ|MAGzfmrV~tfi+%uD*ogXy8eM-p6@;{Ndb_- zcJ(2f?R7GdDGw|#ieT)%KY&M!$>ji1qdm}#IQ)dT!dA;W~h;-be>je*X^ablaqRgM@WkBY45P7rR$9#j@qYEAj3n54LYj1?g;@X zMaca%u(`*&UJg2*EbKPS4JK*udC`^8u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~`zPUkVkH@FsJzwcmTWT(Cd3X4=Fv2B%a-VC`0G zj)}|8UI8>0327K`DaN;5n$vMb9p045+RK~I>MAt^KGhKIPckgThp|fg=;d;_h&IAs zhH<;lT@_|l5(BQG_lK^DhS9XlgeA6U0Z+*}wWxH(U zoMCHd$OsgKV8j)%inkNnk=Bt{P8+kX>AksT!7ABswef=PxFQ^}bCH41ew5;Vg67V# zPkfiT`!qk%IvY?XM&Z{4M7`KgcU{X@Wj(9#z#U#c0DwWR^9BZ#2|is}9eHbregj*` zmBPaFX)KfGter?Rz4e*XpBPxi0? literal 0 HcmV?d00001 diff --git a/python/tests/test_ort.py b/python/tests/test_ort.py index ca0e993f8..45e8971fb 100644 --- a/python/tests/test_ort.py +++ b/python/tests/test_ort.py @@ -20,6 +20,25 @@ package_name = "rapidocr_onnxruntime" +@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", [