当前位置:首页 » 编程语言 » pythonlibtiff

pythonlibtiff

发布时间: 2022-08-07 10:41:04

① 如何在树莓派2上搭建python opencv

安装 OpenCV 编译相关套件
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install pkg-config
sudo apt-get install libgtk2.0-dev libgtk2.0
sudo apt-get install zlib1g-dev
sudo apt-get install libpng-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libtiff-dev
sudo apt-get install libjasper-dev
sudo apt-get install libavcodec-dev
sudo apt-get install swig

下载OpenCV2.4.9 for linux 利用wget+档案的网址
cd
wget http //downloads sourceforge net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
(wget 和 http 之间为一个空格,2.4.9为版本,载下来的档案会放在资料夹pi中,档名为download)

压缩 并建立 编译暂存资料夹
cd
unzip opencv-2.4.9
cd opencv-2.4.9
mkdir release
cd release

编译及安装 OpenCV,Raspberry Pi 安装需要大约10小时
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo apt-get update
make
sudo make install

定义环境变数
sudo nano /etc/bash.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
加入后按Ctrl+O存档,按Enter后,再按Ctrl+X离开文件

确认opencv版本
pkg-config –modversion opencv

最后新增一个 sample code 执行编译与测试
nano showimage.c (新增一个.c档)

showimage.c 内容:
#include “highgui.h"
int main( int argc, char **argv ) {

IplImage *img = cvLoadImage( argv[1] );
//大写I小写pl 大写I小写 mage

cvNamedWindow(“ShowImage “, CV_WINDOW_AUTOSIZE);

cvShowImage(“ShowImage “, img);

cvWaitKey(0);

cvReleaseImage(&img);

cvDestroyWindow(“ShowImage “);

}

编译指令

g++ `pkg-config --cflags --libs opencv` showimage.c -o showimage

(注意:pkg 前以及 opencv 后的符号并非单引号,而是esc按键下方的 ` 符号,cflags 与 libs 前为双 -- 符号)

执行指令
./showimage /home/pi/opencv-2.4.9/samples/c/lena.jpg

执行完这行指令后,若有出现error: libopencv_calib3d cannot share object file
可先输入 sudo sudo idconfig - v
再执行
./showimage /home/pi/opencv-2.4.9/samples/c/lena.jpg

② 如何在OSX系统上安装Opencv3和Python2.7

setp1

安装CodeX,不解释,在AppStop中搜索安装即可

setp2

安装Homebrew

Homebrew即MacOSX上的apt-get

按照官网的安装方式,在terminal中输入下列命令即可完成安装

cd ~
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

setp3

使用Homebrew安装Python,注意:避免使用系统Python解释器作为我们自己的主解析器,尤其是在使用virtualenv和virtualenvwrapper的时候。安装命令:

$ brew install python

注意安装结束后会有下列提示,提示我们把/usr/local/opt/python/libexec/bin增加到环境变量中,此举正是为了我们在使用python时,使用的是用Homebrew安装的python而不是系统python。

If you wish to have this formula's python executable in your PATH then add

the following to ~/.bash_profile:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

这是重要的一步,请不要跳过。

setp4

安装 virtualenv 和 virtualenvwrapper

这两个工具是为了创建独立的python环境,不了解的朋友请自行Google

值得注意的是,这两个工具对于搭建opencv3.0+python2.7运行环境来说不是必须的,但是强烈建议安装,以保证python环境的干净,易于管理。

安装只需执行命令:

$ pip install virtualenv virtualenvwrapper

安装完成后,在~/.bash_profile文件中追加如下内容:

# Virtualenv/VirtualenvWrapper
source /usr/local/bin/virtualenvwrapper.sh

然后执行命令:

$ source ~/.bash_profile

至此,virtualenv 和virtualenvwrapper已经正确完成安装。我们可以使用如下命令创建一个独立的python环境:

$ mkvirtualenv cv

setp5

我们开始安装一些必须的python包,安装NumPy

We need to install NumPy since the OpenCV Python bindings represent images as multi-dimensional NumPy arrays

安装方式:

$ pip install numpy

注意:如果你使用了step4中的virtualenv创建python虚拟环境,则需要在您之前创建的虚拟环境中安装需要的python包

step6

之前的步骤,主要目的是建立和配置编译安装OpenCv的环境,从这一步开始,我们开始真正的工作。

首先,我们使用brew安装需要的开发者工具,例如CMake。

$ brew install cmake pkg-config

还有一些必要的图像I/O包,这些包可以使我们能够加载各种不同类型的图像文件例如JPEG,PNG,TIFF等。

$ brew install jpeg libpng libtiff openexr

And finally, let’s install libraries that are used to optimize various operations within OpenCV (if we so choose):

$ brew install eigen tbb

setp7

恭喜,截止目前系统已经搭建完成,我们开始着手编译和安装python支持的opencv。下载代码:

$ cd ~
$ git clone https://github.com/Itseez/opencv.git
$ cd opencv
$ git checkout 3.0.0

最后一个命令$ git checkout 3.0.0其中的3.0.0可以替换成你需要的版本号

之后下载opencv_contrib代码,这部分不是必须的,但是强烈建议同时下载,原因是opencv_contrib包含很多有用的功能,包括:

feature detection, local invariant descriptors (SIFT, SURF, etc.), text detection in natural images, line descriptors, and more

$ cd ~
$ git clone https://github.com/Itseez/opencv_contrib
$ cd opencv_contrib
$ git checkout 3.0.0

请确保checkout opencv_contrib的版本号要与上面checkout opencv的版本号相同

step8

创建一个bulid目录:

$ cd ~/opencv
$ mkdir build
$ cd build

使用CMake配置我们的构建:

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON2_PACKAGES_PATH=~/.virtualenvs/cv/lib/python2.7/site-packages \
-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/bin \
-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers \
-D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/moles ..

注意:在执行上述命令之前,请务必切换到之前建立的虚拟python环境cv:

workon cv

cmake命令执行完成后,需要关注它的总结输出,尤其是其中的Opencv moles部分:

-- OpenCV moles:
-- To be built: core flann imgproc ml objdetect photo video dnn imgcodecs shape videoio highgui superres ts features2d calib3d stitching videostab python2
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cubjdetect cuptflow cudastereo cudawarping cudev java python3 viz

-- Python 2:
-- Interpreter: /Users/zhuangyuan/.virtualenvs/cv/bin/python2.7 (ver 2.7.13)
-- Libraries: /usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/bin (ver 2.7.13)
-- numpy: /Users/zhuangyuan/.virtualenvs/cv/lib/python2.7/site-packages/numpy/core/include (ver 1.13.1)
-- packages path: /Users/zhuangyuan/.virtualenvs/cv/lib/python2.7/site-packages

如果python2部分的信息不完整,或者python2没有出现在OpenCV moles的To be built:后面,而是出现在Unvailable:后面,则说明Cmake没有正确完成,需要检查此步骤中Cmake命令的参数中的路径是否正确已经是否确实切换到了我们为opencv建立的虚拟python环境中。

再次提醒,此步骤中参数路径必须仔细核对,如果错误,后续的编译将无法成功

这时候可以开始编译了:

$ make -j4

这里的4是利用4核CPU全速并行编译,也可以不带-j4参数,或者把4修改成你的CPU核心数

编译完成后,进行安装:

make install

如果有错误,加上sudo再执行:

sudo make install

setp9

检查一下~/.virtualenvs/cv/lib/python2.7/site-packages/路径下可以看到cv2.so就说明安装成功了:

$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
$ ls -l cv2.so
-rwxr-xr-x 1 adrian staff 2013052 Jun 5 15:20 cv2.so

用一下吧:

(cv) promote:lib zhuangyuan$ python
Python 2.7.13 (default, Jul 18 2017, 09:17:00)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "right", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.3.0'

恭喜,OSX系统下opencv3 with python2.7环境搭建成功。

③ python 怎么安装pillow

1. 安装pip

[plain] view plain
sudo easy_install pip

pip 安装成功就可以直接安装pil或者pillow

2. 通过命令pip install pil

[plain] view plain
pip install Pil
Downloading/unpacking Pil
Could not find any downloads that satisfy the requirement Pil
Some externally hosted files were ignored (use --allow-external Pil to allow).
Cleaning up...
No distributions at all found for Pil
Storing debug log for failure in /Users/macbook/Library/Logs/pip.log

3. 所以就安装pillow

[plain] view plain
pip install --use-wheel Pillow
Downloading/unpacking Pillow
Downloading Pillow-2.4.0.zip (6.5MB): 5.0MB downloaded
Cleaning up...

弄了会别的回来发现还没有下载完,这叫一个慢呀,于是放弃
4. 通过Git下载源码地址https://github.com/python-imaging/Pillow

[plain] view plain
git clone https://github.com/python-imaging/Pillow.git

然后开始编译安装
4.1

[plain] view plain
python setup.py build_ext -i

编译完之后会提示运行测试例子,并且发现JPEG support not available

[plain] view plain
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX 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.

4.2 因为JPEG support not available,运行python selftest.py报告错误

[plain] view plain
1 tests of 57 failed.

于是只好卸载pillow

可以通过pip命令来卸载

[plain] view plain
pip uninstall pillow
sudo pip uninstall pillow
Password:
Uninstalling Pillow:
/Library/Python/2.7/site-packages/Pillow-2.4.0-py2.7-macosx-10.9-intel.egg
/usr/local/bin/pilconvert.py
/usr/local/bin/pildriver.py
/usr/local/bin/pilfile.py
/usr/local/bin/pilfont.py
/usr/local/bin/pilprint.py
Proceed (y/n)? y
Successfully uninstalled Pillow

成功之后需要安装libjpeg的支持

[plain] view plain
brew install libjpeg

安装成功之后重新编译pillow

[plain] view plain
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------

[plain] view plain
python selftest.py

[plain] view plain
--------------------------------------------------------------------
Pillow 2.4.0 TEST SUMMARY
--------------------------------------------------------------------
Python moles loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
Binary moles loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
*** JPEG 2000 support not installed
--- ZLIB (PNG/ZIP) support ok
*** LIBTIFF support not installed
--- FREETYPE2 support ok
*** LITTLECMS2 support not installed
*** WEBP support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.

最后执行安装

[plain] view plain
sudo python setup.py install

④ python2.70有没有libtiff板块

python中支持tiff文件处理的是libtiff模块中的TIFF类,第三方库
https://pypi.python.org/pypi/libtiff

⑤ 如何让opencv2.4和opencv3共存

OpenCV2和OpenCV3是目前主流的两个版本,有些程序使用OpenCV2,同时有些程序使用了OpenCV3,但是OpenCV2和OpenCV3的API和结构并不完全相同,比如在OpenCV3以后,SIFT和SURF之类的属性被移到了contrib中了,因此我们需要在一台计算机上同时安装并使用多个版本OpenCV。
二、 安装OpenCV2和OpenCV3
1. 安装依赖库
安装官方要求必选包:
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev1

安装官方可选包:
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev1

添加对OpenGL的支持所需要的包:
sudo apt-get install freeglut3-dev mesa-common-dev libgtkglext1 libgtkglext1-dev1

安装视频处理所需的包
sudo apt-get install checkinstall yasm libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg1

优化opencv的功能包
sudo apt-get install libatlas-base-dev gfortran qt5-default qtcreator1

2.下载源代码
下载OpenCV2.4.13.3源代码:
git clone https://github.com/opencv/opencv/tree/2.4.13.31

下载OpenCV3.3.0源代码:
git clone https://github.com/opencv/opencv/tree/3.3.01

下载OpenCV3.3.0_contrib源代码:
git clone https://github.com/opencv/opencv_contrib/tree/3.3.01

2.安装OpenCV2和OpenCV3 (无CUDA版本)
安装OpenCV2.4.13.3
$ cd opencv-2.4.13.3/
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/opencv2 \
-DWITH_TBB=ON \
-DWITH_IPP=ON \
-DWITH_QT=ON \
-DWITH_GTK=ON \
-DWITH_V4L=ON \
-DWITH_LIBV4L=ON \
-DWITH_OPENGL=ON \
-DWITH_FFMPEG=ON \
-DBUILD_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DINSTALL_C_EXAMPLES=ON \
-DPYTHON_EXECUTABLE=/usr/bin/python \
-DPYTHON_INCLUDE_DIR=/usr/include/python2.7 \
-DPYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python2.7 \
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so \
-DPYTHON_NUMPY_INCLUDE_DIRS=/usr/lib/python2.7/dist-packages/numpy/core/include/ ..
$ make -j $(($(nproc) + 1))
$ sudo make

安装OpenCV3.3.0:
首先将OpenCV3.3.0_contrib-3.3.0放到opencv-3.3.0目录下,然后执行下面命令。
$ cd opencv-3.3.0/
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/opencv3 \
-DOPENCV_EXTRA_MODULES_PATH=/home/bdd/opencv-3.3.0/opencv_contrib-3.3.0/moles \
-DWITH_TBB=ON \
-DWITH_QT=ON \
-DWITH_GTK=ON \
-DWITH_V4L=ON \
-DWITH_LIBV4L=ON \
-DWITH_OPENGL=ON \
-DWITH_FFMPEG=ON \
-DBUILD_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DINSTALL_C_EXAMPLES=ON \
-DPYTHON_EXECUTABLE=/usr/bin/python \
-DPYTHON_INCLUDE_DIR=/usr/include/python2.7 \
-DPYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python2.7 \
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so \
-DPYTHON_NUMPY_INCLUDE_DIRS=/usr/lib/python2.7/dist-packages/numpy/core/include/ ..
$ make -j $(($(nproc) + 1))
$ sudo make

其中OPENCV_EXTRA_MODULES_PATH:指定的OpenCV3.3.0_contrib路径

⑥ python pil 怎么安装

关于Pillow与PIL

PIL(Python Imaging Library)是Python一个强大方便的图像处理库,名气也比较大。不过只支持到Python 2.7。

PIL官方网站:http://www.pythonware.com/procts/pil/

Pillow是PIL的一个派生分支,但如今已经发展成为比PIL本身更具活力的图像处理库。目前最新版本是3.0.0。

Pillow的Github主页:https://github.com/python-pillow/Pillow
Pillow的文档(对应版本v3.0.0):https://pillow.readthedocs.org/en/latest/handbook/index.html
Pillow的文档中文翻译(对应版本v2.4.0):http://pillow-cn.readthedocs.org/en/latest/

Python 3.x 安装Pillow

给Python安装Pillow非常简单,使用pip或easy_install只要一行代码即可。

在命令行使用PIP安装:
pip install Pillow

或在命令行使用easy_install安装:
easy_install Pillow

安装完成后,使用from PIL import Image就引用使用库了。比如:
from PIL import Image
im = Image.open("bride.jpg")
im.rotate(45).show()

⑦ linux python libtiff库怎么安装

1. 先安装pip b) 获取上面网址的get-pip.py c) 运行python get-pip.py d) 安装完成之后 pip应用程序安装在C:\Python27\Scripts目录下,把这个路径加到path环境变量里面 e) cmd-》 输入pip -》可看到命令帮助,表示安装成功

⑧ 如何执行python第三方包windows exe格式

python第三方包的windows安装文件exe格式, 这上面有很多python第三方包的二进制安装文件,包括32位和64位的。下载安装就ok了!
这下面有很多python第三方包的二进制安装文件,包括32位和64位的。下载安装就ok了!

包括了mysqldb,ldap等。

Index by date:

fiona

scikit-image

netcdf4

mercurial

scikits.audiolab

numba

llvmpy

python-igraph

rpy2

numpy

opencv

zope.interface

sfepy

quantlib

gdal

imread

django

psychopy

cx_freeze

msgpack

regex

cellcognition

vigra

scikit-learn

pytables

h5py

blender-mathutils

htseq

bioformats

simplejson

pyzmq

mako

simpleitk

qimage2ndarray

ujson

vlfd

libsvm

liblinear

cgkit

scipy

distribute

noise

theano

pyalembic

openimageio

pyaudio

pymca

pyamg

pgmagick

lxml

steps

sqlalchemy

cffi

biopython

python-ldap

pycurl

nipy

nibabel

pygments

mahotas

py-postgresql

pyamf

planar

holopy

pyvisa

jcc

polymode

polygon

cython

pyropes

llist

shapely

vtk

pymongo

libpython

meshpy

pandas

umysql

epydoc

coverage

cheetah

pyrxp

pybluez

pythonmagick

bsdiff4

pymssql

pymol

boost.python

orange

requests

pywcs

python-sundials

pymix

pyminuit

pylzma

pyicu

assimulo

basemap

pygraphviz

pyproj

mpi4py

spyder

pytz

pyfits

mysql-python

pygame

pycparser

twisted

pil

qutip

openexr

nipype

python-snappy

visvis

docutils

pyhdf

pyqwt

kivy

scikits.umfpack

psycopg

ets

guiqwt

veusz

pyqt

pyside

dpmix

py-fcm

scikits.hydroclimpy

smc.freeimage

scipy-stack

ipython

nose

mxbase

numexpr

pyyaml

ode

virtualenv

aspell_python

tornado

pywavelets

bottleneck

networkx

statsmodels

pylibdeconv

pyhook

lmfit

slycot

ndimage

scikits.scattpy

cvxopt

pymc

pysparse

scikits.odes

matplotlib

vpython

pycuda

pyopencl

pymvpa

pythonnet

cld

mod_wsgi

nltk

python-levenshtein

rtree

pywin32

scientificpython

sympy

thrift

pyopengl-accelerate

mdp

pyopengl

gmpy

reportlab

natgrid

scikits.vectorplot

pyreadline

milk

blosc

pycogent

pip

gevent

scons

carray

python-dateutil

jinja2

markupsafe

jsonlib

pysfml

fonttools

silvercity

console

python-cjson

pycluster

cdecimal

pytst

autopy

sendkeys

ceodbc

fipy

psutil

pyephem

pycifrw

blist

line_profiler

pydbg

bitarray

pyglet

python-lzo

faulthandler

delny

pyexiv2

ilastik

twainmole

scitools

pyspharm

casuarius

pyodbc

greenlet

nitime

pylibtiff

mmtk

pycairo

pysqlite

curses

videocapture

bazaar

nlopt

trfit

libsbml

oursql

sphinx

cellprofiler

py2exe

re2

liblas

cgal-python

pymedia

ffnet

pyfftw

libxml-python

pyfltk

pymex

pymatlab

zodb3

mmlib

pygtk

pyserial

babel

scikits.ann

scikits.delaunay

numeric

pulp

nmoldyn

pymutt

iocbio

jpype

wxpython

pybox2d

dipy

mmseg

pynifti

scikits.samplerate

scikits.timeseries

vitables

quickfix

⑨ python 3.6中如何引用libtiff包

先要安装pip install numpy
再安装pip install libtiff
不过需要编译环境,安装好后就可以引用了

热点内容
有哪些低配置游戏像王者荣耀 发布:2024-05-03 22:27:11 浏览:243
gp数据库库 发布:2024-05-03 22:12:43 浏览:873
压缩点点 发布:2024-05-03 22:12:33 浏览:380
有哪些编程比赛 发布:2024-05-03 22:03:45 浏览:263
怎么根据配置调整游戏分辨率 发布:2024-05-03 22:02:50 浏览:77
小鸟酱265g资源密码多少啊 发布:2024-05-03 21:32:08 浏览:653
三国战纪游戏华为帐号密码是多少 发布:2024-05-03 21:22:54 浏览:950
变频压缩机启动 发布:2024-05-03 21:17:06 浏览:436
建立云存储 发布:2024-05-03 21:04:03 浏览:76
socket编程php 发布:2024-05-03 20:12:50 浏览:208