{"id":1020751,"date":"2024-12-27T13:15:11","date_gmt":"2024-12-27T05:15:11","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1020751.html"},"modified":"2024-12-27T13:15:13","modified_gmt":"2024-12-27T05:15:13","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8python%e5%9b%be%e5%83%8f%e6%a0%87%e6%b3%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1020751.html","title":{"rendered":"\u5982\u4f55\u4f7f\u7528python\u56fe\u50cf\u6807\u6ce8"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25163138\/a5d454ea-b84f-42f4-83d7-921d26817f8e.webp\" alt=\"\u5982\u4f55\u4f7f\u7528python\u56fe\u50cf\u6807\u6ce8\" \/><\/p>\n<p><p> \u8981\u4f7f\u7528Python\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8\uff0c<strong>\u53ef\u4ee5\u501f\u52a9OpenCV\u3001Pillow\u3001matplotlib\u7b49\u5e93\u3001\u4ee5\u53caLabelImg\u7b49\u5de5\u5177\u6765\u5b9e\u73b0<\/strong>\u3002\u5176\u4e2d\uff0cOpenCV\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\uff0cPillow\u662fPython Imaging Library\u7684\u4e00\u4e2a\u5206\u652f\uff0c\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u7684\u57fa\u672c\u64cd\u4f5c\uff0c\u800cmatplotlib\u5219\u53ef\u4ee5\u7528\u4e8e\u53ef\u89c6\u5316\u3002LabelImg\u662f\u4e00\u4e2a\u56fe\u50cf\u6807\u6ce8\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u751f\u6210\u6807\u6ce8\u6587\u4ef6\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001OPENCV\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8<\/p>\n<\/p>\n<p><p>OpenCV\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u5e93\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u548c\u89c6\u9891\u5904\u7406\u3002\u5728\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8\u65f6\uff0cOpenCV\u7684\u591a\u79cd\u7ed8\u5236\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u5404\u79cd\u6807\u6ce8\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5OpenCV<\/strong><\/li>\n<\/ol>\n<p><p>\u8981\u4f7f\u7528OpenCV\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\u3002\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install opencv-python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u52a0\u8f7d\u548c\u663e\u793a\u56fe\u50cf<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528OpenCV\u52a0\u8f7d\u548c\u663e\u793a\u56fe\u50cf\u975e\u5e38\u7b80\u5355\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/h2>\n<p>image = cv2.imread(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf<\/strong><\/h2>\n<p>cv2.imshow(&#39;Image&#39;, image)<\/p>\n<p>cv2.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>tKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u6807\u6ce8<\/strong><\/li>\n<\/ol>\n<p><p>OpenCV\u63d0\u4f9b\u4e86\u591a\u79cd\u51fd\u6570\u7528\u4e8e\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u6807\u6ce8\uff0c\u5982\u753b\u7ebf\u3001\u77e9\u5f62\u3001\u5706\u5f62\u4ee5\u53ca\u6587\u672c\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u6807\u6ce8\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u753b\u7ebf<\/p>\n<p>cv2.line(image, (0, 0), (150, 150), (255, 0, 0), 5)<\/p>\n<h2><strong>\u753b\u77e9\u5f62<\/strong><\/h2>\n<p>cv2.rectangle(image, (15, 25), (200, 150), (0, 255, 0), 3)<\/p>\n<h2><strong>\u753b\u5706\u5f62<\/strong><\/h2>\n<p>cv2.circle(image, (100, 100), 55, (0, 0, 255), -1)<\/p>\n<h2><strong>\u6dfb\u52a0\u6587\u672c<\/strong><\/h2>\n<p>font = cv2.FONT_HERSHEY_SIMPLEX<\/p>\n<p>cv2.putText(image, &#39;OpenCV&#39;, (10, 500), font, 4, (255, 255, 255), 2, cv2.LINE_AA)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u51fd\u6570\u90fd\u9700\u8981\u4f20\u5165\u56fe\u50cf\u3001\u5750\u6807\u3001\u989c\u8272\u548c\u7ebf\u5bbd\u7b49\u53c2\u6570\u3002\u901a\u8fc7\u8fd9\u4e9b\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u5404\u79cd\u6807\u6ce8\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001PILLOW\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8<\/p>\n<\/p>\n<p><p>Pillow\u662fPython Imaging Library\uff08PIL\uff09\u7684\u4e00\u4e2a\u53cb\u597d\u7684\u5206\u652f\uff0c\u652f\u6301\u591a\u79cd\u56fe\u50cf\u6587\u4ef6\u683c\u5f0f\u3002\u5b83\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u7684\u521b\u5efa\u3001\u8f6c\u6362\u548c\u6807\u6ce8\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5Pillow<\/strong><\/li>\n<\/ol>\n<p><p>\u53ef\u4ee5\u901a\u8fc7pip\u5b89\u88c5Pillow\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pillow<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u52a0\u8f7d\u548c\u663e\u793a\u56fe\u50cf<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528Pillow\u52a0\u8f7d\u548c\u663e\u793a\u56fe\u50cf\u4e5f\u5f88\u7b80\u5355\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/h2>\n<p>image = Image.open(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf<\/strong><\/h2>\n<p>image.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u6807\u6ce8<\/strong><\/li>\n<\/ol>\n<p><p>Pillow\u63d0\u4f9b\u4e86ImageDraw\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u4e8e\u5728\u56fe\u50cf\u4e0a\u7ed8\u5236\u57fa\u672c\u7684\u5f62\u72b6\u548c\u6587\u672c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import ImageDraw<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aDraw\u5bf9\u8c61<\/strong><\/h2>\n<p>draw = ImageDraw.Draw(image)<\/p>\n<h2><strong>\u753b\u7ebf<\/strong><\/h2>\n<p>draw.line((0, 0) + image.size, fill=128)<\/p>\n<h2><strong>\u753b\u77e9\u5f62<\/strong><\/h2>\n<p>draw.rectangle([50, 50, 150, 150], outline=&quot;red&quot;)<\/p>\n<h2><strong>\u6dfb\u52a0\u6587\u672c<\/strong><\/h2>\n<p>draw.text((10, 10), &quot;Sample Text&quot;, fill=&quot;white&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u5404\u79cd\u6807\u6ce8\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001MATPLOTLIB\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8<\/p>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u7528\u4e8e\u7ed8\u5236\u56fe\u5f62\u7684Python\u5e93\uff0c\u901a\u5e38\u7528\u4e8e\u7ed8\u5236\u6570\u636e\u53ef\u89c6\u5316\u56fe\u5f62\u3002\u5b83\u4e5f\u53ef\u4ee5\u7528\u4e8e\u56fe\u50cf\u6807\u6ce8\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5Matplotlib<\/strong><\/li>\n<\/ol>\n<p><p>\u53ef\u4ee5\u901a\u8fc7pip\u5b89\u88c5Matplotlib\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u52a0\u8f7d\u548c\u663e\u793a\u56fe\u50cf<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528Matplotlib\u52a0\u8f7d\u548c\u663e\u793a\u56fe\u50cf\u7684\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import matplotlib.image as mpimg<\/p>\n<h2><strong>\u52a0\u8f7d\u56fe\u50cf<\/strong><\/h2>\n<p>img = mpimg.imread(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf<\/strong><\/h2>\n<p>plt.imshow(img)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u6807\u6ce8<\/strong><\/li>\n<\/ol>\n<p><p>Matplotlib\u53ef\u4ee5\u4f7f\u7528\u5176\u7ed8\u56fe\u529f\u80fd\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u6807\u6ce8\uff0c\u5982\u7ebf\u6761\u3001\u77e9\u5f62\u548c\u6587\u672c\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.patches as patches<\/p>\n<p>fig, ax = plt.subplots(1)<\/p>\n<p>ax.imshow(img)<\/p>\n<h2><strong>\u6dfb\u52a0\u77e9\u5f62<\/strong><\/h2>\n<p>rect = patches.Rectangle((50, 50), 100, 100, linewidth=2, edgecolor=&#39;r&#39;, facecolor=&#39;none&#39;)<\/p>\n<p>ax.add_patch(rect)<\/p>\n<h2><strong>\u6dfb\u52a0\u6587\u672c<\/strong><\/h2>\n<p>plt.text(60, 60, &#39;Sample Text&#39;, fontsize=12, color=&#39;white&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u56fe\u50cf\u4e0a\u6dfb\u52a0\u5404\u79cd\u6807\u6ce8\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528LabelImg\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8<\/p>\n<\/p>\n<p><p>LabelImg\u662f\u4e00\u4e2a\u56fe\u50cf\u6807\u6ce8\u5de5\u5177\uff0c\u7279\u522b\u9002\u7528\u4e8e\u751f\u6210\u7528\u4e8e<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u7684\u6807\u6ce8\u6570\u636e\u3002\u5b83\u652f\u6301\u591a\u79cd\u6807\u6ce8\u683c\u5f0f\uff0c\u5982PASCAL VOC\u548cYOLO\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5LabelImg<\/strong><\/li>\n<\/ol>\n<p><p>LabelImg\u53ef\u4ee5\u901a\u8fc7GitHub\u4ed3\u5e93\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002\u9996\u5148\uff0c\u514b\u9686\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git clone https:\/\/github.com\/tzutalin\/labelImg.git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5b89\u88c5\u4f9d\u8d56\u5e76\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd labelImg<\/p>\n<p>pip install -r requirements.txt<\/p>\n<p>python labelImg.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528LabelImg\u8fdb\u884c\u6807\u6ce8<\/strong><\/li>\n<\/ol>\n<p><p>LabelImg\u63d0\u4f9b\u4e86\u4e00\u4e2a\u56fe\u5f62\u7528\u6237\u754c\u9762\uff0c\u53ef\u4ee5\u7528\u4e8e\u52a0\u8f7d\u56fe\u50cf\u5e76\u8fdb\u884c\u6807\u6ce8\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u754c\u9762\u65b9\u4fbf\u5730\u9009\u62e9\u56fe\u50cf\u3001\u6dfb\u52a0\u6807\u6ce8\u3001\u4fdd\u5b58\u6807\u6ce8\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u751f\u6210\u6807\u6ce8\u6587\u4ef6<\/strong><\/li>\n<\/ol>\n<p><p>\u5b8c\u6210\u6807\u6ce8\u540e\uff0cLabelImg\u53ef\u4ee5\u751f\u6210XML\u6216TXT\u683c\u5f0f\u7684\u6807\u6ce8\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u53ef\u4ee5\u7528\u4e8e\u8bad\u7ec3\u673a\u5668\u5b66\u4e60\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u7efc\u5408\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u7efc\u5408\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u3002\u4f8b\u5982\uff0c\u4f7f\u7528LabelImg\u8fdb\u884c\u521d\u6b65\u6807\u6ce8\uff0c\u7136\u540e\u4f7f\u7528OpenCV\u6216Pillow\u8fdb\u884c\u66f4\u7cbe\u7ec6\u7684\u6807\u6ce8\u5904\u7406\u3002\u6216\u8005\uff0c\u4f7f\u7528Matplotlib\u5bf9\u6807\u6ce8\u7ed3\u679c\u8fdb\u884c\u53ef\u89c6\u5316\u5c55\u793a\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u7ed3\u5408\u4f7f\u7528OpenCV\u548cLabelImg<\/strong><\/li>\n<\/ol>\n<p><p>\u53ef\u4ee5\u5148\u4f7f\u7528LabelImg\u8fdb\u884c\u521d\u6b65\u7684\u6807\u6ce8\uff0c\u7136\u540e\u4f7f\u7528OpenCV\u8bfb\u53d6\u751f\u6210\u7684\u6807\u6ce8\u6587\u4ef6\uff0c\u8fdb\u4e00\u6b65\u5904\u7406\u56fe\u50cf\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528OpenCV\u5bf9\u6807\u6ce8\u7ed3\u679c\u8fdb\u884c\u7ec6\u5316\u5904\u7406\uff0c\u6216\u6dfb\u52a0\u989d\u5916\u7684\u6ce8\u91ca\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u7ed3\u5408\u4f7f\u7528Pillow\u548cMatplotlib<\/strong><\/li>\n<\/ol>\n<p><p>Pillow\u53ef\u4ee5\u7528\u4e8e\u52a0\u8f7d\u548c\u5904\u7406\u56fe\u50cf\uff0c\u800cMatplotlib\u53ef\u4ee5\u7528\u4e8e\u5bf9\u5904\u7406\u540e\u7684\u56fe\u50cf\u8fdb\u884c\u53ef\u89c6\u5316\u5c55\u793a\u3002\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e24\u4e2a\u5e93\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5f3a\u5927\u7684\u56fe\u50cf\u6807\u6ce8\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u56fe\u50cf\u6807\u6ce8\u7684\u5e94\u7528<\/p>\n<\/p>\n<p><p>\u56fe\u50cf\u6807\u6ce8\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u3002\u6807\u6ce8\u6570\u636e\u901a\u5e38\u7528\u4e8e\u8bad\u7ec3\u76d1\u7763\u5b66\u4e60\u6a21\u578b\uff0c\u5982\u5bf9\u8c61\u68c0\u6d4b\u3001\u56fe\u50cf\u5206\u7c7b\u548c\u8bed\u4e49\u5206\u5272\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5bf9\u8c61\u68c0\u6d4b<\/strong><\/li>\n<\/ol>\n<p><p>\u5bf9\u8c61\u68c0\u6d4b\u4efb\u52a1\u9700\u8981\u8bc6\u522b\u56fe\u50cf\u4e2d\u7684\u7279\u5b9a\u5bf9\u8c61\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u5bf9\u8c61\u751f\u6210\u4e00\u4e2a\u8fb9\u754c\u6846\u3002\u901a\u8fc7\u6807\u6ce8\u5bf9\u8c61\u7684\u8fb9\u754c\u6846\uff0c\u53ef\u4ee5\u8bad\u7ec3\u5bf9\u8c61\u68c0\u6d4b\u6a21\u578b\uff0c\u5982YOLO\u548cFaster R-CNN\u7b49\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u56fe\u50cf\u5206\u7c7b<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e2d\uff0c\u6807\u6ce8\u56fe\u50cf\u7684\u7c7b\u522b\u4fe1\u606f\u7528\u4e8e\u8bad\u7ec3\u5206\u7c7b\u6a21\u578b\u3002\u6807\u6ce8\u6570\u636e\u96c6\u53ef\u4ee5\u5e2e\u52a9\u6a21\u578b\u5b66\u4e60\u5982\u4f55\u6839\u636e\u56fe\u50cf\u7684\u7279\u5f81\u8fdb\u884c\u5206\u7c7b\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u8bed\u4e49\u5206\u5272<\/strong><\/li>\n<\/ol>\n<p><p>\u8bed\u4e49\u5206\u5272\u4efb\u52a1\u9700\u8981\u5bf9\u56fe\u50cf\u4e2d\u7684\u6bcf\u4e2a\u50cf\u7d20\u8fdb\u884c\u5206\u7c7b\u3002\u6807\u6ce8\u6570\u636e\u96c6\u901a\u5e38\u5305\u542b\u6bcf\u4e2a\u50cf\u7d20\u7684\u7c7b\u522b\u4fe1\u606f\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u8bad\u7ec3\u6a21\u578b\u8fdb\u884c\u7cbe\u7ec6\u7684\u8bed\u4e49\u5206\u5272\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u800c\u8a00\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u548c\u5e93\u7528\u4e8e\u56fe\u50cf\u6807\u6ce8\uff0c\u5305\u62ecOpenCV\u3001Pillow\u3001Matplotlib\u548cLabelImg\u7b49\u3002\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u56fe\u50cf\u6807\u6ce8\u529f\u80fd\u3002\u8fd9\u4e9b\u6807\u6ce8\u6570\u636e\u5728\u673a\u5668\u5b66\u4e60\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u4e2d\u53d1\u6325\u7740\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u56fe\u50cf\u6807\u6ce8\u5de5\u5177\uff1f<\/strong><br \/>\u5728\u4f7f\u7528Python\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u81f3\u5173\u91cd\u8981\u3002\u5e38\u7528\u7684\u56fe\u50cf\u6807\u6ce8\u5de5\u5177\u5305\u62ecLabelImg\u3001VGG Image Annotator (VIA)\u548cRectLabel\u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u4e0d\u4ec5\u63d0\u4f9b\u4e86\u76f4\u89c2\u7684\u7528\u6237\u754c\u9762\uff0c\u8fd8\u652f\u6301\u591a\u79cd\u683c\u5f0f\u7684\u8f93\u51fa\uff0c\u4f8b\u5982Pascal VOC\u548cCOCO\u683c\u5f0f\uff0c\u65b9\u4fbf\u4e0ePython\u4e2d\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u517c\u5bb9\u3002\u6839\u636e\u4f60\u7684\u9879\u76ee\u9700\u6c42\u548c\u4e2a\u4eba\u4e60\u60ef\uff0c\u9009\u62e9\u6700\u9002\u5408\u7684\u5de5\u5177\u53ef\u4ee5\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u5e93\u53ef\u4ee5\u5e2e\u52a9\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8\uff1f<\/strong><br \/>Python\u4e2d\u6709\u8bb8\u591a\u5e93\u53ef\u4ee5\u7b80\u5316\u56fe\u50cf\u6807\u6ce8\u7684\u8fc7\u7a0b\u3002OpenCV\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u9009\u62e9\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\uff0c\u80fd\u591f\u8fdb\u884c\u56fe\u50cf\u7684\u52a0\u8f7d\u3001\u663e\u793a\u548c\u7f16\u8f91\u3002Pillow\u4e5f\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u65b9\u4fbf\u8fdb\u884c\u57fa\u672c\u7684\u56fe\u50cf\u64cd\u4f5c\u3002\u6b64\u5916\uff0c\u4f7f\u7528Matplotlib\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ed8\u5236\u56fe\u5f62\u548c\u663e\u793a\u56fe\u50cf\uff0c\u975e\u5e38\u9002\u5408\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\u548c\u6807\u6ce8\u3002<\/p>\n<p><strong>\u5982\u4f55\u5c06\u6807\u6ce8\u7ed3\u679c\u5bfc\u5165Python\u8fdb\u884c\u6570\u636e\u5904\u7406\uff1f<\/strong><br \/>\u5728\u5b8c\u6210\u56fe\u50cf\u6807\u6ce8\u540e\uff0c\u901a\u5e38\u9700\u8981\u5c06\u6807\u6ce8\u7ed3\u679c\u5bfc\u5165Python\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u6570\u636e\u5904\u7406\u3002\u5927\u591a\u6570\u6807\u6ce8\u5de5\u5177\u4f1a\u5c06\u6807\u6ce8\u6570\u636e\u4fdd\u5b58\u4e3aJSON\u6216XML\u683c\u5f0f\u3002\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>json<\/code>\u5e93\u6216<code>xml.etree.ElementTree<\/code>\u5e93\u6765\u89e3\u6790\u8fd9\u4e9b\u6587\u4ef6\u3002\u89e3\u6790\u540e\uff0c\u53ef\u4ee5\u5c06\u6807\u6ce8\u6570\u636e\u8f6c\u6362\u4e3aPandas DataFrame\u7b49\u683c\u5f0f\uff0c\u4ee5\u4fbf\u4e8e\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u6a21\u578b\u8bad\u7ec3\u3002\u786e\u4fdd\u6839\u636e\u9879\u76ee\u9700\u6c42\u9002\u5f53\u5730\u5904\u7406\u548c\u6e05\u6d17\u6570\u636e\uff0c\u4ee5\u63d0\u9ad8\u540e\u7eed\u5206\u6790\u7684\u51c6\u786e\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u4f7f\u7528Python\u8fdb\u884c\u56fe\u50cf\u6807\u6ce8\uff0c\u53ef\u4ee5\u501f\u52a9OpenCV\u3001Pillow\u3001matplotlib\u7b49\u5e93\u3001\u4ee5\u53caLabelI [&hellip;]","protected":false},"author":3,"featured_media":1020756,"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\/1020751"}],"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=1020751"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1020751\/revisions"}],"predecessor-version":[{"id":1020760,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1020751\/revisions\/1020760"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1020756"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1020751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1020751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1020751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}