欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

ubuntu python3 install opencv2

系統 1809 0

Installing OpenCV in Ubuntu for Python 3

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 copying the code over, do not include the >>> in the terminal: It’s just used to represent the python input.)

Contents [hide]

  • 1 Packages Required
  • 2 Copying the Python dev file
  • 3 Downloading the OpenCV Source Code
  • 4 Building
  • 5 Installing
  • 6 Checking
  • 7 Python Libraries
  • 8 Troubleshooting
  • 9 References

Packages Required

Before compiling OpenCV, we have to download some packages for compilation.

Update the repository before installing the necessary packages.

sudo apt-get update
1
sudo apt - get update

Once the update is done, we’ll proceed on to downloading the required packages to compile OpenCV.

  • 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
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
1
sudo apt - get install build - essential cmake git libgtk2 . 0 - dev pkg - config libavcodec - dev libavformat - dev libswscale - 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)

sudo apt-get install python3.5-dev
1
sudo apt - get install python3 . 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 copy the file to the expected location. Run the following code below:

python3.5-config --includes
1
python3 . 5 - config -- includes

The output would look something similar below:

-I/usr/include/python3.5m -I/usr/include/x86_64-linux-gnu/python3.5m
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 copy the file from the current location to the expected location.

sudo cp /usr/include/x86_64-linux-gnu/python3.5m/pyconfig.h /usr/include/python3.5m/
1
sudo cp / usr / include / x86_64 - linux - gnu / python3 . 5m / pyconfig . h / usr / include / python3 . 5m /

?

Downloading the OpenCV Source Code

Make a new directory OpenCV-tmp in your Desktop, then change the directory into OpenCV-tmp . We will be using cloning the OpenCV source from Github into this folder.

mkdir OpenCV-tmp cd OpenCV-tmp git clone https://github.com/Itseez/opencv.git
1
2
3
mkdir OpenCV - tmp
cd OpenCV - tmp
git clone https : //github.com/Itseez/opencv.git

A opencv directory will be created in OpenCV-tmp . Rename opencv to opencv-3 .

?

Building

Before compiling the source, we have to generate the make file, so we will be using cmake.

Create a new directory build, which we will build the makefile in. Change the directory into it.

After that, run the cmake utility:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ../opencv-3
1
cmake - D CMAKE_BUILD_TYPE = RELEASE - D CMAKE_INSTALL_PREFIX = / usr / local . . / opencv - 3

If the command above does not work, you can try this alternative command: (Thanks to supermdguy for pointing this out!)

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
1
cmake - D CMAKE_BUILD_TYPE = RELEASE - D CMAKE_INSTALL_PREFIX = / usr / local . .

?

After the makefile is generated, we will build the installation files:

make -j $(nproc --all)
1
make - j $ ( nproc -- all )

This may take some time depending on your computer.

Side note:? We’ll split the make task via the -j argument, 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 the make command, the command would look like this:

make -j2
1
make - j2

?

Installing

Once the build is complete, we’ll install OpenCV by running the make file:

sudo make install
1
sudo make install

?

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 import cv2, and also check it’s version. If there are no errors, the output should look something like this:

>>> import cv2 >>> cv2.__version__ '3.1.0-dev'
1
2
3
>>> import cv2
>>> 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

sudo apt-get install python3-numpy
1
sudo apt - get install python3 - numpy

Matplotlib: 2D Plotting Library

sudo apt-get install python3-matplotlib
1
sudo apt - get install python3 - matplotlib

?

Troubleshooting

ImportError: No module named ‘cv2’

  • 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 be python3.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.

更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 成人免费视频观看视频 | 成人在线国产 | 国产欧美日韩亚洲精品区2345 | 天天摸天天做天天爽 | chengrenzaixian| 欧洲精品视频在线观看 | 欧洲午夜视频 | 五月综合激情 | 日韩成人一区二区 | 亚洲婷婷综合网 | 亚洲欧美日韩中文字幕在线一区 | 国产香蕉视频在线观看 | 超碰一区二区三区 | 亚洲欧美日韩精品中文乱码 | 91看片淫黄大片欧美看国产片 | 欧美日韩精品一区二区 | 国产精品久久久久久久免费大片 | 国产欧美一区二区久久 | 狠狠躁日日躁夜夜躁A片小说按摩 | 免费观看www | 国产在线精品一区二区三区 | 日韩在线免费看网站 | 无码国产精品成人午夜视频 | 蜜桃91麻豆| www.亚洲在线 | 成人免费看黄网站yyy456 | 男女交配视频网站 | 91视频8mav| 午夜影院在线免费观看视频 | 一级毛片免费不卡在线 | 天堂在线亚洲 | 天天天天做夜夜夜夜 | 国产精选91热在线观看 | 在线三级网址 | 免费成人高清 | 亚洲国产精品成 | 国产福利资源在线 | 日本不卡一区二区三区在线观看 | 国产精品美女久久久久久久网站 | 羞羞视频网站在线观看 | 国产精品999在线观看 |