Python: simple camera program implementation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.