Python安裝OpenCV的示例代碼

OpenCV介紹
OpenCV是一個(gè)基于BSD許可(開(kāi)源)發(fā)行的跨平臺(tái)計(jì)算機(jī)視覺(jué)庫(kù),可以運(yùn)行在Linux、Windows、Android和Mac OS操作系統(tǒng)上。它輕量級(jí)而且高效——由一系列 C 函數(shù)和少量 C++ 類構(gòu)成,同時(shí)提供了Python、Ruby、MATLAB等語(yǔ)言的接口,實(shí)現(xiàn)了圖像處理和計(jì)算機(jī)視覺(jué)方面的很多通用算法。
OpenCV用C++語(yǔ)言編寫,它的主要接口也是C++語(yǔ)言,但是依然保留了大量的C語(yǔ)言接口。該庫(kù)也有大量的Python、Java and MATLAB/OCTAVE(版本2.5)的接口。這些語(yǔ)言的API接口函數(shù)可以通過(guò)在線文檔獲得。如今也提供對(duì)于C#、Ch、Ruby,GO的支持。
OpenCV 擁有包括 500 多個(gè)C函數(shù)的跨平臺(tái)的中、高層 API。它不依賴于其它的外部庫(kù)——盡管也可以使用某些外部庫(kù)。
所有新的開(kāi)發(fā)和算法都是用C++接口。一個(gè)使用CUDA的GPU接口也于2010年9月開(kāi)始實(shí)現(xiàn)。
OpenCV 為Intel Integrated Performance Primitives(IPP)提供了透明接口。這意味著如果有為特定處理器優(yōu)化的 IPP 庫(kù),OpenCV 將在運(yùn)行時(shí)自動(dòng)加載這些庫(kù)。
注:OpenCV 2.0版的代碼已顯著優(yōu)化,無(wú)需IPP來(lái)提升性能,故2.0版不再提供IPP接口。
好了,下面開(kāi)始今天的正文。
安裝python-3.7.3-amd64.exe
命令行進(jìn)入到你Python的安裝目錄中的Scripts下:D:\Program Files\Python37\Scripts
安裝pip
進(jìn)入Python安裝目錄下的Scripts路徑,執(zhí)行 easy_install.exe pip
安裝wheel
進(jìn)入Python安裝目錄下的Scripts路徑,執(zhí)行 pip install wheel
安裝numpy
進(jìn)入Python安裝目錄下的Scripts路徑,執(zhí)行 pip install numpy
安裝opencv
進(jìn)入Python安裝目錄下的Scripts路徑,執(zhí)行 pip install opencv-python
Microsoft Windows [版本 10.0.17134.706] (c) 2018 Microsoft Corporation。保留所有權(quán)利。 C:\Users\LiuJing>D: D:\>cd D:\Program Files\Python37\Scripts D:\Program Files\Python37\Scripts>easy_install.exe pip Searching for pip Best match: pip 19.0.3 Adding pip 19.0.3 to easy-install.pth file Installing pip-script.py script to d:\program files\python37\Scripts Installing pip.exe script to d:\program files\python37\Scripts Installing pip3-script.py script to d:\program files\python37\Scripts Installing pip3.exe script to d:\program files\python37\Scripts Installing pip3.7-script.py script to d:\program files\python37\Scripts Installing pip3.7.exe script to d:\program files\python37\Scripts Using d:\program files\python37\lib\site-packages Processing dependencies for pip Finished processing dependencies for pip D:\Program Files\Python37\Scripts>pip install wheel Collecting wheel Downloading https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl Installing collected packages: wheel Successfully installed wheel-0.33.1 You are using pip version 19.0.3, however version 19.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. D:\Program Files\Python37\Scripts>pip install numpy Collecting numpy Downloading https://files.pythonhosted.org/packages/4e/9d/c129d78e6b942303b762ccfdf1f8339de80c5e6021b14ef0c99ec5bdc6aa/numpy-1.16.3-cp37-cp37m-win_amd64.whl (11.9MB) 100% |████████████████████████████████| 11.9MB 197kB/s Installing collected packages: numpy Successfully installed numpy-1.16.3 You are using pip version 19.0.3, however version 19.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. D:\Program Files\Python37\Scripts>pip install opencv-python Collecting opencv-python Downloading https://files.pythonhosted.org/packages/a3/50/04d0669afe884f137c2f490642756e8c4a658254300a9eaf253d1e643085/opencv_python-4.1.0.25-cp37-cp37m-win_amd64.whl (37.3MB) 100% |████████████████████████████████| 37.4MB 150kB/s Requirement already satisfied: numpy>=1.14.5 in d:\program files\python37\lib\site-packages (from opencv-python) (1.16.3) Installing collected packages: opencv-python Successfully installed opencv-python-4.1.0.25 You are using pip version 19.0.3, however version 19.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. D:\Program Files\Python37\Scripts>
import cv2
img = cv2.imread("01.jpg")
cv2.imshow("1", img)
cv2.waitKey(10000)
如果能導(dǎo)入并顯示圖片則成功
總結(jié)
到此這篇關(guān)于Python安裝OpenCV的示例代碼的文章就介紹到這了,更多相關(guān)Python安裝OpenCV內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- pycharm安裝opencv-python報(bào)錯(cuò)的解決
- python2.7安裝opencv-python很慢且總是失敗問(wèn)題
- 關(guān)于pip安裝opencv-python遇到的問(wèn)題
- python3.6.4安裝opencv3.4.2的實(shí)現(xiàn)
- python之OpenCV的作用以及安裝案例教程
- Python下opencv庫(kù)的安裝過(guò)程及問(wèn)題匯總
- python快速安裝OpenCV的步驟記錄
- Window系統(tǒng)下Python如何安裝OpenCV庫(kù)
- python 3.7.4 安裝 opencv的教程
- Python安裝OpenCV庫(kù)超時(shí)失敗解決
相關(guān)文章
在python中實(shí)現(xiàn)將一張圖片剪切成四份的方法
今天小編就為大家分享一篇在python中實(shí)現(xiàn)將一張圖片剪切成四份的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-12-12
Python連接PostgreSQL數(shù)據(jù)庫(kù)的方法
大家應(yīng)該都有所了解,python可以操作多種數(shù)據(jù)庫(kù),諸如SQLite、MySql、PostgreSQL等,這里不對(duì)所有的數(shù)據(jù)庫(kù)操作方法進(jìn)行贅述,只針對(duì)目前項(xiàng)目中用到的PostgreSQL做一下簡(jiǎn)單介紹,主要是Python連接PostgreSQL數(shù)據(jù)庫(kù)的方法。有需要的朋友們可以參考借鑒,下面來(lái)一起看看吧。2016-11-11
python批量導(dǎo)出導(dǎo)入MySQL用戶的方法
這篇文章主要介紹了2013-11-11
運(yùn)行python提示no module named sklearn的解決方法
這篇文章主要介紹了運(yùn)行python提示no module named sklearn的解決方法,需要的朋友可以參考下2020-11-11
Python基礎(chǔ)教程之淺拷貝和深拷貝實(shí)例詳解
這篇文章主要介紹了Python基礎(chǔ)教程之淺拷貝和深拷貝實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-07-07
Pytest參數(shù)化parametrize使用代碼實(shí)例
這篇文章主要介紹了Pytest參數(shù)化parametrize使用代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-02-02
pycharm中選中一個(gè)單詞替換所有重復(fù)單詞的實(shí)現(xiàn)方法
這篇文章主要介紹了pycharm中選中一個(gè)單詞替換所有重復(fù)單詞的實(shí)現(xiàn)方法,類似于sublime 里的ctrl+D功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2020-11-11
TensorFlow 2.0之后動(dòng)態(tài)分配顯存方式
這篇文章主要介紹了TensorFlow 2.0之后動(dòng)態(tài)分配顯存方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12
python里的條件語(yǔ)句和循環(huán)語(yǔ)句你了解多少
這篇文章主要為大家詳細(xì)介紹了python的條件語(yǔ)句和循環(huán)語(yǔ)句,使用數(shù)據(jù)庫(kù),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02

