{"id":9465,"date":"2025-11-07T13:57:27","date_gmt":"2025-11-07T05:57:27","guid":{"rendered":"\/?p=9465"},"modified":"2025-11-07T13:57:27","modified_gmt":"2025-11-07T05:57:27","slug":"%e5%9f%ba%e4%ba%8e-easyocr-hanlp-%e5%ae%9e%e7%8e%b0%e5%9b%be%e7%89%87%e6%96%87%e5%ad%97%e5%ae%9e%e4%bd%93%e8%af%86%e5%88%ab%ef%bc%88%e4%b8%ad%e6%96%87%e5%a7%93%e5%90%8d%e3%80%81%e6%9c%ba%e6%9e%84","status":"publish","type":"post","link":"\/?p=9465","title":{"rendered":"\u57fa\u4e8e EasyOCR + HanLp \u5b9e\u73b0\u56fe\u7247\u6587\u5b57\u5b9e\u4f53\u8bc6\u522b\uff08\u4e2d\u6587\u59d3\u540d\u3001\u673a\u6784\u540d\u3001\u5730\u57df\u540d\uff09"},"content":{"rendered":"<h2>\u4e00\u3001EasyOCR + HanLp<\/h2>\n<p><code>EasyOCR<\/code> \u662f\u4e00\u4e2a<code>python<\/code>\u7248\u7684\u6587\u5b57\u8bc6\u522b\u5de5\u5177\u3002\u76ee\u524d\u652f\u630180\u4e2d\u8bed\u8a00\u7684\u8bc6\u522b\u3002\u5e76\u4e14\u652f\u6301\uff1a\u56fe\u50cf\u9884\u5904\u7406\uff08\u53bb\u566a\u3001\u8272\u5f69\u9971\u548c\u5ea6\u3001\u5c16\u9510\u5904\u7406)\u3001CRAFT\u6587\u5b57\u68c0\u6d4b\u3001\u4e2d\u95f4\u5904\u7406\uff08\u503e\u659c\u5904\u7406\u7b49\uff09\u3001\u6587\u5b57\u8bc6\u522b\u3001\u540e\u7eed\u5904\u7406\u3001\u8f93\u51fa\u7ed3\u679c\u3002\u6846\u67b6\u5982\u4e0b\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135659709.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p><code>HanLP<\/code> \u662f\u4e00\u7cfb\u5217\u6a21\u578b\u4e0e\u7b97\u6cd5\u7ec4\u6210\u7684<code>NLP<\/code>\u5de5\u5177\u5305\uff0c\u76ee\u6807\u662f\u666e\u53ca\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u5e94\u7528\u3002<code>HanLP<\/code>\u5177\u5907\u529f\u80fd\u5b8c\u5584\u3001\u6027\u80fd\u9ad8\u6548\u3001\u67b6\u6784\u6e05\u6670\u3001\u8bed\u6599\u65f6\u65b0\u3001\u53ef\u81ea\u5b9a\u4e49\u7684\u7279\u70b9\u3002\u5185\u90e8\u7b97\u6cd5\u7ecf\u8fc7\u5de5\u4e1a\u754c\u548c\u5b66\u672f\u754c\u8003\u9a8c\uff0c\u914d\u5957\u4e66\u7c4d\u300a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5165\u95e8\u300b\u5df2\u7ecf\u51fa\u7248\u3002\u76ee\u524d\uff0c\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684<code>HanLP 2.x<\/code>\u5df2\u6b63\u5f0f\u53d1\u5e03\uff0c\u6b21\u4e16\u4ee3\u6700\u5148\u8fdb\u7684<code>NLP<\/code>\u6280\u672f\uff0c\u652f\u6301\u5305\u62ec\u7b80\u7e41\u4e2d\u82f1\u65e5\u4fc4\u6cd5\u5fb7\u5728\u5185\u7684<code>104<\/code>\u79cd\u8bed\u8a00\u4e0a\u7684\u8054\u5408\u4efb\u52a1\u3002<\/p>\n<p>\u4e0b\u9762\u91c7\u7528 <code>EasyOCR<\/code> \u63d0\u53d6\u51fa\u6587\u672c\u4e2d\u7684\u6587\u5b57\uff0c\u5229\u7528 <code>HanLP<\/code> \u5206\u6790\u51fa\u6587\u672c\u4e2d\u7684 \u4e2d\u6587\u59d3\u540d\u3001\u673a\u6784\u540d\u3001\u5730\u57df\u540d \u7b49\u4fe1\u606f\u3002<\/p>\n<h2>\u4e8c\u3001\u73af\u5883\u51c6\u5907<\/h2>\n<p><code>python<\/code>\u73af\u5883\uff1a3.6<\/p>\n<h3>\u5b89\u88c5 <code>EasyOCR<\/code> \uff1a<\/h3>\n<pre><code>pip install easyocr<\/code><\/pre>\n<p>\u5b89\u88c5\u597d\u4f9d\u8d56\uff0c\u6267\u884c\u68c0\u6d4b\u5982\u679c\u6a21\u578b\u4e0d\u5b58\u5728\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u6a21\u578b\uff0c\u4e0d\u8fc7\u4e0b\u8f7d\u65f6\u95f4\u5f88\u957f\u5bb9\u6613\u5931\u8d25\uff0c\u53ef\u4ee5\u53bb\u5b98\u65b9\u7f51\u7ad9\u4e2d\u4e0b\u8f7d\u6587\u672c\u68c0\u6d4b\u6a21\u578b\u548c\u6587\u672c\u5206\u6790\u6a21\u578b\uff1a<\/p>\n<blockquote>\n<p><a href=\"https:\/\/www.jaided.ai\/easyocr\/modelhub\/\">https:\/\/www.jaided.ai\/easyocr\/modelhub\/<\/a><\/p>\n<\/blockquote>\n<p>\u4e0b\u8f7d\u6587\u672c\u8bc6\u522b\u6a21\u578b\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135659841.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u4e0b\u8f7d\u6587\u672c\u68c0\u6d4b\u6a21\u578b\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135659935.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u4e0b\u8f7d\u540e\u89e3\u538b\u653e\u5230\u9879\u76ee\u7684 <code>model<\/code> \u76ee\u5f55\u4e0b\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135700032.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<h3>\u5b89\u88c5 HanLp<\/h3>\n<pre><code>pip install pyhanlp<\/code><\/pre>\n<p><code>HanLp<\/code> \u7684\u6a21\u578b\u5982\u679c\u4e0d\u5b58\u5728\u4e5f\u4f1a\u81ea\u52a8\u4e0b\u8f7d\uff0c\u8fd9\u4e2a\u4e0b\u8f7d\u901f\u5ea6\u8f83\u5feb\u3002<\/p>\n<h2>\u4e09\u3001\u56fe\u7247\u6587\u5b57\u5b9e\u4f53\u8bc6\u522b<\/h2>\n<p>\u4e0b\u9762\u662f\u6211\u51c6\u5907\u7684\u56fe\u7247\uff0c\u5176\u4e2d\u59d3\u540d\u3001\u673a\u6784\u540d\u3001\u5730\u57df\u540d\uff0c\u8fd8\u6709\u4e00\u4e9b\u5e72\u6270\u6587\u5b57<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640.jpeg\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u7f16\u5199\u8bc6\u522b\u7a0b\u5e8f\uff1a<\/p>\n<pre><code>import easyocr\nfrom pyhanlp import HanLP\nfrom PIL import Image, ImageDraw\n\ndef recognize():\n    # \u52a0\u8f7d easyocr \u6a21\u578b\uff0c\u5e76\u5236\u5b9a\u8bed\u79cd\n    reader = easyocr.Reader([&#039;ch_sim&#039;, &#039;en&#039;], model_storage_directory=&#039;model&#039;)\n    # \u56fe\u7247\u4f4d\u7f6e\n    imgPath = &#039;img\/1.jpeg&#039;\n    # \u8bc6\u522b\u56fe\u7247\u4e2d\u7684\u6587\u5b57\n    result = reader.readtext(imgPath, detail=1)\n    # \u4f7f\u7528 PIL \u8bfb\u53d6\u56fe\u7247,\u753b\u51fa\u8bc6\u522b\u6846\n    image  = Image.open(imgPath)\n    # \u5bf9\u56fe\u7247\u7ed8\u56fe\n    draw = ImageDraw.Draw(image)\n    # \u5b58\u653e\u8bc6\u522b\u51fa\u6240\u6709\u6587\u5b57,\u8fdb\u884cNLP\u89e3\u6790\n    text = &#039;&#039;\n    for item in result:\n        text += item[1]+&#039; &#039;\n        # \u753b\u77e9\u5f62\u6846\n        draw.rectangle((tuple(item[0][0]), tuple(item[0][2])), fill=None, outline=(255, 0, 0), width=2)\n        print(&quot;\u63d0\u53d6\u5230\u6587\u5b57\u5757\uff1a&quot;,item)\n    print(&quot;==================================================&quot;)\n    print(&quot;\u8bc6\u522b\u6587\u5b57\u6587\u672c: &quot;,text)\n    # \u521b\u5efa\u5206\u8bcd\u5668\n    segment = HanLP.newSegment().enableNameRecognize(True).enableOrganizationRecognize(True).enablePlaceRecognize(True)\n    # \u63d0\u53d6\u5b9e\u4f53\n    cut_word = segment.seg(text)\n    print(cut_word)\n    # \u5b58\u653e\u4eba\u540d\n    name = []\n    organization = []\n    place = []\n    for item in cut_word:\n        word = item.word\n        nature = item.nature.toString()\n        if nature == &#039;nr&#039;:\n            name.append(word)\n        elif nature == &#039;ns&#039;:\n            place.append(word)\n        elif nature == &#039;nt&#039;:\n            organization.append(word)\n\n    print(&quot;\u8bc6\u522b\u4e2d\u6587\u59d3\u540d\uff1a&quot;,name)\n    print(&quot;\u8bc6\u522b\u673a\u6784\u540d\uff1a&quot;,organization)\n    print(&quot;\u8bc6\u522b\u5730\u57df\u540d\uff1a&quot;,place)\n    image.show()\n\nif __name__ == &#039;__main__&#039;:\n    recognize()<\/code><\/pre>\n<p>\u8fd0\u884c\u7a0b\u5e8f\uff0c\u5982\u679c\u6ca1\u6709 HanLP \uff0c\u5219\u81ea\u52a8\u4e0b\u8f7d\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135700322.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u8bc6\u522b\u6587\u5b57\u60c5\u51b5\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135700640.png\" alt=\"\u56fe\u7247\" \/>\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u6587\u5b57\u90fd\u88ab\u6355\u6349\u5230\u4e86\uff0c\u4e0b\u9762\u770b\u8bcd\u8bed\u5206\u6790\u6548\u679c\uff1a<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/640-20251107135700753.png\" alt=\"\u56fe\u7247\" \/><\/p>\n<p>\u5df2\u6210\u529f\u63d0\u53d6\u76f8\u5173\u5b9e\u4f53\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001EasyOCR + HanLp EasyOCR \u662f\u4e00\u4e2apython\u7248\u7684\u6587\u5b57\u8bc6\u522b\u5de5\u5177\u3002\u76ee\u524d\u652f\u630180\u4e2d\u8bed\u8a00\u7684\u8bc6\u522b\u3002\u5e76\u4e14\u652f\u6301\uff1a\u56fe\u50cf\u9884\u5904\u7406\uff08   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[225],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9465"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9465"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9465\/revisions"}],"predecessor-version":[{"id":9466,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9465\/revisions\/9466"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9465"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}