python中的screen blit_python pygame blit。获取要显示的图像

在尝试通过pygame播放摄像头视频时遇到错误,原始代码中的`screen.blit(image, (0, 0))`抛出TypeError,因为图像未转换为pygame.Surface。解决方案是创建一个pygame.surface.Surface对象并保存图片到当前文件夹,屏幕虽然仍显示黑色,但图片已成功保存。" 116447153,10545394,"解决Oracle impdp报错ORA-31693, ORA-31640, ORA-19505, ORA-27037
摘要由CSDN通过智能技术生成

我想让我的摄像头通过pygame播放视频。代码如下:# import the relevant libraries

import time

import pygame

import pygame.camera

from pygame.locals import *

# this is where one sets how long the script

# sleeps for, between frames.sleeptime__in_seconds = 0.05

# initialise the display window

pygame.init()

pygame.camera.init()

screen = pygame.display.set_mode((640, 480), 0, 32)

# set up a camera object

cam = pygame.camera.Camera(0)

# start the camera

cam.start()

while 1:

# sleep between every frame

time.sleep( 10 )

# fetch the camera image

image = cam.get_image()

# blank out the screen

screen.fill((0,0,2))

# copy the camera image to the screen

screen.blit( image, ( 0, 0 ) )

# update the screen to show the latest screen image

pygame.d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值