跳转至

快速开始

1. 安装

pip install rapidocr

2. 使用

rapidocr -img "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true" --vis_res
1
2
3
4
5
6
7
8
9
from rapidocr import RapidOCR

engine = RapidOCR()

img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
result = engine(img_url)
print(result)

result.vis()

3. 查看可视化结果

Demo

4. 返回result结果示例

返回结果是一个RapidOCROutput数据类,可以直接通过result.boxesresult.txts来访问使用。

RapidOCROutput(
    boxes=array([[[  6.,   2.],
        [322.,   9.],
        [320., 104.],
        [  4.,  97.]],

       [[ 70.,  98.],
        [252.,  98.],
        [252., 125.],
        [ 70., 125.]],

       [[ 68., 144.],
        [256., 144.],
        [256., 165.],
        [ 68., 165.]],

       [[108., 170.],
        [217., 170.],
        [217., 182.],
        [108., 182.]],

       [[ 35., 227.],
        [ 62., 227.],
        [ 62., 236.],
        [ 35., 236.]],

       [[139., 223.],
        [187., 223.],
        [187., 251.],
        [139., 251.]],

       [[ 35., 233.],
        [ 81., 236.],
        [ 80., 255.],
        [ 33., 252.]],

       [[257., 234.],
        [304., 236.],
        [303., 254.],
        [257., 253.]],

       [[259., 227.],
        [286., 226.],
        [287., 236.],
        [259., 237.]],

       [[140., 243.],
        [186., 245.],
        [186., 272.],
        [139., 271.]],

       [[129., 289.],
        [207., 290.],
        [206., 340.],
        [128., 338.]],

       [[ 98., 320.],
        [129., 320.],
        [129., 330.],
        [ 98., 330.]],

       [[205., 316.],
        [223., 316.],
        [223., 335.],
        [205., 335.]],

       [[114., 342.],
        [210., 342.],
        [210., 355.],
        [114., 355.]],

       [[ 68., 362.],
        [151., 362.],
        [151., 384.],
        [ 68., 384.]],

       [[202., 362.],
        [286., 362.],
        [286., 384.],
        [202., 384.]],

       [[ 68., 391.],
        [151., 391.],
        [151., 413.],
        [ 68., 413.]],

       [[202., 391.],
        [287., 391.],
        [287., 413.],
        [202., 413.]]], dtype=float32),
    txts=('正品促销', '大桶装更划算', '强力去污符合国标', '40°C深度防冻不结冰', '日常价¥', '真击', '10.0起', '10.0起', '日常价¥', '底价', '5.8', '券后价¥', '起', '惊喜福利不容错过', '极速发货', '冰点标准', '破损就赔', '假一赔十'),
    scores=(0.99893, 0.9843, 0.97842, 0.93412, 0.81418, 0.66226, 0.99243, 0.99849, 0.81369, 0.99633, 0.9999, 0.83907, 0.99993, 0.99782, 0.99813, 0.99786, 0.92679, 0.99717),
    word_results=(None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None), elapse_list=[0.16008154186420143, 0.017705917358398438, 0.35501312371343374], elapse=0.5328005829360336)

推荐阅读

其他编程语言支持

评论