{"id":1029213,"date":"2024-12-31T11:06:18","date_gmt":"2024-12-31T03:06:18","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1029213.html"},"modified":"2024-12-31T11:06:21","modified_gmt":"2024-12-31T03:06:21","slug":"python%e5%ae%89%e8%a3%85cv2%e5%ba%93%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1029213.html","title":{"rendered":"python\u5b89\u88c5cv2\u5e93\u5982\u4f55\u5b89\u88c5"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/bb791582-068e-4f43-9e46-c08e97f687f8.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5b89\u88c5cv2\u5e93\u5982\u4f55\u5b89\u88c5\" \/><\/p>\n<p><p> <strong>\u8981\u5b89\u88c5Python\u7684cv2\u5e93\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528pip\u5b89\u88c5\u3001\u786e\u4fdd\u6b63\u786e\u7684Python\u7248\u672c\u3001\u8bbe\u7f6e\u865a\u62df\u73af\u5883\u3002<\/strong> \u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\u6765\u5b89\u88c5cv2\u5e93\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528pip\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406Python\u7684\u5305\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5cv2\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install opencv-python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u5916\uff0c\u5982\u679c\u4f60\u9700\u8981\u5b8c\u6574\u7684OpenCV\u529f\u80fd\uff08\u5305\u62ec\u989d\u5916\u7684\u6a21\u5757\uff09\uff0c\u53ef\u4ee5\u5b89\u88c5opencv-python-headless:<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install opencv-python-headless<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u786e\u4fdd\u6b63\u786e\u7684Python\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5728\u5b89\u88c5cv2\u5e93\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86\u5408\u9002\u7684Python\u7248\u672c\u3002OpenCV 4.x \u7248\u672c\u652f\u6301Python 3.x\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fPython 2.x\uff0c\u5efa\u8bae\u5347\u7ea7\u5230Python 3.x\u3002<\/p>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u8bbe\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\uff0c\u5efa\u8bae\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528venv\u6a21\u5757\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-sh\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/li>\n<\/ol>\n<ul>\n<li>\u5728Windows\u4e0a:<\/li>\n<\/ul>\n<p><pre><code class=\"language-sh\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ul>\n<li>\u5728macOS\/Linux\u4e0a:<\/li>\n<\/ul>\n<p><pre><code class=\"language-sh\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5cv2\u5e93\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-sh\">pip install opencv-python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u9a8c\u8bc1cv2\u5e93\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<p>print(cv2.__version__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4e0a\u8ff0\u4ee3\u7801\u8fd0\u884c\u4e0d\u62a5\u9519\uff0c\u5e76\u4e14\u6253\u5370\u51faOpenCV\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660ecv2\u5e93\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5931\u8d25\u6216\u62a5\u9519<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u5347\u7ea7pip<\/strong>\uff1a\u786e\u4fdd\u4f60\u4f7f\u7528\u7684\u662f\u6700\u65b0\u7248\u672c\u7684pip\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u7279\u5b9a\u7248\u672c<\/strong>\uff1a\u6709\u65f6\u6700\u65b0\u7248\u672c\u53ef\u80fd\u4e0d\u7a33\u5b9a\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684opencv-python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install opencv-python==4.5.1.48<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u517c\u5bb9\u6027\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u9047\u5230\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u53ef\u4ee5\u53c2\u8003OpenCV\u5b98\u65b9\u6587\u6863\uff0c\u67e5\u770b\u4e0e\u5f53\u524dPython\u7248\u672c\u517c\u5bb9\u7684OpenCV\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u6709\u4e9b\u529f\u80fd\u53ef\u80fd\u4f9d\u8d56\u4e8e\u5176\u4ed6\u5e93\uff0c\u5982numpy\u3002\u5728\u5b89\u88c5cv2\u5e93\u65f6\uff0cpip\u4f1a\u81ea\u52a8\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u3002\u4f46\u5982\u679c\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u624b\u52a8\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install numpy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001Windows\u7cfb\u7edf\u7684\u5b89\u88c5\u7ec6\u8282<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e0a\u5b89\u88c5cv2\u5e93\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u7279\u5b9a\u7684\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u7ec6\u8282\u548c\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528wheel\u6587\u4ef6\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u6709\u65f6\u76f4\u63a5\u4f7f\u7528pip\u5b89\u88c5\u4f1a\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4e0b\u8f7d\u9884\u7f16\u8bd1\u7684wheel\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528pip\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u4e0b\u8f7d\u9002\u5408\u4f60Python\u7248\u672c\u7684wheel\u6587\u4ef6\uff1a<a href=\"https:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/#opencv\">https:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/#opencv<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5wheel\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install &lt;path_to_wheel_file&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Microsoft Visual C++<\/strong><\/p>\n<\/p>\n<p><p>OpenCV\u5728Windows\u4e0a\u9700\u8981Microsoft Visual C++\u7684\u652f\u6301\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u4ece\u5fae\u8f6f\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><p><a href=\"https:\/\/support.microsoft.com\/en-us\/help\/2977003\/the-latest-supported-visual-c-downloads\">https:\/\/support.microsoft.com\/en-us\/help\/2977003\/the-latest-supported-visual-c-downloads<\/a><\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001macOS\u7cfb\u7edf\u7684\u5b89\u88c5\u7ec6\u8282<\/h3>\n<\/p>\n<p><p>\u5728macOS\u7cfb\u7edf\u4e0a\u5b89\u88c5cv2\u5e93\u901a\u5e38\u6bd4\u8f83\u987a\u5229\uff0c\u4f46\u4e5f\u6709\u4e00\u4e9b\u7ec6\u8282\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528Homebrew\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>Homebrew\u662fmacOS\u4e0a\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u5b89\u88c5OpenCV\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">brew install opencv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5728Python\u4e2d\u5bfc\u5165cv2\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python<\/p>\n<p>&gt;&gt;&gt; import cv2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u786e\u4fdd\u6b63\u786e\u7684\u8def\u5f84<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u901a\u8fc7Homebrew\u5b89\u88c5\u540e\u4ecd\u7136\u65e0\u6cd5\u5bfc\u5165cv2\u5e93\uff0c\u53ef\u80fd\u662f\u8def\u5f84\u95ee\u9898\u3002\u786e\u4fddPython\u80fd\u591f\u627e\u5230OpenCV\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u89e3\u51b3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">export PYTHONPATH=\/usr\/local\/lib\/python3.9\/site-packages:$PYTHONPATH<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516b\u3001Linux\u7cfb\u7edf\u7684\u5b89\u88c5\u7ec6\u8282<\/h3>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e0a\u5b89\u88c5cv2\u5e93\u901a\u5e38\u4e5f\u6bd4\u8f83\u987a\u5229\uff0c\u4f46\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u8bbe\u7f6e\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5opencv-python\u4e4b\u524d\uff0c\u5148\u5b89\u88c5\u4e00\u4e9b\u5fc5\u9700\u7684\u4f9d\u8d56\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo apt-get update<\/p>\n<p>sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev<\/p>\n<p>sudo apt-get install python3.8-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u81ea\u5b9a\u4e49OpenCV\uff0c\u53ef\u4ee5\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git clone https:\/\/github.com\/opencv\/opencv.git<\/p>\n<p>cd opencv<\/p>\n<p>mkdir build<\/p>\n<p>cd build<\/p>\n<p>cmake ..<\/p>\n<p>make -j8<\/p>\n<p>sudo make install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e5d\u3001\u4f7f\u7528cv2\u5e93<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528cv2\u5e93\u8fdb\u884c\u56fe\u50cf\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bfb\u53d6\u56fe\u50cf<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<p>img = cv2.imread(&#39;image.jpg&#39;)<\/p>\n<p>cv2.imshow(&#39;Image&#39;, img)<\/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<\/li>\n<li>\n<p><strong>\u56fe\u50cf\u7070\u5ea6\u5904\u7406<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-python\">gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<\/p>\n<p>cv2.imshow(&#39;Gray Image&#39;, gray)<\/p>\n<p>cv2.waitKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u5b58\u56fe\u50cf<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-python\">cv2.imwrite(&#39;gray_image.jpg&#39;, gray)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5cv2\u5e93\u5e76\u4e0d\u590d\u6742\uff0c\u4f46\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5c0f\u95ee\u9898\u3002\u901a\u8fc7\u672c\u6587\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u4f60\u5e94\u8be5\u53ef\u4ee5\u987a\u5229\u5730\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5cv2\u5e93\uff0c\u5e76\u5f00\u59cb\u4f7f\u7528OpenCV\u8fdb\u884c\u56fe\u50cf\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u672c\u6587\u7684\u4e3b\u8981\u5185\u5bb9\u6458\u8981\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u4f7f\u7528pip\u5b89\u88c5<\/strong>\uff1a\u6700\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u60c5\u51b5\u3002<\/li>\n<li><strong>\u8bbe\u7f6e\u865a\u62df\u73af\u5883<\/strong>\uff1a\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002<\/li>\n<li><strong>\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/strong>\uff1a\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6cd5\u3002<\/li>\n<li><strong>\u64cd\u4f5c\u7cfb\u7edf\u7279\u5b9a\u7684\u5b89\u88c5\u7ec6\u8282<\/strong>\uff1a\u4ecb\u7ecd\u4e86Windows\u3001macOS\u548cLinux\u7cfb\u7edf\u4e0a\u7684\u5b89\u88c5\u7ec6\u8282\u3002<\/li>\n<\/ul>\n<p><p>\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u4f60\u5728\u4f7f\u7528OpenCV\u8fdb\u884c\u56fe\u50cf\u5904\u7406\u65f6\u4e00\u5207\u987a\u5229\uff01<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u786e\u8ba4\u6211\u7684Python\u73af\u5883\u4e2d\u662f\u5426\u5df2\u5b89\u88c5cv2\u5e93\uff1f<\/strong><br \/>\u8981\u786e\u8ba4cv2\u5e93\u662f\u5426\u5df2\u5b89\u88c5\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code class=\"language-python\">import cv2\nprint(cv2.__version__)\n<\/code><\/pre>\n<p>\u5982\u679ccv2\u5e93\u5df2\u5b89\u88c5\uff0c\u8fd9\u6761\u547d\u4ee4\u4f1a\u8fd4\u56de\u5f53\u524d\u5b89\u88c5\u7684OpenCV\u7248\u672c\u53f7\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u4f1a\u629b\u51fa\u4e00\u4e2aImportError\u9519\u8bef\u63d0\u793a\u3002<\/p>\n<p><strong>\u5728\u5b89\u88c5cv2\u5e93\u65f6\uff0c\u6211\u5e94\u8be5\u9009\u62e9\u54ea\u4e2a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>OpenCV\u652f\u6301\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u901a\u5e38\u5efa\u8bae\u4f7f\u7528\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\uff08\u5982Python 3.x\uff09\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u548c\u66f4\u591a\u7684\u529f\u80fd\u3002\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528\u7279\u5b9a\u7684\u9879\u76ee\u6216\u6846\u67b6\uff0c\u8bf7\u786e\u4fdd\u68c0\u67e5\u5176\u6587\u6863\u4ee5\u786e\u8ba4\u517c\u5bb9\u6027\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u5b89\u88c5cv2\u5e93\u65f6\u9047\u5230\u9519\u8bef\uff0c\u6211\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5b89\u88c5cv2\u5e93\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u9519\u8bef\uff0c\u5e38\u89c1\u7684\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\uff1a  <\/p>\n<ol>\n<li>\u786e\u4fdd\u4f60\u7684pip\u5de5\u5177\u662f\u6700\u65b0\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pip install --upgrade pip<\/code>\u8fdb\u884c\u66f4\u65b0\u3002  <\/li>\n<li>\u5982\u679c\u4f7f\u7528Windows\uff0c\u786e\u4fdd\u5df2\u5b89\u88c5Visual C++ Redistributable\u3002  <\/li>\n<li>\u68c0\u67e5\u4f60\u7684\u7f51\u7edc\u8fde\u63a5\u662f\u5426\u6b63\u5e38\uff0c\u56e0\u4e3a\u6709\u65f6\u4e0b\u8f7d\u8fc7\u7a0b\u4e2d\u4f1a\u51fa\u73b0\u95ee\u9898\u3002  <\/li>\n<li>\u5982\u679c\u4f7f\u7528Linux\uff0c\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u5e93\uff0c\u4f8b\u5982<code>libopencv-dev<\/code>\u3002\u6839\u636e\u9519\u8bef\u63d0\u793a\u8fdb\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u901a\u5e38\u53ef\u4ee5\u89e3\u51b3\u95ee\u9898\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"\u8981\u5b89\u88c5Python\u7684cv2\u5e93\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528pip\u5b89\u88c5\u3001\u786e\u4fdd\u6b63\u786e\u7684Python\u7248\u672c\u3001\u8bbe\u7f6e\u865a\u62df\u73af\u5883\u3002 \u4e0b\u9762 [&hellip;]","protected":false},"author":3,"featured_media":1029227,"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\/1029213"}],"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=1029213"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1029213\/revisions"}],"predecessor-version":[{"id":1029231,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1029213\/revisions\/1029231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1029227"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1029213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1029213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1029213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}