ubuntu14.04 python2.7 Installation Configuration OpenCV3.0

Source: Internet
Author: User

Environment: ubuntu14.04 python2.7

Content: Installing and configuring OpenCV3.0

Today, according to the steps of the OPENCV online installation OpenCV But, after the Python prompt "No module named Cv2"

First, the steps to install OPENCV:

Installation steps of OPENCV official website: http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation

1. Download opencv:https://codeload.github.com/itseez/opencv/zip/3.0.0

2. Unzip:

1 tar -xzvf opencv3. 0.0

3. Install the required packages for OPENCV:

  • GCC 4.4.x or later
  • CMake 2.6 or higher
  • Git
  • gtk+2.x or higher, including headers (Libgtk2.0-dev)
  • Pkg-config
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (Python-dev, python-numpy)
  • FFmpeg or LIBAV development Packages:libavcodec-dev, Libavformat-dev, Libswscale-dev
  • [Optional] libtbb2 Libtbb-dev
  • [Optional] libdc1394 2.x
  • [optional] Libjpeg-dev, Libpng-dev, Libtiff-dev, Libjasper-dev, Libdc1394-22-dev
    1 sudo Install build-essential2sudoinstall cmake git libgtk2. 0 pkg-config libavcodec-dev libavformat-dev libswscale-Dev3sudoinstall python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22
          C13>-dev

4. In the extracted OPCV directory, build a release directory, and then use CMake to compile the source code. (Use the official website method the last OpenCV installation directory is the release this directory)

1 cd ~/OpenCV2mkdir  release3CD release4 Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.  //There are two points behind here that can't be omitted, but what do you mean I don't understand

5. Then install

1 sudo make 2 sudo  Make Install

At this point, the installation is complete.

Then, after the installation is complete, Python references the OpenCV "No module named Cv2" issue.

My main reference here is this blog post: http://pinkyjie.com/2010/10/19/ubuntu-opencv-python/

Here is a hint to the following place, the file "Cv.so" will appear during make, which is the key file to connect OpenCV and Python.

the "no module named Cv2" occurs because Python cannot find the cv.so file we just mentioned, we enter the path/usr/local/lib/ python2.7 found two folders, one is Dist-package, one is Site-package,python by default only in the former search, and we generated the cv.so file in our installation directory. /.. /opencv3.0.0/release "(Remember this directory, which is the directory we just built in the installation process, if you do not have this file in the installation directory, then the previous make step problem, may need to go through the entire installation process), All we need to do is simply move it to the Dist-package folder.

Finally, my test program:

1 Import Cv2 2 3 img = cv2.imread ('lena.jpg')4 cv2.imshow ('  Image', img)5 k = cv2.waitkey (0)6

ubuntu14.04 python2.7 Installation Configuration OpenCV3.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.