{"id":1086,"date":"2022-07-22T23:41:00","date_gmt":"2022-07-22T23:41:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=1086"},"modified":"2022-07-22T23:41:00","modified_gmt":"2022-07-22T23:41:00","slug":"1086","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2022\/07\/22\/1086\/","title":{"rendered":"WINDOWS 11 \u7cfb\u7edf Python 3.10 \u5b89\u88c5 OpenCV"},"content":{"rendered":"<h2>2023-01-04 \u66f4\u65b0\u8865\u5145\u8bd5\u9a8c\uff0c\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\u6765\u63d0\u9ad8\u4e0b\u8f7d\u901f\u5ea6<\/h2>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b pip \u4f7f\u7528\u7684\u662f\u56fd\u5916\u7684\u955c\u50cf\uff0c\u5728\u4e0b\u8f7d\u7684\u65f6\u5019\u901f\u5ea6\u975e\u5e38\u6162\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\u6765\u63d0\u9ad8\u4e0b\u8f7d\u901f\u5ea6\uff0c\u4f8b\u5982\u4f7f\u7528\u56fd\u5185\u6e05\u534e\u5927\u5b66\u7684\u6e90\uff0c\u5730\u5740\u5982\u4e0b\uff1a<\/p>\n<pre><code>https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\n<\/code><\/pre>\n<p>\u76f4\u63a5\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u53ef\u4ee5\u5728 pip \u547d\u4ee4\u4e2d\u4f7f\u7528-i\u53c2\u6570\u6765\u6307\u5b9a\u955c\u50cf\u5730\u5740\uff0c\u5982\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u7528\u6e05\u534e\u955c\u50cf\u6e90\u5b89\u88c5 numpy \u548c opencv-python \u5305\u3002<\/p>\n<pre><code>python -m pip install numpy -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\npython -m pip install opencv-python -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2022\/07\/2838333003.webp\" alt=\"opencv.webp\" title=\"opencv.webp\"><\/p>\n<h2>1. \u5148\u5b89\u88c5 <code>NumPy<\/code> \u5e93\uff0c\u4f7f\u7528 <code>OpenCV<\/code> \u9700\u8981\u4f9d\u8d56 NumPy \u8fd9\u4e2a\u5e93<\/h2>\n<h2>python -m pip install numpy<\/h2>\n<pre><code>Collecting numpy\n  Using cached numpy-1.23.1-cp38-cp38-win_amd64.whl (14.7 MB)\nInstalling collected packages: numpy\nSuccessfully installed numpy-1.23.1<\/code><\/pre>\n<h2>2. <code>pip<\/code> \u5b89\u88c5  <code>OpenCV<\/code> \u5e93\u7684\u540d\u79f0\u662f <code>opencv-python<\/code>\uff0c\u6240\u4ee5\u4e0b\u9762\u547d\u4ee4\u9519\u8bef<\/h2>\n<pre><code>python -m pip install opencv\nERROR: Could not find a version that satisfies the requirement opencv (from versions: none)\nERROR: No matching distribution found for opencv<\/code><\/pre>\n<h2>3. <code>pip<\/code> \u5b89\u88c5  <code>OpenCV<\/code> \u5e93\u7684\u540d\u79f0\u662f <code>opencv-python<\/code><\/h2>\n<h2>python -m pip install opencv-python<\/h2>\n<pre><code>Collecting opencv-python\n  Downloading opencv_python-4.6.0.66-cp36-abi3-win_amd64.whl (35.6 MB)\n     ---------------------------------------- 35.6\/35.6 MB 599.9 kB\/s eta 0:00:00\nRequirement already satisfied: numpy&gt;=1.17.3 in c:usersvipappdatalocalprogramspythonpython38libsite-packages (from opencv-python) (1.23.1)\nInstalling collected packages: opencv-python\nSuccessfully installed opencv-python-4.6.0.66<\/code><\/pre>\n<h2>4. \u4f7f\u7528 <code>OpenCV<\/code> \u5e93\u8f6c\u6362\u56fe\u7247\u683c\u5f0f\u793a\u4f8b\uff1a\u628apng\u683c\u5f0f\u8f6c\u6362jpg\u548cwebp\u683c\u5f0f<\/h2>\n<pre><code>import cv2\nimg = cv2.imread('test.png')\ncv2.imwrite('test.jpg', img)\ncv2.imwrite('test.webp', img)<\/code><\/pre>\n<h2>Linux \u7cfb\u7edf\u5b89\u88c5 OpenCV \u5e93, \u5b89\u88c5\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u5b89\u88c5\u4f9d\u8d56\u5e93 numpy<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/lyvba.com\/wp-content\/uploads\/2022\/07\/1492794748.png\" alt=\"pip3.png\" title=\"pip3.png\"><\/p>\n<h3>python3 -m pip install --upgrade pip  # \u5148\u66f4\u65b0pip<\/h3>\n<h3>pip3 install opencv-python<\/h3>\n<pre><code>Collecting opencv-python\n  Downloading opencv_python-4.6.0.66-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.9 MB)\n     \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 60.9\/60.9 MB 10.1 MB\/s eta 0:00:00\nCollecting numpy&gt;=1.17.3\n  Downloading numpy-1.23.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)\n     \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 17.1\/17.1 MB 15.0 MB\/s eta 0:00:00\nInstalling collected packages: numpy, opencv-python\nSuccessfully installed numpy-1.23.1 opencv-python-4.6.0.66<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>2023-01-04 \u66f4\u65b0\u8865\u5145\u8bd5\u9a8c\uff0c\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\u6765\u63d0\u9ad8\u4e0b\u8f7d\u901f\u5ea6 \u9ed8\u8ba4\u60c5\u51b5\u4e0b pip \u4f7f\u7528\u7684\u662f\u56fd\u5916\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[45],"class_list":["post-1086","post","type-post","status-publish","format-standard","hentry","category-learn","tag-python"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/1086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=1086"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/1086\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=1086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=1086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=1086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}