{"id":178416,"date":"2024-05-08T19:50:20","date_gmt":"2024-05-08T11:50:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/178416.html"},"modified":"2024-05-08T19:50:26","modified_gmt":"2024-05-08T11:50:26","slug":"python%e6%9c%89%e4%bb%80%e4%b9%88%e5%a5%bd%e7%9a%84%e5%ba%93%e5%8f%af%e4%bb%a5%e8%af%86%e5%88%ab%e9%aa%8c%e8%af%81%e7%a0%81","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/178416.html","title":{"rendered":"Python\u6709\u4ec0\u4e48\u597d\u7684\u5e93\u53ef\u4ee5\u8bc6\u522b\u9a8c\u8bc1\u7801"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27062832\/b6e05e1a-cbb0-44b0-9664-2d04ca8755d1.webp\" alt=\"Python\u6709\u4ec0\u4e48\u597d\u7684\u5e93\u53ef\u4ee5\u8bc6\u522b\u9a8c\u8bc1\u7801\" \/><\/p>\n<p><p><strong>Python\u7528\u4e8e\u9a8c\u8bc1\u7801\u8bc6\u522b\u7684\u597d\u5e93\u6709\u5982Tesseract OCR\u3001PyTesseract\u3001OpenCV\u3001Keras\u4e0eTensorFlow<\/strong>\u3001<strong>Pillow<\/strong>\u3001<strong>captcha<\/strong>\u7b49\u3002\u5176\u4e2d\uff0c<strong>Tesseract OCR<\/strong>\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5149\u5b66\u5b57\u7b26\u8bc6\u522b\uff08OCR\uff09\u5f15\u64ce\uff0c\u5b83\u53ef\u4ee5\u8bc6\u522b\u591a\u79cd\u683c\u5f0f\u7684\u56fe\u7247\u4e2d\u7684\u6587\u672c\uff0c\u5e76\u652f\u6301\u591a\u79cd\u8bed\u8a00\u3002\u4ee5<strong>Tesseract OCR<\/strong>\u4e3a\u57fa\u7840\u7684<strong>PyTesseract<\/strong>\u662fPython\u73af\u5883\u4e2d\u4f7f\u7528\u8fd9\u4e00\u5f15\u64ce\u7684\u63a5\u53e3\uff0c\u80fd\u591f\u5c06\u56fe\u7247\u4e2d\u7684\u6587\u672c\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u3002\u8be5\u5e93\u5bf9\u4e8e\u6807\u51c6\u6253\u5370\u5b57\u7b26\u7684\u8bc6\u522b\u51c6\u786e\u5ea6\u9ad8\uff0c\u4f46\u53ef\u80fd\u9700\u8981\u9884\u5904\u7406\u56fe\u50cf\u4ee5\u63d0\u9ad8\u8bc6\u522b\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001Tesseract OCR\u548cPyTesseract<\/h3>\n<\/p>\n<p><p><strong>Tesseract OCR<\/strong>\u7ecf\u8fc7\u591a\u5e74\u53d1\u5c55\uff0c\u5df2\u7ecf\u6210\u4e3a\u5728\u9a8c\u8bc1\u7801\u8bc6\u522b\u9886\u57df\u5e7f\u6cdb\u5e94\u7528\u7684\u5de5\u5177\u3002\u5b83\u9996\u5148\u9700\u8981\u5728\u7cfb\u7edf\u4e2d\u5b89\u88c5Tesseract\u5f15\u64ce\uff0c\u4e4b\u540e\u518d\u901a\u8fc7<strong>PyTesseract<\/strong>\u8fdb\u884c\u8c03\u7528\u3002Tesseract OCR\u914d\u5408\u9002\u5f53\u7684\u9884\u5904\u7406\u6b65\u9aa4\uff0c\u6bd4\u5982\u4e8c\u503c\u5316\u3001\u53bb\u566a\u7b49\uff0c\u53ef\u4ee5\u63d0\u9ad8\u8bc6\u522b\u7684\u51c6\u786e\u7387\u3002\u5b83\u8fd8\u5141\u8bb8\u7528\u6237\u8bad\u7ec3\u81ea\u5b9a\u4e49\u7684\u5b57\u4f53\uff0c\u66f4\u597d\u5730\u9002\u5e94\u7279\u5b9a\u6837\u5f0f\u7684\u9a8c\u8bc1\u7801\u3002<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u5f00\u59cb\u4f7f\u7528Tesseract\uff0c\u7528\u6237\u9700\u8981\u8c03\u6574\u56fe\u50cf\u7684\u5927\u5c0f\u3001\u5bf9\u6bd4\u5ea6\u3001\u4eae\u5ea6\u7b49\u5c5e\u6027\uff0c\u5e76\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u56fe\u50cf\u5206\u5272\u6765\u5206\u79bb\u91cd\u53e0\u6216\u7c98\u8fde\u7684\u5b57\u7b26\u3002\u8fd9\u4e9b\u9884\u5904\u7406\u6b65\u9aa4\u901a\u5e38\u9700\u914d\u5408\u5176\u4ed6\u5e93\u5982<strong>OpenCV<\/strong>\u6216<strong>Pillow<\/strong>\u6765\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001OpenCV<\/h3>\n<\/p>\n<p><p><strong>OpenCV<\/strong>\uff08Open Source Computer Vision Library\uff09\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u8f6f\u4ef6\u5e93\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u6570\u767e\u79cd\u8ba1\u7b97\u673a\u89c6\u89c9\u7b97\u6cd5\u3002\u5728\u9a8c\u8bc1\u7801\u8bc6\u522b\u65b9\u9762\uff0cOpenCV\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u56fe\u50cf\u9884\u5904\u7406\uff0c\u5982\u989c\u8272\u8f6c\u6362\u3001\u9608\u503c\u5316\u3001\u6ee4\u6ce2\u548c\u8fb9\u7f18\u68c0\u6d4b\u7b49\uff0c\u4ece\u800c\u4e3aOCR\u8bc6\u522b\u521b\u5efa\u66f4\u9002\u5408\u7684\u8f93\u5165\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528OpenCV\u8fdb\u884c\u8bc6\u522b\u7684\u4e00\u4e2a\u5178\u578b\u6d41\u7a0b\u53ef\u80fd\u5305\u62ec\uff1a\u8bfb\u53d6\u56fe\u50cf\u3001\u7070\u5ea6\u5904\u7406\u3001\u4e8c\u503c\u5316\u3001\u8fb9\u7f18\u68c0\u6d4b\u3001\u627e\u5230\u9a8c\u8bc1\u7801\u5b57\u7b26\u7684\u8fb9\u754c\u3001\u5206\u5272\u5b57\u7b26\u3001\u6700\u540e\u4f7f\u7528OCR\u5f15\u64ce\u50cfTesseract\u8fdb\u884c\u6587\u5b57\u8bc6\u522b\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001Keras\u4e0eTensorFlow<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u590d\u6742\u6216\u8005\u626d\u66f2\u7684\u9a8c\u8bc1\u7801\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6216\u8005\u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\u3002<strong>Keras<\/strong>\u4e0e<strong>TensorFlow<\/strong>\u662fPython\u4e2d\u5f3a\u5927\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u8bad\u7ec3\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u4ee5\u8bc6\u522b\u9a8c\u8bc1\u7801\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u6784\u5efa\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\uff0c\u5e76\u7528\u5927\u91cf\u7684\u5e26\u6807\u7b7e\u7684\u9a8c\u8bc1\u7801\u6837\u672c\u5bf9\u5176\u8fdb\u884c\u8bad\u7ec3\uff0c\u4f7f\u7f51\u7edc\u5b66\u4f1a\u8bc6\u522b\u9a8c\u8bc1\u7801\u4e2d\u7684\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u6df1\u5ea6\u5b66\u4e60\u8fdb\u884c\u9a8c\u8bc1\u7801\u8bc6\u522b\u9700\u8981\u5927\u91cf\u7684\u6570\u636e\u96c6\u4ee5\u53ca\u4e00\u5b9a\u7684\u8ba1\u7b97\u8d44\u6e90\u3002\u6b64\u65b9\u6cd5\u7684\u597d\u5904\u662f\u80fd\u591f\u5e94\u5bf9\u591a\u53d8\u7684\u9a8c\u8bc1\u7801\u6837\u5f0f\uff0c\u751a\u81f3\u5305\u62ec\u566a\u97f3\u80cc\u666f\u3001\u626d\u66f2\u6587\u5b57\u7b49\u590d\u6742\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001Pillow<\/h3>\n<\/p>\n<p><p><strong>Pillow<\/strong>\u662fPython\u4e2d\u4e00\u4e2a\u73b0\u4ee3\u5316\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u5b83\u662f\u8457\u540d\u7684<strong>PIL<\/strong>\uff08Python Imaging Library\uff09\u5e93\u7684\u4e00\u4e2a\u5206\u652f\u3002\u5728\u9a8c\u8bc1\u7801\u8bc6\u522b\u4e2d\uff0cPillow\u7ecf\u5e38\u88ab\u7528\u6765\u505a\u56fe\u7247\u7684\u52a0\u8f7d\u3001\u8f6c\u6362\u3001\u88c1\u526a\u7b49\u9884\u5904\u7406\u64cd\u4f5c\uff0c\u4e3aOCR\u6216\u8005\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u63d0\u4f9b\u5904\u7406\u540e\u7684\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4f7f\u7528Pillow\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u56fe\u50cf\u7684\u57fa\u672c\u64cd\u4f5c\uff0c\u5982\u8c03\u6574\u5927\u5c0f\u3001\u65cb\u8f6c\u3001\u989c\u8272\u8f6c\u6362\u7b49\u3002\u8fd9\u4e9b\u64cd\u4f5c\u5bf9\u4e8e\u8bc6\u522b\u7b80\u5355\u7684\u9a8c\u8bc1\u7801\u56fe\u50cf\u975e\u5e38\u6709\u7528\uff0c\u6709\u65f6\u4ec5\u901a\u8fc7\u5408\u9002\u7684\u9884\u5904\u7406\uff0c\u751a\u81f3\u53ef\u4ee5\u76f4\u63a5\u8bfb\u53d6\u5230\u9a8c\u8bc1\u7801\uff0c\u65e0\u9700\u5176\u4ed6\u590d\u6742\u7684\u7b97\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001captcha<\/h3>\n<\/p>\n<p><p><strong>captcha<\/strong>\u5e93\u662fPython\u4e2d\u751f\u6210\u9a8c\u8bc1\u7801\u56fe\u7247\u7684\u5e93\uff0c\u7528\u4e8e\u8bad\u7ec3\u548c\u6d4b\u8bd5\u9a8c\u8bc1\u7801\u8bc6\u522b\u7cfb\u7edf\u3002\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e2a\u5e93\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u521b\u5efa\u591a\u79cd\u6837\u5f0f\u548c\u56f0\u96be\u7b49\u7ea7\u7684\u9a8c\u8bc1\u7801\u56fe\u7247\u3002\u867d\u7136\u8fd9\u4e2a\u5e93\u7684\u4e3b\u8981\u7528\u9014\u662f\u751f\u6210\u9a8c\u8bc1\u7801\uff0c\u4f46\u5b83\u4e5f\u53ef\u4ee5\u7528\u6765\u5236\u4f5c\u7528\u4e8e\u673a\u5668\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u7684\u6837\u672c\u6570\u636e\u96c6\u3002\u5bf9\u4e8e\u8bad\u7ec3\u5982Keras\u6216TensorFlow\u8fd9\u6837\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u62e5\u6709\u5927\u91cf\u7684\u8bad\u7ec3\u6570\u636e\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<\/p>\n<p><p>Python\u4e2d\u7684\u8fd9\u4e9b\u5e93\u90fd\u63d0\u4f9b\u4e86\u5404\u81ea\u7279\u5b9a\u7684\u529f\u80fd\u548c\u4f18\u70b9\u3002\u7efc\u5408\u8fd0\u7528\u8fd9\u4e9b\u5e93\u548c\u6280\u672f\uff0c\u53ef\u4ee5\u9488\u5bf9\u4e0d\u540c\u7684\u9a8c\u8bc1\u7801\u7c7b\u578b\u548c\u8bc6\u522b\u96be\u5ea6\u9009\u62e9\u6216\u7ed3\u5408\u4f7f\u7528\u6700\u5408\u9002\u7684\u5de5\u5177\u3002\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7406\u89e3\u5404\u4e2a\u5e93\u7684\u7279\u70b9\u4ee5\u53ca\u5982\u4f55\u7ed3\u5408\u5b83\u4eec\u8fdb\u884c\u9a8c\u8bc1\u7801\u8bc6\u522b\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5f80\u5f80\u9700\u8981\u4e0d\u65ad\u8c03\u6574\u7b56\u7565\u548c\u65b9\u6cd5\uff0c\u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u8bc6\u522b\u6548\u7387\u548c\u51c6\u786e\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u54ea\u4e9bPython\u5e93\u53ef\u4ee5\u7528\u4e8e\u9a8c\u8bc1\u7801\u8bc6\u522b\uff1f<\/strong><\/p>\n<p>Python\u4e2d\u5b58\u5728\u8bb8\u591a\u4f18\u79c0\u7684\u5e93\u53ef\u4ee5\u7528\u4e8e\u9a8c\u8bc1\u7801\u8bc6\u522b\uff0c\u5176\u4e2d\u4e00\u4e9b\u503c\u5f97\u63a8\u8350\u7684\u5305\u62ec\uff1aTesseract OCR\u3001PyTesseract\u3001OpenCV\u548cPillow\u7b49\u3002\u8fd9\u4e9b\u5e93\u90fd\u5177\u6709\u4e0d\u540c\u7684\u7279\u70b9\u548c\u529f\u80fd\uff0c\u4ece\u7b80\u5355\u7684\u9a8c\u8bc1\u7801\u5230\u590d\u6742\u7684\u56fe\u50cf\u8bc6\u522b\u90fd\u53ef\u4ee5\u5e94\u5bf9\u3002<\/p>\n<p><strong>2. Tesseract OCR\u5982\u4f55\u4f7f\u7528\u6765\u8bc6\u522b\u9a8c\u8bc1\u7801\uff1f<\/strong><\/p>\n<p>Tesseract OCR\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u5f00\u6e90OCR\u5f15\u64ce\uff0c\u53ef\u4ee5\u7528\u4e8e\u8bc6\u522b\u5370\u5237\u5b57\u4f53\u7684\u6587\u5b57\uff0c\u5305\u62ec\u9a8c\u8bc1\u7801\u3002\u8981\u4f7f\u7528Tesseract OCR\u8fdb\u884c\u9a8c\u8bc1\u7801\u8bc6\u522b\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Tesseract OCR\u548cpytesseract\u5e93\u3002\u7136\u540e\uff0c\u5c06\u9a8c\u8bc1\u7801\u56fe\u7247\u52a0\u8f7d\u5230Python\u4e2d\uff0c\u8c03\u7528pytesseract\u7684\u76f8\u5173\u51fd\u6570\u6765\u8fdb\u884c\u8bc6\u522b\uff0c\u6700\u540e\u83b7\u53d6\u8bc6\u522b\u7ed3\u679c\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u4f7f\u7528\u6df1\u5ea6\u5b66\u4e60\u5e93PyTorch\u8bc6\u522b\u9a8c\u8bc1\u7801\uff1f<\/strong><\/p>\n<p>PyTorch\u662f\u4e00\u79cd\u975e\u5e38\u5f3a\u5927\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u5206\u7c7b\u3001\u76ee\u6807\u68c0\u6d4b\u548c\u9a8c\u8bc1\u7801\u8bc6\u522b\u7b49\u4efb\u52a1\u3002\u4f7f\u7528PyTorch\u8fdb\u884c\u9a8c\u8bc1\u7801\u8bc6\u522b\u7684\u4e00\u822c\u6b65\u9aa4\u5982\u4e0b\uff1a\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u901a\u5e38\u4f7f\u7528\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u7ed3\u6784\uff1b\u7136\u540e\uff0c\u51c6\u5907\u7528\u4e8e\u8bad\u7ec3\u7684\u9a8c\u8bc1\u7801\u6570\u636e\u96c6\uff0c\u5e76\u6839\u636e\u9700\u8981\u8fdb\u884c\u6570\u636e\u589e\u5f3a\uff1b\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528PyTorch\u7684\u6570\u636e\u52a0\u8f7d\u5668\u52a0\u8f7d\u6570\u636e\u96c6\u5e76\u8fdb\u884c\u8bad\u7ec3\uff1b\u6700\u540e\uff0c\u4f7f\u7528\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u8fdb\u884c\u9a8c\u8bc1\u7801\u8bc6\u522b\uff0c\u5373\u8f93\u5165\u9a8c\u8bc1\u7801\u56fe\u7247\uff0c\u8f93\u51fa\u8bc6\u522b\u7ed3\u679c\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u9a8c\u8bc1\u7801\u7c7b\u578b\uff0c\u53d6\u5f97\u76f8\u5bf9\u8f83\u9ad8\u7684\u51c6\u786e\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u7528\u4e8e\u9a8c\u8bc1\u7801\u8bc6\u522b\u7684\u597d\u5e93\u6709\u5982Tesseract OCR\u3001PyTesseract\u3001OpenCV\u3001Kera [&hellip;]","protected":false},"author":3,"featured_media":178426,"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\/178416"}],"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=178416"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/178416\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/178426"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=178416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=178416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=178416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}