{"id":15020,"date":"2024-09-09T14:42:53","date_gmt":"2024-09-09T06:42:53","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=15020"},"modified":"2024-12-09T14:49:19","modified_gmt":"2024-12-09T06:49:19","slug":"paddleocr","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/de\/paddleocr\/","title":{"rendered":"PaddleOCR\uff1a\u57fa\u4e8e\u98de\u6868\u7684\u591a\u8bed\u8a00OCR\u5de5\u5177\u5e93\uff0c\u652f\u630180\u591a\u79cd\u8bed\u8a00\u8bc6\u522b"},"content":{"rendered":"<p>PaddleOCR \u662f\u4e00\u4e2a\u57fa\u4e8e PaddlePaddle \u7684\u591a\u8bed\u8a00 OCR \u5de5\u5177\u5305\uff0c\u65e8\u5728\u63d0\u4f9b\u5b9e\u7528\u4e14\u8d85\u8f7b\u91cf\u7ea7\u7684 OCR \u7cfb\u7edf\u3002\u5b83\u652f\u6301\u8d85\u8fc7 80 \u79cd\u8bed\u8a00\u7684\u8bc6\u522b\uff0c\u5e76\u63d0\u4f9b\u6570\u636e\u6807\u6ce8\u548c\u5408\u6210\u5de5\u5177\uff0c\u652f\u6301\u5728\u670d\u52a1\u5668\u3001\u79fb\u52a8\u8bbe\u5907\u3001\u5d4c\u5165\u5f0f\u548c\u7269\u8054\u7f51\u8bbe\u5907\u4e0a\u8fdb\u884c\u8bad\u7ec3\u548c\u90e8\u7f72\u3002PaddleOCR \u96c6\u6210\u4e86\u6587\u672c\u56fe\u50cf\u77eb\u6b63\u3001\u7248\u9762\u533a\u57df\u68c0\u6d4b\u3001\u5e38\u89c4\u6587\u672c\u68c0\u6d4b\u3001\u5370\u7ae0\u6587\u672c\u68c0\u6d4b\u3001\u6587\u672c\u8bc6\u522b\u3001\u8868\u683c\u8bc6\u522b\u7b49\u591a\u79cd\u529f\u80fd\uff0c\u663e\u8457\u964d\u4f4e\u4e86\u5f00\u53d1\u6210\u672c\uff0c\u5e76\u652f\u6301\u9ad8\u6027\u80fd\u63a8\u7406\u3001\u670d\u52a1\u5316\u90e8\u7f72\u548c\u7aef\u4fa7\u90e8\u7f72\u7b49\u591a\u79cd\u65b9\u5f0f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>\u591a\u8bed\u8a00\u8bc6\u522b<\/strong>\uff1a\u652f\u6301\u8d85\u8fc7 80 \u79cd\u8bed\u8a00\u7684\u6587\u672c\u8bc6\u522b\u3002<\/li>\n<li><strong>\u6570\u636e\u6807\u6ce8\u548c\u5408\u6210\u5de5\u5177<\/strong>\uff1a\u63d0\u4f9b\u4fbf\u6377\u7684\u6570\u636e\u6807\u6ce8\u548c\u5408\u6210\u5de5\u5177\uff0c\u5e2e\u52a9\u5feb\u901f\u751f\u6210\u8bad\u7ec3\u6570\u636e\u3002<\/li>\n<li><strong>\u6587\u672c\u56fe\u50cf\u77eb\u6b63<\/strong>\uff1a\u96c6\u6210\u6587\u672c\u56fe\u50cf\u77eb\u6b63\u529f\u80fd\uff0c\u63d0\u9ad8\u8bc6\u522b\u51c6\u786e\u6027\u3002<\/li>\n<li><strong>\u7248\u9762\u533a\u57df\u68c0\u6d4b<\/strong>\uff1a\u652f\u6301\u9ad8\u7cbe\u5ea6\u7248\u9762\u533a\u57df\u68c0\u6d4b\uff0c\u9002\u7528\u4e8e\u590d\u6742\u6587\u6863\u7684\u89e3\u6790\u3002<\/li>\n<li><strong>\u8868\u683c\u8bc6\u522b<\/strong>\uff1a\u63d0\u4f9b\u8868\u683c\u8bc6\u522b\u529f\u80fd\uff0c\u80fd\u591f\u51c6\u786e\u63d0\u53d6\u8868\u683c\u6570\u636e\u3002<\/li>\n<li><strong>\u5370\u7ae0\u6587\u672c\u68c0\u6d4b<\/strong>\uff1a\u652f\u6301\u5370\u7ae0\u6587\u672c\u7684\u68c0\u6d4b\u548c\u8bc6\u522b\u3002<\/li>\n<li><strong>\u9ad8\u6027\u80fd\u63a8\u7406<\/strong>\uff1a\u652f\u6301\u9ad8\u6027\u80fd\u63a8\u7406\uff0c\u6ee1\u8db3\u5b9e\u65f6\u5e94\u7528\u9700\u6c42\u3002<\/li>\n<li><strong>\u591a\u79cd\u90e8\u7f72\u65b9\u5f0f<\/strong>\uff1a\u652f\u6301\u670d\u52a1\u5668\u3001\u79fb\u52a8\u8bbe\u5907\u3001\u5d4c\u5165\u5f0f\u548c\u7269\u8054\u7f51\u8bbe\u5907\u7684\u90e8\u7f72\u3002<\/li>\n<li><strong>\u4f4e\u4ee3\u7801\u5f00\u53d1<\/strong>\uff1a\u63d0\u4f9b\u4f4e\u4ee3\u7801\u5168\u6d41\u7a0b\u5f00\u53d1\u5de5\u5177\uff0c\u964d\u4f4e\u5f00\u53d1\u95e8\u69db\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u73af\u5883\u51c6\u5907<\/strong>\uff1a\n<ul>\n<li>\u786e\u4fdd\u5df2\u5b89\u88c5 Python 3.6 \u6216\u4ee5\u4e0a\u7248\u672c\u3002<\/li>\n<li>\u5b89\u88c5 PaddlePaddle \u6846\u67b6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/li>\n<\/ul>\n<pre><code> pip install paddlepaddle\r\n<\/code><\/pre>\n<ul>\n<li>\u5b89\u88c5 PaddleOCR\uff1a<\/li>\n<\/ul>\n<pre><code> pip install paddleocr\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u4e0b\u8f7d\u6a21\u578b<\/strong>\uff1a\n<ul>\n<li>\u4ece\u5b98\u65b9\u4ed3\u5e93\u4e0b\u8f7d\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u5177\u4f53\u4e0b\u8f7d\u94fe\u63a5\u548c\u547d\u4ee4\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u6587\u6863\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8fd0\u884c\u793a\u4f8b<\/strong>\uff1a\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c OCR \u793a\u4f8b\uff1a <code>bash<br \/>\npaddleocr --image_dir .\/doc\/imgs\/11.jpg --det_model_dir .\/inference\/ch_ppocr_mobile_v2.0_det_infer --rec_model_dir .\/inference\/ch_ppocr_mobile_v2.0_rec_infer --cls_model_dir .\/inference\/ch_ppocr_mobile_v2.0_cls_infer<br \/>\n<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u529f\u80fd\u64cd\u4f5c\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u6587\u672c\u8bc6\u522b<\/strong>\uff1a\n<ul>\n<li>\u51c6\u5907\u5f85\u8bc6\u522b\u7684\u56fe\u50cf\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528 <code>paddleocr<\/code> \u547d\u4ee4\u884c\u5de5\u5177\u6216 Python API \u8fdb\u884c\u8bc6\u522b\u3002<\/li>\n<li>\u793a\u4f8b\u4ee3\u7801\uff1a<\/li>\n<\/ul>\n<pre><code> from paddleocr import PaddleOCR, draw_ocr\r\nimport matplotlib.pyplot as plt\r\nimport cv2\r\nocr = PaddleOCR(use_angle_cls=True, lang='ch')\r\nimg_path = 'path\/to\/your\/image.jpg'\r\nresult = ocr.ocr(img_path, cls=True)\r\nfor line in result:\r\nprint(line)\r\n# \u53ef\u89c6\u5316\u7ed3\u679c\r\nimage = cv2.imread(img_path)\r\nboxes = [elements[0] for elements in result]\r\ntxts = [elements[1][0] for elements in result]\r\nscores = [elements[1][1] for elements in result]\r\nim_show = draw_ocr(image, boxes, txts, scores, font_path='path\/to\/your\/font.ttf')\r\nim_show = cv2.cvtColor(im_show, cv2.COLOR_BGR2RGB)\r\nplt.imshow(im_show)\r\nplt.show()\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u8868\u683c\u8bc6\u522b<\/strong>\uff1a\n<ul>\n<li>\u51c6\u5907\u5305\u542b\u8868\u683c\u7684\u56fe\u50cf\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528 <code>paddleocr<\/code> \u547d\u4ee4\u884c\u5de5\u5177\u6216 Python API \u8fdb\u884c\u8868\u683c\u8bc6\u522b\u3002<\/li>\n<li>\u793a\u4f8b\u4ee3\u7801\uff1a<\/li>\n<\/ul>\n<pre><code> from paddleocr import PPStructure, draw_structure_result\r\nimport cv2\r\ntable_engine = PPStructure(show_log=True)\r\nimg_path = 'path\/to\/your\/table_image.jpg'\r\nresult = table_engine(img_path)\r\nfor line in result:\r\nprint(line)\r\n# \u53ef\u89c6\u5316\u7ed3\u679c\r\nimage = cv2.imread(img_path)\r\nim_show = draw_structure_result(image, result, font_path='path\/to\/your\/font.ttf')\r\nim_show = cv2.cvtColor(im_show, cv2.COLOR_BGR2RGB)\r\nplt.imshow(im_show)\r\nplt.show()\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u7248\u9762\u533a\u57df\u68c0\u6d4b<\/strong>\uff1a\n<ul>\n<li>\u51c6\u5907\u5305\u542b\u590d\u6742\u7248\u9762\u7684\u56fe\u50cf\u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528 <code>paddleocr<\/code> \u547d\u4ee4\u884c\u5de5\u5177\u6216 Python API \u8fdb\u884c\u7248\u9762\u533a\u57df\u68c0\u6d4b\u3002<\/li>\n<li>\u793a\u4f8b\u4ee3\u7801\uff1a<\/li>\n<\/ul>\n<pre><code> from paddleocr import PaddleOCR, draw_ocr\r\nimport matplotlib.pyplot as plt\r\nimport cv2\r\nocr = PaddleOCR(use_angle_cls=True, lang='ch')\r\nimg_path = 'path\/to\/your\/layout_image.jpg'\r\nresult = ocr.ocr(img_path, cls=True)\r\nfor line in result:\r\nprint(line)\r\n# \u53ef\u89c6\u5316\u7ed3\u679c\r\nimage = cv2.imread(img_path)\r\nboxes = [elements[0] for elements in result]\r\ntxts = [elements[1][0] for elements in result]\r\nscores = [elements[1][1] for elements in result]\r\nim_show = draw_ocr(image, boxes, txts, scores, font_path='path\/to\/your\/font.ttf')\r\nim_show = cv2.cvtColor(im_show, cv2.COLOR_BGR2RGB)\r\nplt.imshow(im_show)\r\nplt.show()\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>PaddleOCR \u662f\u4e00\u4e2a\u57fa\u4e8e PaddlePaddle \u7684\u591a\u8bed\u8a00 OCR \u5de5\u5177\u5305\uff0c\u65e8\u5728\u63d0\u4f9b\u5b9e\u7528\u4e14\u8d85\u8f7b\u91cf\u7ea7\u7684 OCR \u7cfb\u7edf\u3002\u5b83\u652f\u6301\u8d85\u8fc7 80 \u79cd\u8bed\u8a00\u7684\u8bc6\u522b\uff0c\u5e76\u63d0\u4f9b\u6570\u636e\u6807\u6ce8\u548c\u5408\u6210\u5de5\u5177\uff0c\u652f\u6301\u5728\u670d\u52a1\u5668\u3001\u79fb\u52a8\u8bbe\u5907\u3001\u5d4c\u5165\u5f0f\u548c\u7269\u8054\u7f51\u8bbe\u5907\u4e0a\u8fdb\u884c\u8bad\u7ec3\u548c\u90e8\u7f72&#8230;<\/p>\n","protected":false},"author":1,"featured_media":60980,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,248],"class_list":["post-15020","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-ocr"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/15020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/comments?post=15020"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/posts\/15020\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media\/60980"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/media?parent=15020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/categories?post=15020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/de\/wp-json\/wp\/v2\/tags?post=15020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}