4
我想通過wifi從我的覆盆子pi做一些視頻流。我使用pygame,因爲我也必須在我的項目中使用遊戲手柄。不幸的是我對顯示收到的幀感到困惑。不久,我得到JPEG幀,與PIL打開它,轉換成字符串 - 之後,我可以從字符串如何用pygame顯示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