昨天安装了pygame,还没有具体学习如何用,先写了个最简单且原始的摄像头程序,画面还算流畅,不过还存在较多缺陷,后面对pygame熟悉了再一一优化。

  1、实现:

#!/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('视频窗口@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、测试

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

转载于:https://www.cnblogs.com/dyx1024/archive/2012/02/10/2556712.html

相关文章:

  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-09-02
  • 2022-02-21
  • 2021-12-10
  • 2021-12-06
猜你喜欢
  • 2022-01-15
  • 2021-12-03
  • 2021-05-29
  • 2021-12-29
  • 2021-08-24
  • 2022-12-23
相关资源
相似解决方案