一哥第一卷感叹,这家奥地利~。这是什么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).

    """

, showVideoWindow=):

"""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的各项參数解释例如以下:

, boldfont=,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的各项參数解释例如以下:

, boldfont=, 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

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

Python 相机镜头的更多相关文章

  1. Python中的多进程与多线程(一)

    一.背景 最近在Azkaban的测试工作中,需要在测试环境下模拟线上的调度场景进行稳定性测试.故而重操python旧业,通过python编写脚本来构造类似线上的调度场景.在脚本编写过程中,碰到这样一个 ...

  2. Python高手之路【六】python基础之字符串格式化

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  3. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  4. JavaScript之父Brendan Eich,Clojure 创建者Rich Hickey,Python创建者Van Rossum等编程大牛对程序员的职业建议

    软件开发是现时很火的职业.据美国劳动局发布的一项统计数据显示,从2014年至2024年,美国就业市场对开发人员的需求量将增长17%,而这个增长率比起所有职业的平均需求量高出了7%.很多人年轻人会选择编 ...

  5. 可爱的豆子——使用Beans思想让Python代码更易维护

    title: 可爱的豆子--使用Beans思想让Python代码更易维护 toc: false comments: true date: 2016-06-19 21:43:33 tags: [Pyth ...

  6. 使用Python保存屏幕截图(不使用PIL)

    起因 在极客学院讲授<使用Python编写远程控制程序>的课程中,涉及到查看被控制电脑屏幕截图的功能. 如果使用PIL,这个需求只需要三行代码: from PIL import Image ...

  7. Python编码记录

    字节流和字符串 当使用Python定义一个字符串时,实际会存储一个字节串: "abc"--[97][98][99] python2.x默认会把所有的字符串当做ASCII码来对待,但 ...

  8. Apache执行Python脚本

    由于经常需要到服务器上执行些命令,有些命令懒得敲,就准备写点脚本直接浏览器调用就好了,比如这样: 因为线上有现成的Apache,就直接放它里面了,当然访问安全要设置,我似乎别的随笔里写了安全问题,这里 ...

  9. python开发编译器

    引言 最近刚刚用python写完了一个解析protobuf文件的简单编译器,深感ply实现词法分析和语法分析的简洁方便.乘着余热未过,头脑清醒,记下一点总结和心得,方便各位pythoner参考使用. ...

随机推荐

  1. leetcode:linked_list_cycle_II

    一.     题目 给定一个链表,假设链表中有环则返回环的開始节点,否则返回NULL.要求不用额外的空间完毕. 二.     分析 在I中,我们推断环的存在,即用slow和fast两个指针,设定步长f ...

  2. Android系统各版本号及代号

    Android系统各版本号及代号 版本 版本号代号 公布日期 API Android 1.0 阿童木 1 Android 1.1 发条机器人 2008.9 2 Android 1.5 纸杯蛋糕 200 ...

  3. python几道简单的算法题

    最近看了python的语法,但是总感觉不知道怎么使用它,还是先来敲敲一些简单的程序吧. 1.题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 程序分析:可填在百位.十 ...

  4. python学习笔记之三:字典,当索引不好用时

    字典是python中唯一内建的映射类型.字典中的值并没有特殊的顺序,但是都存储在一个特定的键(key)里.键可以是数字,字符串甚至是元组. 1. 创建和使用字典 字典可以通过下面的方式创建: phon ...

  5. 编辑简单的 shell程序

    编辑简单的 shell程序 知道了vi编辑器的使用规则之后,结合shell的使用规则,可以编辑简单的 shell程序试试手 题目如下: 1.用while语句创建一个根据输入的数值求累加和(1+2+3+ ...

  6. CentOS7+Tomcat 生产系统部署

    1 准备OS账户 安全起见,本着最小权限原则,生产系统决不同意使用root账户来执行tomcat.为此,建立新账户tomcat,并设定登录password. useradd tomcat passwd ...

  7. MATLAB导入数据importdata功能

    用load函数导入mat文件大家都会.可是今天我拿到一个数据,文件后缀名竟然是'.data'.该怎么读呢? 我仅仅好用matlab界面Workspace区域的"import data&quo ...

  8. Git代理服务器设置和访问Github

    因为现在工作的网络环境有着非常严格的限制,.可以说,在最近的访问通过代理Github它采取了一些曲折的.也积累了一些相关经验.我们认为有必要注意什么. 符合"不要再发明轮子"宗旨, ...

  9. 80x86汇编小站站长简单介绍-2014年08月23日

    [序言] 旧版的"80x86汇编小站站长简单介绍"已经过时了, 因此于2013年10月01日花费1个小时又一次更新和排版一次. [人生格言]  1] 一生都用头脑而不是情绪解决这个 ...

  10. poj 3311Hie with the Pie

    题意:一个送披萨的,每次送外卖不超过10个地方,给你这些地方之间的时间,求送完外卖回到店里的总时间最小. 解法一: 这个n不大,即使是NP问题也才1E6多一些所以可以dfs():具体的回溯方法结合da ...