OpenCV python Installation

Source: Internet
Author: User


0. Run the import cv test and find that the opencv module is not installed.


First, the development environment is set up in the windows xp environment.
The three conditions must be ensured during the construction process:


1. python needs to install the python-numpy module, otherwise it will not be able to run even if the cv module is found. The error "ImportError: numpy. core. multiarray failed to import" will also occur.
When installing this module, you must ensure that the python version is consistent with the numpy version. For example, the current numpy version supports python2.6 at the maximum, therefore, if your python version is not 2.6, this module cannot be installed.
-------------------------------
Http://www.numpy.org/


Ubuntu & Debian
Sudo apt-get install python-numpy python-scipy python-matplotlib ipython-notebook python-pandas python-sympy python-nose


Download windows
Http://www.lfd.uci.edu /~ Gohlke/pythonlibs/
Numpy-MKL-1.7.1.win32-py2.7.exe (win32 bit)
Numpy-MKL-1.7.1.win-amd64-py2.7.exe (win 64-bit)
------------------------------------
The new version 1.7.1 is used above.


2. The python version must be consistent with the OpenCV version. Otherwise, an error occurs when importing the cv module.
For example, if you have installed Python 2.0, OpenCV needs to Install Version 2.2.


-------------------------
The OpenCV-2.3.1-win-superpack.exe is downloaded.
124 MB, in size.
This file is different from the directory structure of the OpenCV-2.4.6.0.exe file after decompression. I did not find the file location 2.4.6.
Use 2.3.1 temporarily.
\ Opencv231 \ opencv \ build \ python \ 2.7 directory:
Cv2.pyd
Cv. py
Copy two files to: D: \ Python27 \ Lib \ site-packages \
-------------------------
The 2.4.6 file is:
Opencv \ build \ python \ 2.7 \
Cv2.pyd
----------------


The problem that the relevant modules cannot be found when executing the import cv is described on the OpenCV Website:


"Python 2.6 bindings for OpenCV are supported ded within the package, but not installed. you can copy the subdirectory opencv/Python2.6/Lib/site-packages into the respective directory of the Python installation. this procedure will be automatically in the next OpenCV update."
That is, we only need to copy the files in Python2.6/Lib/site-packages under the OpenCV installation directory to the Lib/site-packages under the Python2.6 installation directory.


Using the above method, the development environment of Python and OpenCV is successfully matched!


-------------
Enter here
Opencv231 \ opencv \ samples \ python

There is a drawing. py file to run.

----------

Reference address:

Http://blog.csdn.net/mengyafei43/article/details/10338531

And so on.

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.