{"id":980235,"date":"2024-12-27T06:52:53","date_gmt":"2024-12-26T22:52:53","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/980235.html"},"modified":"2024-12-27T06:52:55","modified_gmt":"2024-12-26T22:52:55","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e5%bc%80%e5%8f%91ocr","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/980235.html","title":{"rendered":"\u5982\u4f55\u7528Python\u5f00\u53d1ocr"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205714\/22b0a779-2553-4d9e-b6a5-6e4d6a22eedb.webp\" alt=\"\u5982\u4f55\u7528Python\u5f00\u53d1ocr\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Python\u5f00\u53d1OCR\u7684\u4e3b\u8981\u6b65\u9aa4\u5305\u62ec\uff1a\u9009\u62e9OCR\u5e93\u3001\u51c6\u5907\u56fe\u50cf\u6570\u636e\u3001\u56fe\u50cf\u9884\u5904\u7406\u3001\u4f7f\u7528OCR\u8fdb\u884c\u6587\u672c\u8bc6\u522b\u3001\u7ed3\u679c\u540e\u5904\u7406\u3002\u63a8\u8350\u4f7f\u7528Tesseract\u4f5c\u4e3aOCR\u5f15\u64ce\uff0c\u5e76\u7ed3\u5408OpenCV\u8fdb\u884c\u56fe\u50cf\u9884\u5904\u7406\u3002<\/strong><\/p>\n<\/p>\n<p><p>OCR\uff08Optical Character Recognition\uff0c\u5149\u5b66\u5b57\u7b26\u8bc6\u522b\uff09\u6280\u672f\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5c06\u56fe\u50cf\u4e2d\u7684\u6587\u5b57\u8f6c\u6362\u4e3a\u53ef\u7f16\u8f91\u6587\u672c\u3002\u5728Python\u4e2d\uff0c\u5f00\u53d1OCR\u5e94\u7528\u7a0b\u5e8f\u76f8\u5bf9\u7b80\u5355\uff0c\u56e0\u4e3a\u6709\u8bb8\u591a\u5f3a\u5927\u7684\u5e93\u53ef\u4ee5\u4f7f\u7528\uff0c\u5982Tesseract\u3001OpenCV\u3001Pillow\u7b49\u3002\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u56fe\u50cf\u7684\u9884\u5904\u7406\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u9ad8\u8d28\u91cf\u7684\u56fe\u50cf\u80fd\u6781\u5927\u63d0\u9ad8\u8bc6\u522b\u7684\u51c6\u786e\u6027\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u5f00\u53d1OCR\u7cfb\u7edf\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u9009\u62e9OCR\u5e93<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1OCR\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684OCR\u5e93\u662f\u7b2c\u4e00\u6b65\u3002\u76ee\u524d\uff0c\u6700\u5e38\u7528\u7684OCR\u5e93\u662fTesseract\uff0c\u5b83\u662f\u4e00\u4e2a\u5f00\u6e90\u7684OCR\u5f15\u64ce\uff0c\u652f\u6301\u591a\u79cd\u8bed\u8a00\uff0c\u5e76\u4e14\u53ef\u4ee5\u4e0ePython\u96c6\u6210\u4f7f\u7528\u3002Tesseract\u7684\u6027\u80fd\u548c\u51c6\u786e\u6027\u5728\u5f00\u6e90OCR\u5f15\u64ce\u4e2d\u540d\u5217\u524d\u8305\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Tesseract\u4ecb\u7ecd<\/strong><\/p>\n<\/p>\n<p><p>Tesseract\u662fGoogle\u7ef4\u62a4\u7684\u4e00\u4e2a\u5f00\u6e90OCR\u5f15\u64ce\uff0c\u652f\u6301\u591a\u79cd\u8bed\u8a00\u548c\u5b57\u7b26\u96c6\u3002\u5b83\u53ef\u4ee5\u4ece\u56fe\u50cf\u4e2d\u63d0\u53d6\u6587\u672c\uff0c\u5e76\u4e14\u5728\u5904\u7406\u5370\u5237\u6587\u672c\u65f6\u975e\u5e38\u6709\u6548\u3002Tesseract\u9700\u8981\u8bad\u7ec3\u6570\u636e\u6765\u8bc6\u522b\u4e0d\u540c\u7684\u5b57\u7b26\u96c6\uff0c\u901a\u5e38\u8fd9\u4e9b\u6570\u636e\u5df2\u7ecf\u5305\u542b\u5728Tesseract\u7684\u5b89\u88c5\u5305\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Python-tesseract<\/strong><\/p>\n<\/p>\n<p><p>Python-tesseract\u662f\u4e00\u4e2aPython\u5305\u88c5\u5668\uff0c\u7528\u4e8e\u4e0eTesseract\u5f15\u64ce\u4ea4\u4e92\u3002\u5b83\u5141\u8bb8Python\u7a0b\u5e8f\u8c03\u7528Tesseract\u7684\u529f\u80fd\uff0c\u4ece\u800c\u5b9e\u73b0\u56fe\u50cf\u5230\u6587\u672c\u7684\u8f6c\u6362\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u5b89\u88c5Tesseract\u548cPython-tesseract\u76f8\u5bf9\u7b80\u5355\u3002\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\uff0c\u800c\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u9700\u8981\u4e0b\u8f7d\u5e76\u5b89\u88c5\u76f8\u5e94\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u786e\u4fddTesseract\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\"># \u5728Linux\u7cfb\u7edf\u4e0a\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5tesseract<\/p>\n<p>sudo apt-get install tesseract-ocr<\/p>\n<h2><strong>\u5b89\u88c5python-tesseract\u5e93<\/strong><\/h2>\n<p>pip install pytesseract<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u51c6\u5907\u56fe\u50cf\u6570\u636e<\/p>\n<\/p>\n<p><p>\u5728\u8fdb\u884cOCR\u5904\u7406\u4e4b\u524d\uff0c\u51c6\u5907\u597d\u5f85\u5904\u7406\u7684\u56fe\u50cf\u6570\u636e\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u56fe\u50cf\u53ef\u4ee5\u6765\u6e90\u4e8e\u626b\u63cf\u6587\u4ef6\u3001\u62cd\u6444\u7684\u7167\u7247\u6216\u5176\u4ed6\u6570\u5b57\u5316\u6587\u6863\u3002\u5728\u9009\u62e9\u56fe\u50cf\u65f6\uff0c\u5c3d\u91cf\u9009\u62e9\u6e05\u6670\u3001\u5bf9\u6bd4\u5ea6\u9ad8\u7684\u56fe\u50cf\uff0c\u4ee5\u4fbf\u4e8e\u540e\u7eed\u7684OCR\u5904\u7406\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u56fe\u50cf\u683c\u5f0f<\/strong><\/p>\n<\/p>\n<p><p>Tesseract\u652f\u6301\u591a\u79cd\u56fe\u50cf\u683c\u5f0f\uff0c\u5305\u62ecJPEG\u3001PNG\u3001TIFF\u7b49\u3002\u5728\u9009\u62e9\u56fe\u50cf\u683c\u5f0f\u65f6\uff0c\u5efa\u8bae\u4f7f\u7528\u65e0\u635f\u538b\u7f29\u7684PNG\u6216TIFF\u683c\u5f0f\uff0c\u4ee5\u4fdd\u7559\u5c3d\u53ef\u80fd\u591a\u7684\u56fe\u50cf\u7ec6\u8282\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u56fe\u50cf\u5206\u8fa8\u7387<\/strong><\/p>\n<\/p>\n<p><p>\u56fe\u50cf\u7684\u5206\u8fa8\u7387\u5bf9\u4e8eOCR\u7684\u51c6\u786e\u6027\u6709\u5f88\u5927\u5f71\u54cd\u3002\u901a\u5e38\uff0c\u5efa\u8bae\u4f7f\u7528300 DPI\uff08\u6bcf\u82f1\u5bf8\u70b9\u6570\uff09\u6216\u66f4\u9ad8\u5206\u8fa8\u7387\u7684\u56fe\u50cf\uff0c\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u8bc6\u522b\u6548\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u56fe\u50cf\u9884\u5904\u7406<\/p>\n<\/p>\n<p><p>\u5728\u8fdb\u884cOCR\u4e4b\u524d\uff0c\u5bf9\u56fe\u50cf\u8fdb\u884c\u9884\u5904\u7406\u662f\u4e00\u4e2a\u5173\u952e\u6b65\u9aa4\uff0c\u56e0\u4e3a\u5b83\u80fd\u663e\u8457\u63d0\u9ad8OCR\u7684\u51c6\u786e\u6027\u3002\u5e38\u7528\u7684\u56fe\u50cf\u9884\u5904\u7406\u6280\u672f\u5305\u62ec\u7070\u5ea6\u5316\u3001\u4e8c\u503c\u5316\u3001\u53bb\u566a\u3001\u65cb\u8f6c\u6821\u6b63\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7070\u5ea6\u5316<\/strong><\/p>\n<\/p>\n<p><p>\u7070\u5ea6\u5316\u662f\u5c06\u5f69\u8272\u56fe\u50cf\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf\u7684\u8fc7\u7a0b\u3002\u5b83\u80fd\u51cf\u5c11\u56fe\u50cf\u7684\u590d\u6742\u5ea6\uff0c\u5e76\u52a0\u5feb\u540e\u7eed\u5904\u7406\u901f\u5ea6\u3002\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528OpenCV\u5e93\u8f7b\u677e\u5b9e\u73b0\u7070\u5ea6\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u8bfb\u53d6\u56fe\u50cf<\/strong><\/h2>\n<p>image = cv2.imread(&#39;image.png&#39;)<\/p>\n<h2><strong>\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf<\/strong><\/h2>\n<p>gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e8c\u503c\u5316<\/strong><\/p>\n<\/p>\n<p><p>\u4e8c\u503c\u5316\u662f\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a\u9ed1\u767d\u56fe\u50cf\u7684\u8fc7\u7a0b\u3002\u5728OCR\u5904\u7406\u4e2d\uff0c\u4e8c\u503c\u5316\u53ef\u4ee5\u589e\u5f3a\u6587\u672c\u4e0e\u80cc\u666f\u7684\u5bf9\u6bd4\u5ea6\uff0c\u4f7f\u6587\u672c\u66f4\u52a0\u7a81\u51fa\u3002\u5e38\u7528\u7684\u4e8c\u503c\u5316\u65b9\u6cd5\u662fOtsu&#39;s\u65b9\u6cd5\uff0c\u5b83\u80fd\u81ea\u52a8\u786e\u5b9a\u56fe\u50cf\u7684\u9608\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528Otsu&#39;s\u65b9\u6cd5\u8fdb\u884c\u4e8c\u503c\u5316<\/p>\n<p>_, binary_image = cv2.threshold(gray_image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u53bb\u566a<\/strong><\/p>\n<\/p>\n<p><p>\u53bb\u566a\u662f\u6d88\u9664\u56fe\u50cf\u4e2d\u7684\u566a\u58f0\uff0c\u4ee5\u63d0\u9ad8\u56fe\u50cf\u8d28\u91cf\u7684\u8fc7\u7a0b\u3002\u5728\u5904\u7406\u542b\u6709\u566a\u58f0\u7684\u56fe\u50cf\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e2d\u503c\u6ee4\u6ce2\u6216\u9ad8\u65af\u6ee4\u6ce2\u8fdb\u884c\u53bb\u566a\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u4e2d\u503c\u6ee4\u6ce2\u53bb\u566a<\/p>\n<p>denoised_image = cv2.medianBlur(binary_image, 5)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u65cb\u8f6c\u6821\u6b63<\/strong><\/p>\n<\/p>\n<p><p>\u65cb\u8f6c\u6821\u6b63\u662f\u5bf9\u503e\u659c\u7684\u56fe\u50cf\u8fdb\u884c\u8c03\u6574\uff0c\u4f7f\u6587\u672c\u6c34\u5e73\u6392\u5217\u7684\u8fc7\u7a0b\u3002\u53ef\u4ee5\u4f7f\u7528Hough\u53d8\u6362\u68c0\u6d4b\u56fe\u50cf\u4e2d\u7684\u76f4\u7ebf\uff0c\u5e76\u8ba1\u7b97\u51fa\u65cb\u8f6c\u89d2\u5ea6\uff0c\u7136\u540e\u4f7f\u7528\u4eff\u5c04\u53d8\u6362\u8fdb\u884c\u6821\u6b63\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528Hough\u53d8\u6362\u68c0\u6d4b\u76f4\u7ebf\u5e76\u8ba1\u7b97\u65cb\u8f6c\u89d2\u5ea6<\/p>\n<h2><strong>\u4ee3\u7801\u7565<\/strong><\/h2>\n<h2><strong>\u4f7f\u7528\u4eff\u5c04\u53d8\u6362\u8fdb\u884c\u65cb\u8f6c\u6821\u6b63<\/strong><\/h2>\n<h2><strong>\u4ee3\u7801\u7565<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u4f7f\u7528OCR\u8fdb\u884c\u6587\u672c\u8bc6\u522b<\/p>\n<\/p>\n<p><p>\u5728\u5b8c\u6210\u56fe\u50cf\u9884\u5904\u7406\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Tesseract\u8fdb\u884c\u6587\u672c\u8bc6\u522b\u3002Python-tesseract\u5e93\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u56fe\u50cf\u4f20\u9012\u7ed9Tesseract\u8fdb\u884c\u8bc6\u522b\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u57fa\u672c\u4f7f\u7528<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python-tesseract\u8fdb\u884c\u6587\u672c\u8bc6\u522b\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u4f20\u5165\u9884\u5904\u7406\u540e\u7684\u56fe\u50cf\u5373\u53ef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pytesseract<\/p>\n<h2><strong>\u8bbe\u7f6eTesseract\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\uff08\u4ec5\u5728Windows\u7cfb\u7edf\u4e0a\u9700\u8981\uff09<\/strong><\/h2>\n<p>pytesseract.pytesseract.tesseract_cmd = r&#39;C:\\Program Files\\Tesseract-OCR\\tesseract.exe&#39;<\/p>\n<h2><strong>\u4f7f\u7528Tesseract\u8bc6\u522b\u56fe\u50cf\u4e2d\u7684\u6587\u672c<\/strong><\/h2>\n<p>recognized_text = pytesseract.image_to_string(denoised_image, lang=&#39;eng&#39;)<\/p>\n<p>print(recognized_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bed\u8a00\u9009\u62e9<\/strong><\/p>\n<\/p>\n<p><p>Tesseract\u652f\u6301\u591a\u79cd\u8bed\u8a00\uff0c\u53ef\u4ee5\u901a\u8fc7<code>lang<\/code>\u53c2\u6570\u6307\u5b9a\u9700\u8981\u8bc6\u522b\u7684\u8bed\u8a00\u3002\u4f8b\u5982\uff0c\u8bc6\u522b\u4e2d\u6587\u6587\u672c\u65f6\uff0c\u53ef\u4ee5\u8bbe\u7f6e<code>lang=&#39;chi_sim&#39;<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u53c2\u6570<\/strong><\/p>\n<\/p>\n<p><p>Tesseract\u63d0\u4f9b\u4e86\u4e00\u4e9b\u914d\u7f6e\u53c2\u6570\uff0c\u53ef\u4ee5\u8c03\u6574\u8bc6\u522b\u8fc7\u7a0b\u4e2d\u7684\u7ec6\u8282\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u5b57\u7b26\u95f4\u8ddd\u3001\u8bbe\u7f6e\u8bc6\u522b\u6a21\u5f0f\u7b49\u6765\u63d0\u9ad8\u8bc6\u522b\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u7ed3\u679c\u540e\u5904\u7406<\/p>\n<\/p>\n<p><p>\u5728\u5b8c\u6210OCR\u8bc6\u522b\u540e\uff0c\u901a\u5e38\u9700\u8981\u5bf9\u8bc6\u522b\u7ed3\u679c\u8fdb\u884c\u540e\u5904\u7406\uff0c\u4ee5\u63d0\u9ad8\u6587\u672c\u7684\u53ef\u8bfb\u6027\u548c\u51c6\u786e\u6027\u3002\u540e\u5904\u7406\u7684\u6b65\u9aa4\u53ef\u80fd\u5305\u62ec\u53bb\u9664\u591a\u4f59\u7a7a\u683c\u3001\u7ea0\u6b63\u62fc\u5199\u9519\u8bef\u3001\u683c\u5f0f\u5316\u6587\u672c\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u53bb\u9664\u591a\u4f59\u7a7a\u683c<\/strong><\/p>\n<\/p>\n<p><p>\u5728OCR\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u4ea7\u751f\u591a\u4f59\u7684\u7a7a\u683c\u3002\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6216\u5b57\u7b26\u4e32\u5904\u7406\u51fd\u6570\u6765\u53bb\u9664\u8fd9\u4e9b\u7a7a\u683c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<h2><strong>\u53bb\u9664\u591a\u4f59\u7a7a\u683c<\/strong><\/h2>\n<p>cleaned_text = re.sub(r&#39;\\s+&#39;, &#39; &#39;, recognized_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u62fc\u5199\u68c0\u67e5<\/strong><\/p>\n<\/p>\n<p><p>\u62fc\u5199\u9519\u8bef\u662fOCR\u8bc6\u522b\u8fc7\u7a0b\u4e2d\u5e38\u89c1\u7684\u95ee\u9898\u4e4b\u4e00\u3002\u53ef\u4ee5\u4f7f\u7528\u62fc\u5199\u68c0\u67e5\u5e93\uff08\u5982PySpellChecker\uff09\u6765\u68c0\u6d4b\u5e76\u7ea0\u6b63\u62fc\u5199\u9519\u8bef\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from spellchecker import SpellChecker<\/p>\n<p>spell = SpellChecker()<\/p>\n<h2><strong>\u7ea0\u6b63\u62fc\u5199\u9519\u8bef<\/strong><\/h2>\n<p>corrected_text = &#39; &#39;.join([spell.correction(word) for word in cleaned_text.split()])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u683c\u5f0f\u5316\u6587\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u6839\u636e\u5e94\u7528\u573a\u666f\u7684\u4e0d\u540c\uff0c\u53ef\u80fd\u9700\u8981\u5bf9\u6587\u672c\u8fdb\u884c\u683c\u5f0f\u5316\u5904\u7406\u3002\u4f8b\u5982\uff0c\u5c06\u6587\u672c\u8f6c\u6362\u4e3aJSON\u683c\u5f0f\uff0c\u6216\u8005\u89e3\u6790\u6587\u672c\u4e2d\u7684\u7279\u5b9a\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python\u5f00\u53d1OCR\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u9009\u62e9\u5408\u9002\u7684OCR\u5e93\u3001\u8fdb\u884c\u6709\u6548\u7684\u56fe\u50cf\u9884\u5904\u7406\u3001\u4f7f\u7528OCR\u5f15\u64ce\u8fdb\u884c\u6587\u672c\u8bc6\u522b\uff0c\u4ee5\u53ca\u5bf9\u8bc6\u522b\u7ed3\u679c\u8fdb\u884c\u540e\u5904\u7406\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u6784\u5efa\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684OCR\u7cfb\u7edf\u3002\u65e0\u8bba\u662f\u4ece\u7eb8\u8d28\u6587\u6863\u4e2d\u63d0\u53d6\u6587\u672c\uff0c\u8fd8\u662f\u4ece\u56fe\u50cf\u4e2d\u8bc6\u522b\u4fe1\u606f\uff0cOCR\u6280\u672f\u90fd\u80fd\u63d0\u4f9b\u6781\u5927\u7684\u4fbf\u5229\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u7ed3\u5408<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u548c\u6df1\u5ea6\u5b66\u4e60\u6280\u672f\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u5347OCR\u7cfb\u7edf\u7684\u6027\u80fd\u548c\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u4ec0\u4e48\u662fOCR\uff0c\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528Python\u8fdb\u884cOCR\u5f00\u53d1\uff1f<\/strong><br \/>OCR\uff08\u5149\u5b66\u5b57\u7b26\u8bc6\u522b\uff09\u662f\u4e00\u79cd\u5c06\u4e0d\u540c\u7c7b\u578b\u7684\u6587\u6863\uff08\u5982\u626b\u63cf\u7684\u7eb8\u8d28\u6587\u6863\u3001PDF\u6587\u4ef6\u6216\u56fe\u50cf\uff09\u8f6c\u6362\u4e3a\u53ef\u7f16\u8f91\u548c\u53ef\u641c\u7d22\u7684\u6587\u672c\u7684\u6280\u672f\u3002Python\u662f\u4e00\u79cd\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u56e0\u5176\u4e30\u5bcc\u7684\u5e93\u548c\u6846\u67b6\u800c\u5e7f\u6cdb\u5e94\u7528\u4e8eOCR\u5f00\u53d1\u3002\u4f7f\u7528Python\u8fdb\u884cOCR\u5f00\u53d1\u53ef\u4ee5\u7b80\u5316\u6d41\u7a0b\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u5e76\u80fd\u591f\u5229\u7528\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u5982Pillow\u548cOpenCV\uff0c\u7ed3\u5408\u673a\u5668\u5b66\u4e60\u6846\u67b6\uff0c\u5982Tesseract\u548cEasyOCR\uff0c\u6765\u63d0\u9ad8\u8bc6\u522b\u51c6\u786e\u7387\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u8fdb\u884cOCR\u5f00\u53d1\u65f6\u9700\u8981\u54ea\u4e9b\u5e93\u6216\u5de5\u5177\uff1f<\/strong><br \/>\u5728Python\u4e2d\u5f00\u53d1OCR\u5e94\u7528\uff0c\u5e38\u7528\u7684\u5e93\u548c\u5de5\u5177\u5305\u62ec\uff1a  <\/p>\n<ul>\n<li><strong>Tesseract<\/strong>\uff1a\u4e00\u4e2a\u5f00\u6e90OCR\u5f15\u64ce\uff0c\u652f\u6301\u591a\u79cd\u8bed\u8a00\uff0c\u6613\u4e8e\u4e0ePython\u7ed3\u5408\u4f7f\u7528\u3002  <\/li>\n<li><strong>Pillow<\/strong>\uff1a\u7528\u4e8e\u56fe\u50cf\u5904\u7406\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u8fdb\u884cOCR\u4e4b\u524d\u5bf9\u56fe\u50cf\u8fdb\u884c\u9884\u5904\u7406\u3002  <\/li>\n<li><strong>OpenCV<\/strong>\uff1a\u5f3a\u5927\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u5e93\uff0c\u9002\u5408\u5904\u7406\u590d\u6742\u7684\u56fe\u50cf\u5904\u7406\u4efb\u52a1\u3002  <\/li>\n<li><strong>EasyOCR<\/strong>\uff1a\u4e00\u4e2a\u6613\u4e8e\u4f7f\u7528\u7684OCR\u5e93\uff0c\u652f\u6301\u591a\u79cd\u8bed\u8a00\uff0c\u9002\u5408\u5feb\u901f\u5f00\u53d1\u3002<br \/>\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u5e93\u53ef\u4ee5\u63d0\u5347OCR\u5e94\u7528\u7684\u6027\u80fd\u548c\u6548\u679c\u3002<\/li>\n<\/ul>\n<p><strong>\u5982\u4f55\u63d0\u9ad8OCR\u8bc6\u522b\u7684\u51c6\u786e\u6027\uff1f<\/strong><br \/>\u63d0\u9ad8OCR\u8bc6\u522b\u51c6\u786e\u6027\u7684\u65b9\u6cd5\u5305\u62ec\uff1a  <\/p>\n<ul>\n<li><strong>\u56fe\u50cf\u9884\u5904\u7406<\/strong>\uff1a\u5bf9\u56fe\u50cf\u8fdb\u884c\u53bb\u566a\u3001\u4e8c\u503c\u5316\u3001\u65cb\u8f6c\u548c\u7f29\u653e\u7b49\u9884\u5904\u7406\uff0c\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8OCR\u7684\u6548\u679c\u3002  <\/li>\n<li><strong>\u9009\u62e9\u5408\u9002\u7684OCR\u5f15\u64ce<\/strong>\uff1a\u4e0d\u540c\u7684OCR\u5de5\u5177\u5728\u5904\u7406\u7279\u5b9a\u7c7b\u578b\u7684\u6587\u672c\u65f6\u8868\u73b0\u4e0d\u540c\uff0c\u9009\u62e9\u6700\u9002\u5408\u4f60\u9700\u6c42\u7684\u5f15\u64ce\u81f3\u5173\u91cd\u8981\u3002  <\/li>\n<li><strong>\u5b57\u4f53\u548c\u8bed\u8a00\u652f\u6301<\/strong>\uff1a\u786e\u4fddOCR\u5f15\u64ce\u652f\u6301\u6240\u9700\u7684\u8bed\u8a00\u548c\u5b57\u4f53\u7c7b\u578b\uff0c\u4f7f\u7528\u5e38\u89c1\u7684\u5b57\u4f53\u6837\u5f0f\u53ef\u4ee5\u63d0\u9ad8\u8bc6\u522b\u7387\u3002  <\/li>\n<li><strong>\u8bad\u7ec3\u81ea\u5b9a\u4e49\u6a21\u578b<\/strong>\uff1a\u5bf9\u4e8e\u7279\u5b9a\u9886\u57df\u7684\u6587\u672c\uff0c\u8003\u8651\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6280\u672f\u8bad\u7ec3\u81ea\u5b9a\u4e49OCR\u6a21\u578b\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u9002\u5e94\u7279\u5b9a\u7684\u6587\u672c\u7279\u5f81\u3002<br \/>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u63d0\u5347OCR\u7684\u8bc6\u522b\u6548\u679c\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u5f00\u53d1OCR\u7684\u4e3b\u8981\u6b65\u9aa4\u5305\u62ec\uff1a\u9009\u62e9OCR\u5e93\u3001\u51c6\u5907\u56fe\u50cf\u6570\u636e\u3001\u56fe\u50cf\u9884\u5904\u7406\u3001\u4f7f\u7528OCR\u8fdb\u884c\u6587\u672c\u8bc6\u522b\u3001\u7ed3\u679c [&hellip;]","protected":false},"author":3,"featured_media":980242,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980235"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=980235"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980235\/revisions"}],"predecessor-version":[{"id":980243,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/980235\/revisions\/980243"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/980242"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=980235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=980235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=980235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}