【发布时间】:2015-10-20 19:08:54
【问题描述】:
我正在尝试通过 wifi 从我的树莓派做一些视频流。我使用了 pygame,因为我还必须在我的项目中使用游戏手柄。不幸的是,我坚持显示收到的帧。很快:我得到 jpeg 帧,用 PIL 打开它,转换为字符串 - 之后我可以从字符串加载图像
image_stream = io.BytesIO()
...
frame_1 = Image.open(image_stream)
f = StringIO.StringIO()
frame_1.save(f, "JPEG")
data = f.getvalue()
frame = pygame.image.fromstring(frame_1,image_len,"RGB")
screen.fill(white)
screen.blit(frame, (0,0))
pygame.display.flip()
错误是:
Traceback (most recent call last):
File "C:\Users\defau_000\Desktop\server.py", line 57, in <module>
frame = pygame.image.fromstring(frame_1,image_len,"RGB")
TypeError: must be str, not instance
【问题讨论】:
标签: python pygame python-imaging-library