diff --git a/Resources/RadioFont.ttf b/Resources/RadioFont.ttf new file mode 100644 index 0000000..a5d9d10 Binary files /dev/null and b/Resources/RadioFont.ttf differ diff --git a/Software/houston/RobotStreamer.py b/Software/houston/RobotStreamer.py index b445718..a5730bf 100644 --- a/Software/houston/RobotStreamer.py +++ b/Software/houston/RobotStreamer.py @@ -1,7 +1,7 @@ import subprocess as sp from Xlib import display, X -from PIL import Image +from PIL import Image, ImageFont, ImageDraw class Streamer: @@ -67,6 +67,9 @@ class Streamer: # This is the ffmpeg pipe streamer! self.pipe = sp.Popen(cmd_out, stdin=sp.PIPE) + # Graphics and resources + self.font = ImageFont.truetype(r"../../Resources/RadioFont.ttf", 20) + def getFrame(self): """ Returns a single cropped sstv video frame @@ -79,13 +82,54 @@ class Streamer: return image + def drawGraphics(self, image: Image): + """ + Draws graphics and sprites over + a frame + """ + + frame = Image.new(mode="RGB", size=(1280, 720)) + + # Scale and paste + image = image.resize((960, 720), Image.ANTIALIAS) + frame.paste(image) + + # Populate text, normally this should poll or use shared vars! + info = """ +KW1FOX-1 +Online! +Volt: N/A +Last comm: N/A + +KW1FOX-2 +Offline. +Volt: N/A +Last comm: N/A + +KW1FOX-3 +Offline. +Volt: N/A +Last comm: N/A + +Currently Showing: +KW1FOX-1 +NOCOM +NOMETA +""" + + # Draw text + draw = ImageDraw.Draw(frame) + draw.text((960 + 10, 10), info, font=self.font, align="left") + + return frame + def stream(self): """ Actually streams! """ while True: - self.getFrame().save(self.pipe.stdin, "PNG") + self.drawGraphics(self.getFrame()).save(self.pipe.stdin, "PNG") def __del__(self): self.dsp.close() @@ -97,5 +141,5 @@ class Streamer: if __name__ == "__main__": myStreamer = Streamer() - # myStreamer.getFrame().show() + # myStreamer.drawGraphics(Image.open("../../Resources/KW1FOX-1_320x240.png")).show() myStreamer.stream()