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

  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 plain copy print ?
  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/include
ln -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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
抱歉,我无法回答你提供的网址链接的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [人脸检测实战高级:使用 OpenCV、Python 和 dlib 完成眨眼检测.zip](https://download.csdn.net/download/hhhhhhhhhhwwwwwwwwww/57821490)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [物体检测实战:使用OpenCV内置方法实现行人检测.zip](https://download.csdn.net/download/hhhhhhhhhhwwwwwwwwww/67160136)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [QGIS二次开发:显示多个图层,编程环境为QGIS3.28和VS2017](https://download.csdn.net/download/KK_2018/88217562)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值