New graphics
This commit is contained in:
parent
12d87af633
commit
9c73d1535a
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
|
|
||||||
from Xlib import display, X
|
from Xlib import display, X
|
||||||
from PIL import Image
|
from PIL import Image, ImageFont, ImageDraw
|
||||||
|
|
||||||
|
|
||||||
class Streamer:
|
class Streamer:
|
||||||
|
@ -67,6 +67,9 @@ class Streamer:
|
||||||
# This is the ffmpeg pipe streamer!
|
# This is the ffmpeg pipe streamer!
|
||||||
self.pipe = sp.Popen(cmd_out, stdin=sp.PIPE)
|
self.pipe = sp.Popen(cmd_out, stdin=sp.PIPE)
|
||||||
|
|
||||||
|
# Graphics and resources
|
||||||
|
self.font = ImageFont.truetype(r"../../Resources/RadioFont.ttf", 20)
|
||||||
|
|
||||||
def getFrame(self):
|
def getFrame(self):
|
||||||
"""
|
"""
|
||||||
Returns a single cropped sstv video frame
|
Returns a single cropped sstv video frame
|
||||||
|
@ -79,13 +82,54 @@ class Streamer:
|
||||||
|
|
||||||
return image
|
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):
|
def stream(self):
|
||||||
"""
|
"""
|
||||||
Actually streams!
|
Actually streams!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
self.getFrame().save(self.pipe.stdin, "PNG")
|
self.drawGraphics(self.getFrame()).save(self.pipe.stdin, "PNG")
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.dsp.close()
|
self.dsp.close()
|
||||||
|
@ -97,5 +141,5 @@ class Streamer:
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
myStreamer = Streamer()
|
myStreamer = Streamer()
|
||||||
|
|
||||||
# myStreamer.getFrame().show()
|
# myStreamer.drawGraphics(Image.open("../../Resources/KW1FOX-1_320x240.png")).show()
|
||||||
myStreamer.stream()
|
myStreamer.stream()
|
||||||
|
|
Loading…
Reference in New Issue