Install Opencv+python support under centos6.5

Source: Internet
Author: User
Tags openldap

Python calls OpenCV: OpenCV compiles the shared library file, and Python loads and uses the shared library file as a module. The popular point is that when compiling OPENCV, the Python interface option is turned on, and the Cv2.so (under Linux) or Cv2.pyd (under Windows) is compiled to create the shared library file, which is used by the import Cv2 in Python code. In order to import it correctly, it is often necessary to put cv2.so in Python to find the path that can be found, or modify the PYTHONPATH environment variable to include the path cv2.so. In addition, in Python's OpenCV interface, images are represented using an NumPy array, so it is often necessary to install NumPy, scipy, and Matplotlib.

Step

Initialize the development environment:

Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-cpan pcre-devel sqlite-devel blas-devel lapack-devel

One

Installing python2.7

TAR-XF PYTHON-2.7.9.TAR.XZ
CD Python-2.7.9
./configure--prefix=/usr/local/-enable-shared Cflags=-fpic
Make
/usr/bin/install-c-M 644/tools/gdb/libpython.py python-gdb.py
Make Altinstall

Error handling:python:error while loading shared libraries:libpython2.7.so.1.0:cannot open Shared object file:no such file o R directory

    1. You can use the following methods to compile Python to solve this problem:
      ./configure--enable-shared--prefix=/usr/local/python27
      Make && make install
      2. Cp/usr/local/python27/lib/libpython2.7.so.1.0/usr/local/lib
      Cd/usr/local/lib
      Ln-s libpython2.7.so.1.0 libpython2.7.so
      3. Use the command Whereis libpython2.7.so.1.0 to get the following results
      Libpython2.7.so.1:/usr/local/lib/libpython2.7.so.1.0
      4. If Whereis has no results, or if there is an import error, you can try the following: (available)
      Add a new row to the/etc/ld.so.conf/usr/local/lib
      After saving, run
      /sbin/ldconfig
      /sbin/ldconfig-v

Because you need to use PIP to install the module later, so to install PIP: Specific reference: HTTP://CRFSZ.BLOG.51CTO.COM/7835882/1889350

Second,NumPy a library for large-scale matrix processing, this need to install or no way to compile OpenCV.

Unzip Numpy-1.11.1.zip
CD NUMPY-1.11.1/
Python setup.py Install

Third,CMake compile OpenCV use, also need to install manually.

wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
TAR-ZXVF cmake-2.8.10.2.tar.gz
CD cmake-2.8.10.2
./bootstrap
Gmake
Gmake Install
Cmake-version

Iv. installation of OPENVC

CD opencv-3.0.0-beta/
Create Build
mkdir Build
CD Build
Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.
Note: This step began to compile OpenCV, here will appear to download ippicv_linux_20151201.tgz such a thing, here is a hole, so the above steps should be error, so download this file online, copy it to your own directory
opencv-3.0.0-beta/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b/, overwrite the original tgz file.
Then recompile the cmake, which should not be an error. If no error is indicated:
Make
Make install
The installation is complete

PS: The installation process may be a little longer than 10-30 minutes, after the compilation is completed OPENCV installed in the specified/usr/local below the directory, the library file is installed under the/usr/local/lib, Python module installation location is:/ Usr/local/lib/python2.7/site-packages, execute ls /usr/local/lib/python2. 7/site-packages/ can see two files, one is cv2.so and the other is cv.py

To test the PY script:

#!/usr/bin/python#-*-coding:utf-8-*-import cv2
Image = Cv2.imread ("test.jpg") Print image
Cv2.imwrite ("test1.jpg", image)


650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/96/C5/wKioL1klPADAf6IHAAAT5Jlzoug358.png-wh_500x0-wm_ 3-wmp_4-s_3513523517.png "title=" 111.png "alt=" Wkiol1klpadaf6ihaaat5jlzoug358.png-wh_50 "/>

Six, install OpenCV climb of pit:

Importerror:no module named Skimage.feature

Pip Install Scikit-image


To be Continued ...






This article is from the "7835882" blog, please be sure to keep this source http://crfsz.blog.51cto.com/7835882/1929067

Install Opencv+python support under centos6.5

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.