I installed pygame yesterday, but I haven't learned how to use it. I first wrote the simplest and original camera program, and the picture is still smooth, but there are still many defects, later, I was familiar with pygame and optimized it one by one.
1. Implementation:
#! /Usr/bin/ENV Python #-*-coding: UTF-8-*-from videocapture import deviceimport timeimport sys, pygamepygame. init () size = width, height = 620,485 speed = [2, 2] Black = 0, 0, 0pygame. display. set_caption ('video window @ dyx1024') screen = pygame. display. set_mode (size) # capture frequency, capture a sleep_time_long = 0.1 # initialize the camera cam = Device (devnum = 0, showvideowindow = 0) While true: # capture the image cam.savesnapshot('test.jpg ', timestamp = 3, boldfont = 1, quality = 75) # Load image = pygame.image.load('test.jpg ') # transfer screen. bspeed (image, speed) # display the image pygame. display. flip () # sleep for a minute. sleep (sleep_time_long)
2. Test