zhaoke0727 发表于 2017-5-2 07:09:56

Python:简单的摄像头程序实现

  昨天安装了pygame,还没有具体学习如何用,先写了个最简单且原始的摄像头程序,画面还算流畅,不过还存在较多缺陷,后面对pygame熟悉了再一一优化。
  1、实现:
  #!/usr/bin/env python# -*- coding: utf-8 -*-from VideoCapture import Deviceimport timeimport sys, pygamepygame.init()size = width, height = 620, 485speed = black = 0, 0, 0pygame.display.set_caption('视频窗口@dyx1024') screen = pygame.display.set_mode(size)#抓取频率,抓取一次SLEEP_TIME_LONG = 0.1#初始化摄像头cam = Device(devnum=0, showVideoWindow=0)while True:#抓图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)

  2、测试

页: [1]
查看完整版本: Python:简单的摄像头程序实现