Python 相机镜头

一哥第一卷感叹,这家奥地利~。这是什么g8事件,近盲目安装3g的OpenCV,结果徒劳。

入题。!环境Python2.7

严厉格按照什么步骤。必成功:

所需的软件如下面:

VideoCapture:  http://videocapture.sourceforge.net/VideoCapture-0.9-5.zip

MyEclipse 插件PyDev: http://ncu.dl.sourceforge.net/project/pydev/pydev/PyDev%202.7.1/PyDev%202.7.1.zip

PIL : http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.7.exe

1.      VideoCapture解压后,找到Python27。把里面的东西拷贝到自己安装Python相应文件夹中。建议把Python27外面的src tools啥的仅仅要相应的都复制过去。

2.      PIL直接安装就可以

3.      PyDev解压后直接拷贝到MyEclipse中的dropins。这里的环境配置网上一抓一大把。

环境准备完毕。代码例如以下:

fromVideoCapture import Device

importtime, string

interval= 2

cam =Device(devnum=0, showVideoWindow=0)

#cam.setResolution(648,480)

cam.saveSnapshot(‘image.jpg‘,timestamp=3, boldfont=1, quality=75)

i = 0

quant =interval * .1

starttime= time.time()

while 1:

lasttime = now = int((time.time() -starttime) / interval)

print i

cam.saveSnapshot(‘image.jpg‘, timestamp=3,boldfont=1)

i += 1

while now == lasttime:

now = int((time.time() - starttime) /interval)

time.sleep(quant)

直接运行就可以。

试执行,哈哈:

具体解释及延伸:

对于DEVICE的各项參数解释官档解释例如以下:

class Device:

"""Create instances of this class which will then representvideo devices.

    For the lifetime of the instance, thedevice is blocked, so it can not be

    used by other applications (which is quitenormal Windows behavior).

    If you want to access the device fromanother program, you have to delete

    the instance first (e.g. del cam).

    """

def __init__(self, devnum=0, showVideoWindow=0):

"""devnum: VideoCapture enumerates the available video capture devices

                    on your system.  If you have more than one device, specify

                    the desired one here.  The device number starts from 0.

           showVideoWindow: 0 ... do notdisplay a video window (the default)

                            1 ... display avideo window

                            Mainly used fordebugging, since the video window

                            can not be closedor moved around.

saveSnapshot的各项參数解释例如以下:

def saveSnapshot(self, filename, timestamp=0, boldfont=0,textpos=default_textpos, **keywords):

"""Saves a snapshot to the
harddisk.

        The filetype depends on thefilename extension.  Everything that PIL

        can handle can be specified (foo.jpg,foo.gif, foo.bmp, ...).

        filename:   String containing the name of the resultingfile.

        timestamp:  see getImage()

        boldfont:   see getImage()

        textpos:    see getImage()

        Additional keyword arguments can begive which are just passed to the

        save() method of the Image class.  For example you can specify the

        compression level of a JPEG image byquality=75 (which is the default

        value anyway).

getImage的各项參数解释例如以下:

def getImage(self, timestamp=0, boldfont=0, textpos=default_textpos):

"""Returns a PIL Image instance.

        timestamp:  0 ... no
timestamp (the default)

                    1 ... simple
timestamp

                    2 ... timestamp withshadow

                    3 ... timestamp withoutline

        boldfont:   0 ... normal font (the default)

                    1 ... bold font

        textpos:    The position of the
timestamp can bespecified by a string

                    containing a combination oftwo characters.  One character

                    must be either t or b, theother one either l, c or r.

                    t ... top

                    b ... bottom

                    l ... left

                    c ... center

                    r ... right

                    The default value is ‘bl

自己写的助于理解上述程序的程序:

import time

a=2

b=a*.1

i=0

print b

stime = time.time()

print stime

m=2

while m>i:

lasttime = now = int((time.time()-stime)/a)

print (‘i is: %s‘) %i

i+=1

print ‘进入while循环‘

while now ==lasttime:

now = int((time.time()-stime)/a)

print (time.time()-stime)/a

print (‘now is: %s‘) %now

print (‘lasttime is: %s‘) %lasttime

if now ==lasttime:

print (‘lasttime == now‘)

else:

print (‘lasttime 不等于 now‘)

time.sleep(b)

print ‘休眠%s第二‘ %b

版权声明:本文博主原创文章。博客,未经同意不得转载。

时间: 2024-07-29 12:20:08

Python 相机镜头的相关文章

Python学习1-Python和Pycharm的下载与安装

本文主要介绍Python的下载安装和Python编辑器Pycharm的下载与安装. 一.Python的下载与安装 1.下载 到Python官网上下载Python的安装文件,进入网站后显示如下图: 网速访问慢的话可直接在这里下载:python-2.7.11.amd64 在Downloads中有对应的支持的平台,这里我们是在Windows平台下运行,所以点击Windows,出现如下: 在这里显示了Python更新的所有版本,其中最上面两行分别是Python2.X和Python3.X对应的最后更新版本

Python——深入理解urllib、urllib2及requests(requests不建议使用?)

深入理解urllib.urllib2及requests            python Python 是一种面向对象.解释型计算机程序设计语言,由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年,Python 源代码同样遵循 GPL(GNU General Public License)协议[1] .Python语法简洁而清晰,具有丰富和强大的类库. urllib and urllib2 区别 urllib和urllib2模块都做与请求URL相关的操作,但

python学习_day26_面向对象之封装

1.私有属性 (1)动态属性 在python中用双下划线开头的方式将属性隐藏起来.类中所有双下划线开头的名称,如__x都会自动变形成:_类名__x的形式.这种自动变形的特点是: a.类中定义的__x只能在内部使用,如self.__x,引用的就是变形的结果.b.这种变形其实正是针对外部的变形,在外部是无法通过__x这个名字访问到的.c.在子类定义的__x不会覆盖在父类定义的__x,因为子类中变形成了:_子类名__x,而父类中变形成了:_父类名__x,即双下滑线开头的属性在继承给子类时,子类是无法覆

python面向对象知识点疏理

面向对象技术简介 类: 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例.class 类变量:类变量在整个实例化的对象中是公用的.类变量定义在类中且在函数体之外.类变量通常不作为实例变量使用. 数据成员:类变量或者实例变量用于处理类及其实例对象的相关的数据. 方法重写:如果从父类继承的方法不能满足子类的需求,可以对其进行改写,这个过程叫方法的覆盖,也称为方法的重写. 实例变量:定义在方法中的变量,只作用于当前实例的类. 继承:即一个派生类(de

python实现网页登录时的rsa加密流程

对某些网站的登录包进行抓包时发现,客户端对用户名进行了加密,然后传给服务器进行校验. 使用chrome调试功能断点调试,发现网站用javascript对用户名做了rsa加密. 为了实现网站的自动登录,需要模拟这个加密过程. 网上搜了下关于rsa加密的最简明的解释: rsa加密是非对称加密算法,该算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但那时想要对其乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥,即公钥,而两个大素数组合成私钥.公钥是可发布的供任何人使用,私钥则为自己

Python中编码的详细讲解

看这篇文章前,你应该已经知道了为什么有编码,以及编码的种类情况 ASCII 占1个字节,只支持英文 GB2312 占2个字节,支持6700+汉字 GBK GB2312的升级版,支持21000+汉字 Shift-JIS 日本字符 ks_c_5601-1987 韩国编码 TIS-620 泰国编码 由于每个国家都有自己的字符,所以其对应关系也涵盖了自己国家的字符,但是以上编码都存在局限性,即:仅涵盖本国字符,无其他国家字符的对应关系.应运而生出现了万国码,他涵盖了全球所有的文字和二进制的对应关系, U

Python练习(一)

Python练习(一): 给一个不超过5位的正整数,判断其有几位,依次打印出个位.十位.百位.千位.万位的数字: num = int(input('please enter a number: '))   lst = [] for i in str(num):      lst.append(i) lenlst = len(lst) if num >= 1000:      if num >= 10000:          print('too big')     else:        

菜鸟学python之对象类型及运算

Python 中的变量不需要声明.每个变量在使用前都必须赋值,变量赋值以后该变量才会被创建. 在 Python 中,变量就是变量,它没有类型,我们所说的"类型"是变量所指的内存中对象的类型. 等号(=)用来给变量赋值. 1 变量赋值 1.1 单个变量赋值 >>> name="python" >>> print(name) python 1.2 多个变量赋值 >>> name=names="python&

开始我的Python爬虫学习之路

因为工作需要经常收集一些数据,我就想通过学爬虫来实现自动化完成比较重复的任务. 目前我Python的状况,跟着敲了几个教程,也算是懂点基础,具体比较深入的知识,是打算从做项目中慢慢去了解学习. 我是觉得如果一开始就钻细节的话,是很容易受到打击而放弃的,做点小项目让自己获得点成就感路才更容易更有信心走下去. 反正遇到不懂的就多查多问就对了. 知乎上看了很多关于入门Python爬虫的问答,给自己总结出了大概的学习方向. 基础: HTML&CSS,JOSN,HTTP协议(这些要了解,不太需要精通) R