I'm trying to make some video stream from my raspberry pi over wifi. I used pygame because I also need to use a gamepad in my project. Unfortunately, I am stuck in displaying the resulting frame. Soon: I get a jpeg frame, open it with PIL, convert to a string - after that I can load an image from a string
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()
and error:
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
source
share