opencv2python3
① python 3 怎麼添加opencv
先進入如下連接下載python和系統版本對應的opencv包:
http://www.lfd.uci.e/~gohlke/pythonlibs/#opencv
比如我的版本是64位的python 3.41,那麼我就下載:
opencv_python-3.1.0-cp34-cp34m-win_amd64.whl
2
下載後修改文件名(這就是安裝中的坑了,不改是安不了的):
把原來文件名opencv_python-3.1.0-cp34-cp34m-win_amd64.whl中間的cp34m變為none,這樣文件名改為:opencv_python-3.1.0-cp34-none-win_amd64.whl
如果不改的話不然會出現:
opencv_python-3.1.0-cp34-cp34m-win_amd64.whl is not a supported wheel on this platform.
3
打開cmd(window鍵+R,輸入cmd就出現),在命令行輸入:
pip3 install 路徑名\opencv_python-3.1.0-cp34-none-win_amd64.whl
這樣就好了。
② tensorflow是python3怎麼安裝opencv
1.下載whl文件
來到這里
搜索適合你的python版本的whl,比如我是python3.5,就選cp35的包
我選擇了
opencv_python‑3.2.0‑cp35‑cp35m‑win_amd64.whl
還有
tensorflow‑0.12.0‑cp35‑cp35m‑win_amd64.whl
對應的我的python-3.5.如果你是3.6請選擇cp36的版本
2.安裝
下載好後將兩個文件復制到你的anaconda目錄下,使用pip安裝兩個文件
D:\Anaconda3>pip install ./opencv_python-3.2.0-cp35-cp35m-win_amd64.whl11
D:\Anaconda3>pip install ./tensorflow-0.12.0-cp35-cp35m-win_amd64.whl11
如果一切順利,你會看到這個畫面
3.成功
安裝成功!
在python中已經可以import啦!
③ opencv3.2為什麼還不發布官方python3版本
你可以自己下wheel文件裝啊,已經有支持py3的包了,去這個網站:
http://www.lfd.uci.e/~gohlke/pythonlibs/
OpenCV, a real time computer vision library.
opencv_python‑2.4.13.2‑cp27‑cp27m‑win32.whl
opencv_python‑2.4.13.2‑cp27‑cp27m‑win_amd64.whl
opencv_python‑3.1.0‑cp27‑cp27m‑win32.whl
opencv_python‑3.1.0‑cp27‑cp27m‑win_amd64.whl
opencv_python‑3.1.0‑cp34‑cp34m‑win32.whl
opencv_python‑3.1.0‑cp34‑cp34m‑win_amd64.whl
opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win32.whl
opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win_amd64.whl
opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win32.whl
opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl
opencv_python‑3.2.0‑cp35‑cp35m‑win32.whl
opencv_python‑3.2.0‑cp35‑cp35m‑win_amd64.whl
opencv_python‑3.2.0‑cp36‑cp36m‑win32.whl
opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl
④ opencv的python版本的(4.1.0.25)是不是包括了opencv2和opencv3啊
就opencv本身而言,opencv是用c++寫的,但是提供python的介面,c++執行效率更高,python開發效率更高(前提是python和c++都同樣熟悉)。
⑤ ubuntu中opencv2可以載入python3么
可以
Installing OpenCV in Ubuntu for Python 3
byWK· Published March 2, 2016 · Updated March 3, 2017
Installing OpenCV in linux for Python 3 is not that straight forward, so in this tutorial, we』ll go through the steps on how do we do it. We』ll be using a 64 bit Ubuntu 16.04 system, and Python 3.5 in this tutorial. (It should also work for Ubuntu 12.04++ onwards and Python 3.x)
(While ing the code over,do notinclude the >>> in the terminal: It』s just used to represent the python input.)
Contents[hide]
1Packages Required
2Copying the Python dev file
3Downloading the OpenCV Source Code
4Building
5Installing
6Checking
7Python Libraries
8Troubleshooting
9References
GCC
CMake
Git
GTK+2.x or higher, including headers (libgtk2.0-dev)
pkg-config
ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
Did you miss the 「Copying the Python dev file」 step? (If you are running Python3.3+)?
Make sure that you downloaded the correct python-dev packages. If you are not running Python 3.5, please change the dev packages accordingly. (E.g. Python 3.4 would bepython3.4-dev)
Recompile the makefile of the build directory. Make sure that you delete everything in the build directory before recompiling the makefile.
If it still does not work, try reinstalling the required packages.
Packages Required
Before compiling OpenCV, we have to download some packages for compilation.
Update the repository before installing the necessary packages.
1
sudoapt-getupdate
Once the update is done, we』ll proceed on to downloading the required packages to compile OpenCV.
1
sudoapt-getinstallbuild-essentialcmakegitlibgtk2.0-devpkg-configlibavcodec-devlibavformat-devlibswscale-dev
Next, we will install the developer packages for python3. If you are using a different version of python, change it to python3.x-dev. (E.g. If you are using Python 3.3, use this instead: python3.3-dev)
1
sudoapt-getinstallpython3.5-dev
Copying the Python dev file
(If you using Python 3.2 or below, you can skip to the next step.)
As the pycofig.h header file is not in the typical place, we would have to the file to the expected location. Run the following code below:
1
python3.5-config--includes
The output would look something similar below:
1
-I/usr/include/python3.5m-I/usr/include/x86_64-linux-gnu/python3.5m
The first part of the output is the expected location & the second part shows the current location of the config file. To solve this problem, we』ll the file from the current location to the expected location.
1
sudocp/usr/include/x86_64-linux-gnu/python3.5m/pyconfig.h/usr/include/python3.5m/
Downloading the OpenCV Source Code
Make a new directoryOpenCV-tmpin your Desktop, then change the directory intoOpenCV-tmp. We will be using cloning the OpenCV source from Github into this folder.
1
2
3
mkdirOpenCV-tmp
cdOpenCV-tmp
gitclone ez/opencv.git
Aopencvdirectory will be created inOpenCV-tmp. Renameopencvtoopencv-3.
Building
Before compiling the source, we have to generate the make file, so we will be using cmake.
Create a new directorybuild,which we will build the makefile in. Change the directory into it.
After that, run the cmake utility:
1
cmake-DCMAKE_BUILD_TYPE=RELEASE-DCMAKE_INSTALL_PREFIX=/usr/local../opencv-3
If the command above does not work, you can try this alternative command: (Thanks tosupermdguyfor pointing this out!)
1
cmake-DCMAKE_BUILD_TYPE=RELEASE-DCMAKE_INSTALL_PREFIX=/usr/local..
After the makefile is generated, we will build the installation files:
1
make-j$(nproc--all)
This may take some time depending on your computer.
Side note:We』ll split themaketask via the-jargument, and the$(nproc -all)bash command to use all the processors available. Say if you want to only use 2 of the processors to run themakecommand, the command would look like this:
1
make-j2
Installing
Once the build is complete, we』ll install OpenCV by running the make file:
1
sudomakeinstall
Checking
After OpenCV have finished installing, we have to check to ensure that OpenCV have been properly installed .
To do this, we』ll enter Python 3 and importcv2,and also check it』s version. If there are no errors, the output should look something like this:
1
2
3
>>>importcv2
>>>cv2.__version__
'3.1.0-dev'
With this, you have successfully installed OpenCV for Python 3!
Python Libraries
Here are some of the python libraries that are commonly used in conjunction with OpenCV:
Numpy: Fundamental package for scientific computing
1
sudoapt-getinstallpython3-numpy
Matplotlib: 2D Plotting Library
1
sudoapt-getinstallpython3-matplotlib
Troubleshooting
ImportError: No mole named 『cv2』
⑥ cv2從python2.7與3.5中使用
因為你是python2環境下的opencv,並不是python3環境下的,每個python版本的工具包都是獨立的,需要分別安裝
⑦ opencv支持python3嗎
安裝Python3
brew install python3
沒有homebrew的話請自行安裝不要使用pip3
一開始我使用
pip3 install numpy
pip3 install opencv-python
雖然成功了,但是不能使用imshow及video相關的東西,要你何用。刪除原OpenCV
在原先CMake的build文件夾下使用
make uninstall安裝OpenCV3
brew install opencv3 --with-contrib --with-python3 --without-python
–with-contrib是安裝額外的contrib模塊。
如果不加–without-python會報一個大意是不能同時用於python3和python2的錯。等待漫長的各種下載和編譯
期間會編譯gcc,花了一個半小時,也是醉了。
有些步驟掛VPN會加速,有些反而會更慢。關於protobuf出錯
在OpenCV3的CMake階段會報一個protobuf下載失敗的錯。
使用:
brew install protobuf
再重新執行鏈接
安裝完後提示信息,大意是OpenCV3與OpenCV有很多文件沖突,所以就不把它放在/usr/local里了 blabla..
此時雖然python里可以用了,但是c++里不行了。
需要使用:
brew link opencv3 --overwrite --force切換
如果以後需要同時使用OpenCV2和OpenCV3,可以用以下命令相互切換
brew unlink opencv3
brew link opencv --force --overwrite
⑧ opencv可以用python3.0嗎
win_amd64.whl(!!!32位的系統下載32位的包,64位的下載64位的,但是如果在64位的系統上安裝了32位的python,則需下載32位的包)(opencv3.0.0對應的是opencv的版本,cp34對應的python的版本)2.使用cmd進入下載好的文件的目錄,安裝指令:(opencv是最後安裝的)"pipinstallnumpy-1.11.0+mkl-cp35-cp35m-win_amd64.whl""pipinstallscipy-0.17.1-cp35-cp35m-win_amd64.whl""pipinstallopencv_python-3.1.0-cp35-cp35m-win_amd64.whl"3.之後把D:\python35\Lib\site-packages中那一堆opencv的dll放到一個新建的名為cv2的文件夾里4.驗證:importcv2無報錯
⑨ python3中能安裝opencv2嗎
官方不支持,建議等支持吧。 dll有自己版本對應的,必須使用專門為python3.4編譯的dll(cv2.pyd),你拿python2.7的肯定用不了。 如果非要使用—— 方法一:自己編譯opencv的源碼 方法二:安裝python2.7
⑩ 如何給Python3安裝OpenCV庫
試試 pip3 install opencv-python