赞
踩
正确的程序如下所示:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from VideoCapture import Device
import time
import sys,pygame
pygame.init()
size = width,height = 620,485
speed = [2,2]
black = 0,0,0
pygame.display.set_caption('视频窗口')
screen = pygame.display.set_mode(size)
#抓去频率,抓去一次
sleep_time_long = 0.1
#初始化摄像头
cam = Device(devnum=0,showVideoWindow=0)
while 1:
#抓图
cam.saveSnapshot('test.jpg',timestamp=3,boldfont=1,quality=75)
#加载图像
image = pygame.image.load('test.jpg')
#传送画面
screen.blit(image,speed)
#显示图像
pygame.display.flip()
#休眠一下,等待一分钟
time.sleep(sleep_time_long)
以下为笔者所写程序:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from VideoCapture import DEVIDE
import time
import sys,pygame
size = width,height = 600,485
speed = [2,2[A2] ]
black[A3] = (0,0,0)
pygame.display.set_Caption('视频窗口')
pygame[A4] .set_mode(size)
sleep_time_long=0.1
cam = DEVICE(devnum=0,VideoWindow=0)
while true:
cam.saveSnapshot('test.jpg',timestamp=3,boldfont=1,quality=75)
image = pygame.iamge.load('test.jpg')
screen.blit[A5] ()
pygame.display.flip()
time.sleep(sleep_time_long)
解释及延伸:
pygame.init
initializeall imported pygame modules
pygame.init():return (numpass, numfail)
Initialize all imported Pygamemodules. No exceptions will be raised if a module fails, but the total numberif successful and failed inits will be returned as a tuple. You can alwaysinitialize individual modules manually, but pygame.init is aconvenient way to get everything started. The init() functions forindividual modules will raise exceptions when they fail.
You may want to initalise thedifferent modules seperately to speed up your program or to not use things yourgame does not.
Itis safe to call this init() more than once: repeated calls willhave no effect. This is true even if you have pygame.quit –uninitializeall pygame modules– all the modules.
set the current window caption
pygame.display.set_caption(title,icontitle=None): return None
If the display has a window title, thisfunction will change the name on the window. Some systems support an alternateshorter title to be used for minimized displays.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。