先安装运行库
sudo apt-get update sudo apt-get upgrade sudo apt-get install -y build-essential sudo apt-get install -y cmake sudo apt-get install -y pkg-config sudo apt-get install -y libpng12-0 libpng12-dev libpng++-dev libpng3 sudo apt-get install -y libpnglite-dev sudo apt-get install -y zlib1g-dbg zlib1g zlib1g-dev sudo apt-get install -y pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools sudo apt-get install -y libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs sudo apt-get install -y ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev sudo apt-get install -y libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev sudo apt-get install -y libxine1-ffmpeg libxine-dev libxine1-bin sudo apt-get install -y libunicap2 libunicap2-dev sudo apt-get install -y libdc1394-22-dev libdc1394-22 libdc1394-utils sudo apt-get install -y swig sudo apt-get install -y libv4l-0 libv4l-dev sudo apt-get install -y python-numpy sudo apt-get install -y libpython2.6 python-dev python2.6-dev sudo apt-get install -y libgtk2.0-dev
下载源码并编译
wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/download opencv-2.4.9.zip unzip opencv-2.4.9.zip rm opencv-2.4.9.zip cd OpenCV-2.4.9 mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON .. make
花费长时间编译完成后 安装
sudo make install /usr/local/lib #没作用似乎
添加环境变量
sudo nano /etc/bash.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH #添加到上面的那个文件的末尾中
结束,开始愉快地设计吧,下面是个显示图片的例子opshow_demo.py:
import cv2 import numpy as np # read Images img = cv2.imread("./RubyLin.jpg") # show Image cv2.imshow("Image", img) cv2.waitKey (0) cv2.destroyAllWindows()
时间: 2024-11-06 13:09:55