Python + OpenCV2 Series: 1-Configuration

Source: Internet
Author: User

Python+opencv2+eclipse+windos 8.1 (32bits): The initial goal is to do image processing, OPENCV strong community support, let me want to go from MATLAB to OPENCV framework for the experiment, And the pros and cons of Python and Eclipse are not listed. Here is a summary of the https://www.python.org/about/home page of Python is powerful ... and fast;
Plays well with others;
Runs everywhere;
is friendly & easy to learn;
Is Open.

1. Why

Eclipse:there is a lot of IDE's Python and Python itself have a simple IDE (shell) called IDLE. I use Eclipse because I has the experence of this open souce, powerful IDE, and I think other IDEs is OK too.

Opencv2:it is the second verison of OpenCV, and it includs more C + + support and Pyhont support.

2. Install

Python Install

Python is like a framework that can contain many class libraries, and Python's coding style is more concise and efficient. But the Python version works with the OPENCV2 version. OpenCV is now out to 3. x version, but with the stability in mind, there are still a lot of people with the 2.4 version. So, use Python 2.7 and opencv2.4 for development.

The following connection is a simplified version of the PYTHON+OPENCV documentation

Link:http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_table_of_contents_setup/py_table_of_contents_ Setup.html#py-table-of-content-setup

link:http://docs.opencv.org/trunk/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.html# Install-opencv-python-in-windows

Installing OpenCV from prebuilt binaries
    1. below Python packages is to is downloaded and installed to their default Locati ONS.

      1.1. python-2.7.x.

      1.2. numpy.

      1.3. matplotlib  ( matplotlib is optional, but recommended since we use it a lot in our tutorials ).

    2. install all packages into their default locations. Python would be installed to  c:/python27/.

    3. after installation, open Python IDLE. ENTER import numpy  and Make sure Numpy is working fine.

    4. download latest OpenCV release From sourceforge Site and Double-click to extract it.

    1. Goto opencv/build/python/2.7 folder.

    2. Copy cv2.pyd to c:/python27/lib/site-packages.

    3. Open Python IDLE and type following codes in Python terminal.

      Cv2cv2.  __version__  

If The results is printed out without any errors, congratulations!!! You have installed Opencv-python successfully.

Note:

1. The last Test code above indicates that PYTHON+OPENCV's development environment has been installed, and Python can be used for OPENCV development. However, I chose to use Eclipse as the IDE, explained later.

2.Numpy is an important class of Python library, mainly about numerical, matrix calculation. Example processing, is for the processing of the matrix, then this class library is very important. Child matplotlib is a common drawing class library. This further illustrates that Python is actually a framework, an empty shelf, and that any functionality needs to be supported by another class library, and that other libraries need to be integrated into Python.

Eclipse IDE Install

In Python's installation directory There is a simplified version of the IDE that Python comes with, but it's also full-featured, but since I'm new to Python, I decided to develop it with more powerful eclipse, and I'm more familiar with eclipse.

Method 1: There is already an eclipse version with the Python plugin (Pydev), called Liclipse. This should be more convenient, but I didn't try, because I didn't know about it when I installed it.

Reference link:http://www.liclipse.com/

Reference link:http://pydev.org/

Method 2: Use Eclipse to configure the plugin yourself

Reference link:http://www.cnblogs.com/realh/archive/2010/10/04/1841907.html

1. Preparatory work:

Download the 32-bit JDK6 Java development Package I don't want to do this, but eclipse relies on him, no way.

Download the 32-bit eclipse here Note to download the Java EE version of J2SE, there is a problem when downloading the Pydev plugin.

Download Python 2.x

2. Installing JDK6

JDK installation is easy, always click Next

Most tutorials say that you need to set environment variables when you finish installing the JDK.
But now the IDE is no longer using environment variables to find the path to the JDK, so this does not have to be set.

3. Install Eclipse and Python
Eclipse is green software, find a place to unzip it OK
Not to mention the Python installation.

4. Install the Pydev plugin for Eclipse
Enable Eclipse ———— If the previous steps are correct, then eclipse should be able to start normally.
The first launch will allow you to select a workspace, press the default settings, tick the no reminder again.

From the Help menu, select Install New software,
Choose the Add button, Name:pydev (this random), Location:http://pydev.org/updates (PyDev update address), OK

Choose Pydev under Pydev for Eclipse, do not choose anything else, or rely on check that off.

Click Next, install Next
The middle will ask whether you trust Aptana, Pydev or whatever, trust will be.

Finally restart Eclipse

5. Configuring the Pydev Plugin
Select Preference in the Window menu,

1, pydev->interpreter-python,new a Python interpreter, fill in the Interpreter name and path, the path to select the corresponding Python.exe.

Python 3.x is required in the following steps, Python 2 is optional. I'm more used to Unicode, so I set it here once.

2, General->editors->text editors->spelling,encoding changed into Other:utf-8

3, General->workspace,text file encoding changed to Other:utf-8

4, find the installation directory of \plugins\org.python.pydev.debug_x.x.x.yyyymmddhh\pysrc\pydevd.py,
920 lines of encoding = Non changed to encoding = "UTF-8", save This configuration file I did not find

At this point, the Pydev configuration is complete.

6. Under test

File->new->project, choose Pydev under the Pydev project,grammer and interpreter Select the appropriate version, Finish.

Right-click on the PyDev Package Explorer project, New->pydev Module, write a name, Finish.

Then write a few lines of code, Run

In the dialog box that pops up, select Python Run,

Ok

Note 1: This shows that the JDK and eclispse seem to be 32-bit or 64-bit, otherwise they may encounter problems. The first time I tried it was the combination of the 64-bit jdk+32 eclipse, and it came across and http://superuser.com/questions/186001/ Eclipse-failed-to-load-the-jni-shared-library the same problem, so decisively changed 32 jdk.

Note 2: I want to do the development of Gae, so selected version 2.6.6, generally choose the latest version can be.

Note 3:pydev Mylyn integration (optional): This depends on the PyDev for Eclipse, you have to install the latter can be installed.
PyDev Django Templates Editor: This requires Aptana Studio 3.

Reference Documentation:
eclipse-failed to load the JNI shared library
Introducing the IDE and other development tools common to Python programmers
Using Eclipse and Pydev to develop Python
Install Python 3.1, Pydev 1.4.7 eclipse process

I have a problem: is the source code of my Python help document is garbled, this has not been resolved, if there is understand people please point out the reason.

Python + OpenCV2 Series: 1-Configuration

Related Article

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.