Ⅰ 人脸识别为什么用python开发

可以使用OpenCV,OpenCV的人脸检测功能在一般场合还是不错的。而ubuntu正好提供了-opencv这个包,用它可以方便地实现人脸检测的代码

写代码之前应该先安装python-opencv:

#!/usr/bin/python
#-*-coding:UTF-8-*-

#face_detect.py

#FaceDetectionusingOpenCV.Basedonsamplecodefrom:
#http://python.pastebin.com/m76db1d6b

#Usage:pythonface_detect.py<image_file>

importsys,os
fromopencv.cvimport*
fromopencv.highguiimport*
fromPILimportImage,ImageDraw
frommathimportsqrt

defdetectObjects(image):
""""""
grayscale=cvCreateImage(cvSize(image.width,image.height),8,1)
cvCvtColor(image,grayscale,CV_BGR2GRAY)

storage=cvCreateMemStorage(0)
cvClearMemStorage(storage)
cvEqualizeHist(grayscale,grayscale)

cascade=cvLoadHaarClassifierCascade(
'/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml',
cvSize(1,1))
faces=cvHaarDetectObjects(grayscale,cascade,storage,1.1,2,
CV_HAAR_DO_CANNY_PRUNING,cvSize(20,20))

result=[]
forfinfaces:
result.append((f.x,f.y,f.x+f.width,f.y+f.height))

returnresult

defgrayscale(r,g,b):
returnint(r*.3+g*.59+b*.11)

defprocess(infile,outfile):

image=cvLoadImage(infile);
ifimage:
faces=detectObjects(image)

im=Image.open(infile)

iffaces:
draw=ImageDraw.Draw(im)
forfinfaces:
draw.rectangle(f,outline=(255,0,255))

im.save(outfile,"JPEG",quality=100)
else:
print"Error:cannotdetectfaceson%s"%infile

if__name__=="__main__":
process('input.jpg','output.jpg')

Ⅱ linux上安装python3.4.4,执行./configure的时候报错,怎么解决

config.log的内容:
This file contains any messages proced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by python configure 3.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = hbttdb1
uname -m = x86_64
uname -r = 2.6.32-279.el6.x86_64
uname -s = Linux
uname -v = #1 SMP Wed Jun 13 18:24:36 EDT 2012
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = x86_64
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /usr/lib64/qt-3.3/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /sbin
PATH: /bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /root/bin
PATH: /data/oracle/app/oracle/proct/11.2.0/bin
PATH: .

## ----------- ##
## Core tests. ##
## ----------- ##
configure:2894: checking build system type
configure:2908: result: x86_64-unknown-linux-gnu
configure:2928: checking host system type
configure:2941: result: x86_64-unknown-linux-gnu
configure:3053: checking for --enable-universalsdk
configure:3100: result: no
configure:3123: checking for --with-universal-archs
configure:3138: result: no
configure:3288: checking MACHDEP
configure:3494: result: linux
configure:3518: checking for --without-gcc
configure:3541: result: no
configure:3665: checking for gcc
configure:3681: found /usr/bin/gcc
configure:3692: result: gcc
configure:3921: checking for C compiler version
configure:3930: gcc --version >&5
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for ing conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:3941: $? = 0
configure:3930: gcc -v >&5
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=Red Hat Bugzilla Main Page --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
configure:3941: $? = 0
configure:3930: gcc -V >&5
gcc: '-V' option must have argument
configure:3941: $? = 1
configure:3930: gcc -qversion >&5
gcc: unrecognized option '-qversion'
gcc: no input files
configure:3941: $? = 1
configure:3961: checking whether the C compiler works
configure:3983: gcc conftest.c >&5
configure:3987: $? = 0
configure:4035: result: yes
configure:4038: checking for C compiler default output file name
configure:4040: result: a.out
configure:4046: checking for suffix of executables
configure:4053: gcc -o conftest conftest.c >&5
configure:4057: $? = 0
configure:4079: result:
configure:4101: checking whether we are cross compiling
configure:4109: gcc -o conftest conftest.c >&5
In file included from /usr/include/stdio.h:75,
from conftest.c:11:
/usr/include/libio.h:332: error: expected specifier-qualifier-list before 'size_t'
/usr/include/libio.h:364: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/libio.h:373: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/libio.h:495: error: expected '=', ',', ';', 'asm' or '__attribute__' before '_IO_sgetn'
In file included from conftest.c:11:
/usr/include/stdio.h:318: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:324: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:336: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:343: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:385: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:387: error: format string argument not a string type
/usr/include/stdio.h:389: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:391: error: format string argument not a string type
/usr/include/stdio.h:661: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:664: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:674: error: expected declaration specifiers or '...' before 'size_t'
/usr/include/stdio.h:704: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fread'
/usr/include/stdio.h:710: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fwrite'
/usr/include/stdio.h:732: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fread_unlocked'
/usr/include/stdio.h:734: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fwrite_unlocked'
configure:4113: $? = 1
configure:4120: ./conftest
./configure: line 4122: ./conftest: No such file or directory
configure:4124: $? = 127
configure:4131: error: in `/root/msk/py_workspace/py_setup/Python-3.4.4':
configure:4133: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_build=x86_64-unknown-linux-gnu
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_MACHDEP_set=
ac_cv_env_MACHDEP_value=
ac_cv_env_PKG_CONFIG_LIBDIR_set=
ac_cv_env_PKG_CONFIG_LIBDIR_value=
ac_cv_env_PKG_CONFIG_PATH_set=
ac_cv_env_PKG_CONFIG_PATH_value=
ac_cv_env_PKG_CONFIG_set=
ac_cv_env_PKG_CONFIG_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=x86_64-unknown-linux-gnu
ac_cv_prog_ac_ct_CC=gcc
## ----------------- ##
## Output variables. ##
## ----------------- ##
ABIFLAGS=''
AR=''
ARCH_RUN_32BIT=''
ARFLAGS=''
ASDLGEN=''
BASECFLAGS=''
BASECPPFLAGS=''
BLDLIBRARY=''
BLDSHARED=''
BUILDEXEEXT=''
CC='gcc'
CCSHARED=''
CFLAGS=''
CFLAGSFORSHARED=''
CFLAGS_NODIST=''
CONFIGURE_MACOSX_DEPLOYMENT_TARGET=''
CONFIG_ARGS=''
CPP=''
CPPFLAGS=''
CXX=''
DEFS=''
DLINCLDIR=''
DLLLIBRARY=''
DYNLOADFILE=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
ENSUREPIP=''
EXEEXT=''
EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
EXT_SUFFIX=''
FRAMEWORKALTINSTALLFIRST=''
FRAMEWORKALTINSTALLLAST=''
FRAMEWORKINSTALLAPPSPREFIX=''
FRAMEWORKINSTALLFIRST=''
FRAMEWORKINSTALLLAST=''
FRAMEWORKPYTHONW=''
FRAMEWORKUNIXTOOLSPREFIX='/usr/local'
GNULD=''
GREP=''
HAS_HG='no-repository'
HAVE_GETHOSTBYNAME=''
HAVE_GETHOSTBYNAME_R=''
HAVE_GETHOSTBYNAME_R_3_ARG=''
HAVE_GETHOSTBYNAME_R_5_ARG=''
HAVE_GETHOSTBYNAME_R_6_ARG=''
HGBRANCH=''
HGTAG=''
HGVERSION=''
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
INSTSONAME=''
LDCXXSHARED=''
LDFLAGS=''
LDLAST=''
LDLIBRARY=''
LDLIBRARYDIR=''
LDSHARED=''
LDVERSION=''
LIBC=''
LIBFFI_INCLUDEDIR=''
LIBM=''
LIBOBJS=''
LIBPL=''
LIBRARY=''
LIBS=''
LIBTOOL_CRUFT=''
LINKCC=''
LINKFORSHARED=''
LIPO_32BIT_FLAGS=''
LN=''
LTLIBOBJS=''
MACHDEP='linux'
MACHDEP_OBJS=''
MAINCC=''
MKDIR_P=''
MULTIARCH=''
NO_AS_NEEDED=''
OBJEXT=''
OPT=''
OTHER_LIBTOOL_OPT=''
PACKAGE_BUGREPORT='List of issues - Python tracker'
PACKAGE_NAME='python'
PACKAGE_STRING='python 3.4'
PACKAGE_TARNAME='python'
PACKAGE_URL=''
PACKAGE_VERSION='3.4'
PATH_SEPARATOR=':'
PKG_CONFIG=''
PKG_CONFIG_LIBDIR=''
PKG_CONFIG_PATH=''
PLATDIR='plat-linux'
PY3LIBRARY=''
PYTHON=''
PYTHONFRAMEWORK=''
PYTHONFRAMEWORKDIR='no-framework'
PYTHONFRAMEWORKIDENTIFIER='org.python.python'
PYTHONFRAMEWORKINSTALLDIR=''
PYTHONFRAMEWORKPREFIX=''
PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
PY_ENABLE_SHARED=''
RANLIB=''
READELF=''
RUNSHARED=''
SGI_ABI=''
SHELL='/bin/sh'
SHLIBS=''
SHLIB_SUFFIX=''
SIGNAL_OBJS=''
SOABI=''
SOVERSION='1.0'
SRCDIRS=''
TCLTK_INCLUDES=''
TCLTK_LIBS=''
THREADHEADERS=''
THREADOBJ=''
TRUE=''
UNIVERSALSDK=''
UNIVERSAL_ARCH_FLAGS=''
USE_INLINE=''
USE_SIGNAL_MODULE=''
USE_THREAD_MODULE=''
VERSION='3.4'
_PYTHON_HOST_PLATFORM=''
ac_ct_AR=''
ac_ct_CC='gcc'
ac_ct_CXX=''
ac_ct_READELF=''
bindir='${exec_prefix}/bin'
build='x86_64-unknown-linux-gnu'
build_alias=''
build_cpu='x86_64'
build_os='linux-gnu'
build_vendor='unknown'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host='x86_64-unknown-linux-gnu'
host_alias=''
host_cpu='x86_64'
host_os='linux-gnu'
host_vendor='unknown'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _BSD_TYPES 1
#define _DARWIN_C_SOURCE 1
#define _XOPEN_SOURCE 700
#define _XOPEN_SOURCE_EXTENDED 1
#define _POSIX_C_SOURCE 200809L
configure: exit 1

Ⅲ 这种图片可以用Python自动识别吗

Python图片文本识别使用的工具是PIL和pytesser。因为他们使用到很多的python库文件,为了避免一个个工具的安装,建议使用pythonxy
pytesser是OCR开源项目的一个模块,在Python中导入这个模块即可将图片中的文字转换成文本。pytesser调用了tesseract。当在Python中调用pytesser模块时,pytesser又用tesseract识别图片中的文字。pytesser的使用步骤如下:

首先,安装Python2.7版本,这个版本比较稳定,建议使用这个版本。
其次,安装pythoncv。
然后,安装PIL工具,pytesser的使用需要PIL库的支持。
接着下载pytesser
最后,将pytesser解压,这个是免安装的,可以将解压后的文件cut到Python安装目录的Lib\site-packages下直接使用,比如我的安装目录是:C:\Python27\Lib\site-packages,同时把这个目录添加到环境变量之中。
完成以上步骤之后,就可以编写图片文本识别的Python脚本了。参考脚本如下:
from pytesser import *
import ImageEnhance
image = Image.open('D:\\workspace\\python\\5.png')
#使用ImageEnhance可以增强图片的识别率
enhancer = ImageEnhance.Contrast(image)
image_enhancer = enhancer.enhance(4)
print image_to_string(image_enhancer)

tesseract是谷歌的一个对图片进行识别的开源框架,免费使用,现在已经支持中文,而且识别率非常高,这里简要来个helloworld级别的认识
下载之后进行安装,不再演示。
在tesseract目录下,有个tesseract.exe文件,主要调用这个执行文件,用cmd运行到这个目录下,在这个目录下同时放置一张需要识别的图片,这里是123.jpg
然后运行:tesseract 123.jpg result
会把123.jpg自动识别并转换为txt文件到result.txt
但是此时中文识别不好
然后找到tessdata目录,把eng.traineddata替换为chi_sim.traineddata,并且把chi_sim.traineddata重命名为eng.traineddata
ok,现在中文识别基本达到90%以上了

Ⅳ opencv和python下,运行对图片的读取程序时出现的问题!!!

1、需要用到其复他模块制的函数,如:

for i in range(20) #循环次数

image=cv2.imread("D:\picture\%d.jpg"%(i))#路径自己选择。

2、可以先升级你的pip,另外看看你的版本是否匹配,包括py版本和32位64位。

3、关于python下使用opencv读取图像。首先需要导入opencv包,上面说的那个Ipython并没有opencv包,所以想使用的请先正确导入opencv包再说,至于怎么导入,先下载个opencv包,里面有关于python的opencv包。
以下照片是关于Ipython的运行界面:

Ⅳ ubutun下opencv3.0+python 2.7安装完毕,打开python需要用什么命令吗

步骤一: 安装依赖. 不管你是用 Python 2.7+ 还是 Python 3+, 你都需要用 apt-get 来安装 安装Open CV 所需要的包,库等依赖.
步骤二: 编译 Python 2.7+ 版的 Open CV. 如果你准备用 Python 2.7 那么这一步你肯定要做的, 做完之后呢, 你就可以跳过步骤三, 直奔步骤四.
步骤三: 编译 Python 3+ 版的 Open CV. 同样地, 你准备用 Python 3+ 的话, 步骤二是不用做的, 直接从步骤一来到这里.
步骤四: 确认安装成功. 在你安装完成之后, 这一步骤就来确认 Open CV是否安装成功, 能不能正常地工作.

Ⅵ python怎么安装opencv

一、openCV介绍
Open Source Computer Vision Library.OpenCV于1999年由Intel建立,如今由Willow Garage提供支持。OpenCV是一个基于BSD许可(开源)发行的跨平台计算机视觉库,可以运行在Linux、Windows、MacOS操作系统上。它轻量级而且高效——由一系列 C 函数和少量C++类构成,同时提供了Python、Ruby、MATLAB等语言的接口,实现了图像处理和计算机视觉方面的很多通用算法。最新版本是3.1 ,2016年1月29日发布。(引自网络openCV)

简言之,通过openCV可实现计算机图像、视频的编辑。广泛应用于图像识别、运动跟踪、机器视觉等领域。
二、环境
本文适用于win7 64位系统 下的Python3.5。python3.5、pip为必备前提。python可在官网下载:https://www.python.org/downloads/windows/,建议使用exe installer,pip会随之安装。
环境变量中加入python安装路径,我的是 C:\Program Files\Python35\Scripts\;C:\Program Files\Python35\; 注意分号。
三、开搞
一切就绪以后以管理员身份运行cmd或PowerShell。依次输入以下命令:
pip install --upgrade setuptools
pip install numpy Matplotlib
pip install opencv-python

opencv环境已经整好,就是这么简单。只需要numpy、Matplotlib、opencv-python三个包,都不大很快就可以下好,如果下载中间出现error或wrong,重新输入命令即可。
如果多次下载失败,可以从http://www.lfd.uci.e/~gohlke/pythonlibs/直接下载whl包安装,安装whl包依然使用pip
pip install 包的位置(如:C:\download\xxx.whl)

四、测试
写.py脚本:
#导入cv模块import cv2 as cv#读取图像,支持 bmp、jpg、png、tiff 等常用格式img = cv.imread("D:\python\test.jpg")#创建窗口并显示图像cv.namedWindow("Image")
cv.imshow("Image",img)
cv.waitKey(0)#释放窗口cv2.destroyAllWindows()
运行以上脚本,如果可以显示出测试的图像,则环境搭建成功

Ⅶ python代码运行助手怎么打开

python代码运行助手是能在网页上运行python语言的工具。因为python的运行环境在很多教程里都是用dos的,黑乎乎的界面看的有点简陋,所以出了这python代码运行助手,作为ide。

实际上,python代码运行助手界面只能算及格分,如果要找ide,推荐使用jupyter。jupyter被集成到ANACONDA里,只要安装了anacoda就能使用了。

回到这个问题:

1、要打开这运行助手首先要下载一个learning.py,如果找不到可以复制如下代码另存为“learning.py”,编辑器用sublime、或者notepad++。

#!/usr/bin/envpython3
#-*-coding:utf-8-*-

r'''
learning.py

APython3tutorialfromhttp://www.liaoxuefeng.com

Usage:

python3learning.py
'''

importsys

defcheck_version():
v=sys.version_info
ifv.major==3andv.minor>=4:
returnTrue
print('Yourcurrentpythonis%d.%d.PleaseusePython3.4.'%(v.major,v.minor))
returnFalse

ifnotcheck_version():
exit(1)

importos,io,json,subprocess,tempfile
fromurllibimportparse
fromwsgiref.simple_serverimportmake_server

EXEC=sys.executable
PORT=39093
HOST='local.liaoxuefeng.com:%d'%PORT
TEMP=tempfile.mkdtemp(suffix='_py',prefix='learn_python_')
INDEX=0

defmain():
httpd=make_server('127.0.0.1',PORT,application)
print('ReadyforPythoncodeonport%d...'%PORT)
httpd.serve_forever()

defget_name():
globalINDEX
INDEX=INDEX+1
return'test_%d'%INDEX

defwrite_py(name,code):
fpath=os.path.join(TEMP,'%s.py'%name)
withopen(fpath,'w',encoding='utf-8')asf:
f.write(code)
print('Codewroteto:%s'%fpath)
returnfpath

defdecode(s):
try:
returns.decode('utf-8')
exceptUnicodeDecodeError:
returns.decode('gbk')

defapplication(environ,start_response):
host=environ.get('HTTP_HOST')
method=environ.get('REQUEST_METHOD')
path=environ.get('PATH_INFO')
ifmethod=='GET'andpath=='/':
start_response('200OK',[('Content-Type','text/html')])
return[b'<html><head><title>LearningPython</title></head><body><formmethod="post"action="/run"><textareaname="code"style="width:90%;height:600px"></textarea><p><buttontype="submit">Run</button></p></form></body></html>']
ifmethod=='GET'andpath=='/env':
start_response('200OK',[('Content-Type','text/html')])
L=[b'<html><head><title>ENV</title></head><body>']
fork,vinenviron.items():
p='<p>%s=%s'%(k,str(v))
L.append(p.encode('utf-8'))
L.append(b'</html>')
returnL
ifhost!=HOSTormethod!='POST'orpath!='/run'ornotenviron.get('CONTENT_TYPE','').lower().startswith('application/x-www-form-urlencoded'):
start_response('400BadRequest',[('Content-Type','application/json')])
return[b'{"error":"bad_request"}']
s=environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
qs=parse.parse_qs(s.decode('utf-8'))
ifnot'code'inqs:
start_response('400BadRequest',[('Content-Type','application/json')])
return[b'{"error":"invalid_params"}']
name=qs['name'][0]if'name'inqselseget_name()
code=qs['code'][0]
headers=[('Content-Type','application/json')]
origin=environ.get('HTTP_ORIGIN','')
iforigin.find('.liaoxuefeng.com')==-1:
start_response('400BadRequest',[('Content-Type','application/json')])
return[b'{"error":"invalid_origin"}']
headers.append(('Access-Control-Allow-Origin',origin))
start_response('200OK',headers)
r=dict()
try:
fpath=write_py(name,code)
print('Execute:%s%s'%(EXEC,fpath))
r['output']=decode(subprocess.check_output([EXEC,fpath],stderr=subprocess.STDOUT,timeout=5))
exceptsubprocess.CalledProcessErrorase:
r=dict(error='Exception',output=decode(e.output))
exceptsubprocess.TimeoutExpiredase:
r=dict(error='Timeout',output='执行超时')
exceptsubprocess.CalledProcessErrorase:
r=dict(error='Error',output='执行错误')
print('Executedone.')
return[json.mps(r).encode('utf-8')]

if__name__=='__main__':
main()

2,再用一个记事本写如下的代码:

@echooff
pythonlearning.py
pause

另存为‘运行.bat’

3、把“运行.bat”和“learning.py”放到同一目录下,

Ⅷ python 怎样安装open cv

在官网自行下载,这里下载的是opencv2.4.10安装。
复制cv2.pyd 将”\opencv\build\python\2.7\x64”或”\opencv\build\python\2.7\x86”(根据python版本)文件夹中找到cv2.pyd”,复制到Python安装文件的”C:\Python27\Lib\site-packages”文件夹中。

Ⅸ 我的python opencv2不知道出错在哪里

我没用过Python的Opencv的库,只是用过Python的Image的库;Image库已经可以结果这个问题了我试着做一下:你先得安装PIL库得到rgb三个通道,然后转到HSV通道,其中H表示0-255的颜色,V表示强度,你大概先知道紫色的范围是多少from PIL import Imageimport colorsysdef CalculateH(img): if len(img.getbands()) == 4: ir,ig,ib,ia = img.split() else: ir, ig, ib = img.split() Hdat = [] Sdat = [] Vdat = [] for rd,gn,bl in zip(ir.getdata(),ig.getdata(),ib.getdata()): h,l,s = colorsys.rgb_to_hsv(rd/255.,gn/255.,bl/255.) Hdat.append(h) Sdat.append(l) Vdat.append(s) meanV = mean(Vdat) return Hdat, meanV def myreadim(filename): im = Image.open(filename) H,V = CalculateH(im)后面我就懒得写了,应该思路都清楚了吧,要转到其他的颜色通道上,不要在rgb通道上