opencv 安装 以及PIL 安装主要参考http://blog.csdn.net/sunlylorn/article/details/7907698 部分软件包过老需要自己手动下载

来源:互联网 发布:mac彻底删除音乐创作 编辑:程序博客网 时间:2024/06/08 07:13
  1. mkdir release
  2. cd  release
  3. cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..  
  4. make

  5. sudo make install  
  6.   
  7. export LD_LIBRARY_PATH=~/soft/opencv/release/lib:$LD_LIBRARY_PATH  
  8.   
  9. sudo ldconfig  
  10.   
  11. pkg-config opencv –libs  

三、测试一下

[plain] view plaincopyprint?
  1. cd../sample/cpp/  
  2.   
  3. g++ drawing.cpp -o drawing `pkg-config opencv --libs --cflags`  
  4.   
  5. ./draw
  6. 这个测试我没有出来于是似的另一个
  7. cd ~/samps/c
  8.  chmod +x build_all.sh

  9. ./build_all.sh

  10. samples/c

    $chmod

    +x

    build_all.sh

    $./build_all.s

./facedetectcascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg















PIL 安装主要参考http://vososo.com/vo/519


PIL是python理想的图片处理module,但是想要良好的支持各种图片,还需要检查一下几步,否则会提示:IOError: decoder jpeg not available之类的。

第一步:安装zlib png freetype jpeg

install zlib 
下载zlib,(zlib.net已墙,可以去SF.net),

url:http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download?use_mirror=superb-dca2

shell:

$ tar -xvzf zlib-1.2.5.tar.gz
$ cd zlib-1.2.5
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
install png 用到再安装就可以了
shell:
$ wget ftp.simplesystems.org/pub/libpng/png/src/libpng16/(这个需要自己下)

网址ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/

$ tar -xvzf libpng-1.5.6.tar.gz
$ cd libpng-1.5.6
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

install freetype
shell:

$ wget http://nchc.dl.sourceforge.net/project/freetype/freetype2/2.4.7/freetype-2.4.7.tar.gz
$ tar -jxf freetype-2.4.7.tar.gz
$ cd freetype-2.4.7/
$ ./configure --prefix=/usr/local
$ make
$ make install

install jpeg
shell:

$ wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
$ tar -xvzf jpegsrc.v8c.tar.gz
$ cd jpeg-8c/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

第三步:安装PIL(Python Imaging Library )

 

shell 写道 我装的是1.6

pil下载: http://effbot.org/downloads/Imaging-1.1.6.tar.gz

$ wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
$ tar -xvzf Imaging-1.1.6.tar.gz
$ cd Imaging-1.1.6/
修改setup.py文件:
$ vim nano setup.py

修改如下:
JPEG_ROOT = "/usr/local/lib"
ZLIB_ROOT = "/usr/local/lib"
FREETYPE_ROOT = "/usr/local/lib"

检查是否支持:

$ python setup.py build_ext -i
running build_ext



这个地方我又出现了点要蛾子,因为最新的freetapy全都更新到2 了所以加上这两句话再去试试上面的是否支持

cd /usr/includeln -s freetype2 freetype



--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available -----------------------> OK!
--- ZLIB (PNG/ZIP) support available -----------------------> OK!
--- FREETYPE2 support available -----------------------> OK!
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

To check the build, run the selftest.py script.

正式安装:

$ python setup.py build
$ sudo python setup.py install

最后一步:验证

 

Python代码

#!/usr/bin/env python
# -*- coding:utf-8 -*-


import Image
picPath = './Images/lena.jpg'


im = Image.open(picPath)
print im.getbbox()

输出结果图片尺寸:
(0, 0, 600, 715)

yeah,搞定!

 

 

报错:

python2.6 seccode.py
Traceback (most recent call last):
File "seccode.py", line 81, in <module>
frame = getframe('test.gif')
File "seccode.py", line 40, in getframe
im = Image.open(fname)
File "/data1/python2.6/lib/python2.6/site-packages/PIL/Image.py", line 1901, in open
return factory(fp, filename)
File "/data1/python2.6/lib/python2.6/site-packages/PIL/ImageFile.py", line 82, in __init__
self._open()
File "/data1/python2.6/lib/python2.6/site-packages/PIL/GifImagePlugin.py", line 97, in _open
self.seek(0) # get ready to read first frame
File "/data1/python2.6/lib/python2.6/site-packages/PIL/GifImagePlugin.py", line 152, in seek
self.dispose = Image.core.fill("P", self.size,
File "/data1/python2.6/lib/python2.6/site-packages/PIL/Image.py", line 36, in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed

处理方法:命令行下执行,因为jpeg的解析so文件在/usr/local/lib下面,所以要把动态库的链接路径加到环境变量里就OK了

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

#vi /etc/profile
在里面加入:
export PATH="$PATH:/opt/au1200_rm/build_tools/bin"























0 0
原创粉丝点击