Exemplo n.º 1
0
    def main(self):
        from Kamaelia.UI.Pygame.Display import PygameDisplay
        from Kamaelia.UI.Pygame.MagnaDoodle import MagnaDoodle

        X=PygameDisplay(width=200,height=200).activate()
        PygameDisplay.setDisplayService(X)
        MagnaDoodle().run()
Exemplo n.º 2
0
    def RateLimitedPlayback(frame):
        fps = frame["frame_rate"]
        x, y = tuple(frame["size"])
        print "Frames per second:", fps
        print "(width,height):", (x, y)

        pgd = PygameDisplay(width=x, height=y).activate()
        PygameDisplay.setDisplayService(pgd)

        return Graphline( \
            LIMIT = PromptedTurnstile(),
            RATE  = ByteRate_RequestControl(rate=fps, chunksize=1.0, allowchunkaggregation=False),
            PLAY  = player,
            linkages = {
                ("",      "inbox" ) : ("LIMIT", "inbox"),
                ("LIMIT", "outbox") : ("PLAY",  "inbox"),
                ("PLAY",  "outbox") : ("",      "outbox"),

                ("RATE", "outbox" ) : ("LIMIT", "next"),

                ("",      "control") : ("RATE",  "control"),
                ("RATE",  "signal" ) : ("LIMIT", "control"),
                ("LIMIT", "signal" ) : ("PLAY",  "control"),
                ("PLAY",  "signal" ) : ("",      "signal"),
            },
            boxsizes = {
                ("LIMIT","inbox") : 2,
            },
        )
Exemplo n.º 3
0
    def RateLimitedPlayback(frame):
        fps = frame["frame_rate"]
        x,y = tuple(frame["size"])
        print "Frames per second:",fps
        print "(width,height):",(x,y)
        
        pgd = PygameDisplay(width=x,height=y).activate()
        PygameDisplay.setDisplayService(pgd)

        return Graphline( \
            LIMIT = PromptedTurnstile(),
            RATE  = ByteRate_RequestControl(rate=fps, chunksize=1.0, allowchunkaggregation=False),
            PLAY  = player,
            linkages = {
                ("",      "inbox" ) : ("LIMIT", "inbox"),
                ("LIMIT", "outbox") : ("PLAY",  "inbox"),
                ("PLAY",  "outbox") : ("",      "outbox"),
                
                ("RATE", "outbox" ) : ("LIMIT", "next"),

                ("",      "control") : ("RATE",  "control"),
                ("RATE",  "signal" ) : ("LIMIT", "control"),
                ("LIMIT", "signal" ) : ("PLAY",  "control"),
                ("PLAY",  "signal" ) : ("",      "signal"),
            },
            boxsizes = {
                ("LIMIT","inbox") : 2,
            },
        )
Exemplo n.º 4
0
    def main(self):
        from Kamaelia.UI.Pygame.Display import PygameDisplay
        from Kamaelia.UI.Pygame.MagnaDoodle import MagnaDoodle

        X = PygameDisplay(width=200, height=200).activate()
        PygameDisplay.setDisplayService(X)
        MagnaDoodle().run()
Exemplo n.º 5
0
                         ("GRAMMAR", "outbox"): ("self", "outbox"),
                         ("QUANTISE", "drawing"): ("self", "drawing"),
                         ("ANALYSE", "drawing"): ("self", "drawing"),
                     })


if __name__ == "__main__":

    from Kamaelia.UI.Pygame.Display import PygameDisplay
    from Kamaelia.Util.Console import ConsoleEchoer

    width = 1024
    height = 384

    pgd = PygameDisplay(width=width, height=height).activate()
    PygameDisplay.setDisplayService(pgd)

    Graphline(
        CANVAS=Canvas(position=(0, 0), size=(width, height)),
        PEN=Pen(),
        STROKER=StrokeRecogniser(),
        OUTPUT=ConsoleEchoer(),
        linkages={
            ("CANVAS", "eventsOut"): ("PEN", "inbox"),
            ("PEN", "outbox"): ("CANVAS", "inbox"),
            ("PEN", "points"): ("STROKER", "inbox"),
            ("STROKER", "outbox"): ("OUTPUT", "inbox"),
            ("STROKER", "drawing"): ("CANVAS", "inbox"),
        },
    ).run()
Exemplo n.º 6
0
 def main(self):
     pgd = PygameDisplay(width=self.width, height=self.height).activate()
     PygameDisplay.setDisplayService(pgd)
     yield 1
Exemplo n.º 7
0
#from BlankCanvas import BlankCanvas


if __name__=="__main__":
    width = 1024
    height = 768
    top = 0
    left = 0
    colours_order = [ "black", "red", "orange", "yellow", "green", "turquoise", "blue", "purple", "darkgrey", "lightgrey" ]
    ogl_display = OpenGLDisplay(title="Kamaelia Whiteboard",width=width,height=height,background_colour=(255,255,255))
    ogl_display.activate()
    OpenGLDisplay.setDisplayService(ogl_display)
    
    ogl_display = OpenGLDisplay.getDisplayService()
    PygameDisplay.setDisplayService(ogl_display[0])
    
    if (0):
        #PygameDisplay.setDisplayService(ogl_display)
        CANVAS = Canvas( position=(left,top+32),size=(1200,(900-(32+15))),notepad="Test" ).activate() #(replace width with 'width' and height with 'height-(32+15)'
        PAINTER = Painter().activate()
        CANVAS_WRAPPER = PygameWrapper(wrap=CANVAS, position=(0,0,-10), rotation=(0,0,0)).activate() 
        ERASER  = Eraser(left,top).activate()
        PALETTE = buildPalette( cols=colours, order=colours_order, topleft=(left+64,top), size=32 ).activate()
        CLEAR = ClearPage(left+(64*5)+32*len(colours),top).activate()
        #PALETTE_WRAPPER = PygameWrapper(wrap=PALETTE, position=(4,1,-10), rotation=(-20,15,3)).activate()
    
        #PAINTER_WRAPPER = PygameWrapper(wrap=PAINTER, position=(4,1,-10), rotation=(-20,15,3)).activate()
        CANVAS.link( (PAINTER,"outbox"), (CANVAS, "inbox") )
        PAINTER.link( (CANVAS,"eventsOut"), (PAINTER, "inbox") )
        PAINTER.link( (PALETTE,"outbox"), (PAINTER, "colour") )
Exemplo n.º 8
0
            1,
            DetectShotChanges(threshold),
            FormatOutput(),
            ConsoleEchoer(),
            StopSelector(waitForTrigger=True),
        ).run()

    else:
        # cut detector plus playback at the same time

        from Kamaelia.UI.Pygame.Display import PygameDisplay
        from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay
        from Kamaelia.Util.Backplane import Backplane, PublishTo, SubscribeTo
        from Kamaelia.Util.RateFilter import MessageRateLimit

        PygameDisplay.setDisplayService(
            PygameDisplay(width=1024, height=500).activate())

        Pipeline(
            UnixProcess("ffmpeg -i " + infile +
                        " -f yuv4mpegpipe -y /dev/stdout"),
            2,
            YUV4MPEGToFrame(),
            50,
            MessageRateLimit(25, 25),
            PublishTo("VIDEO"),
            Backplane("VIDEO"),
            StopSelector(waitForTrigger=True),
        ).activate()

        Pipeline(
            SubscribeTo("VIDEO"),
Exemplo n.º 9
0
 def main(self):
     pgd = PygameDisplay( width=self.width, height=self.height ).activate()
     PygameDisplay.setDisplayService(pgd)
     yield 1
Exemplo n.º 10
0
                          ("ANALYSE", "drawing")  : ("self", "drawing"),
                        }
                    )



if __name__ == "__main__":

    from Kamaelia.UI.Pygame.Display import PygameDisplay
    from Kamaelia.Util.Console import ConsoleEchoer

    width = 1024
    height = 384

    pgd = PygameDisplay( width=width, height=height ).activate()
    PygameDisplay.setDisplayService(pgd)
    
    Graphline( CANVAS  = Canvas( position=(0,0),size=(width,height) ),
               PEN     = Pen(),
               STROKER = StrokeRecogniser(),
               OUTPUT  = ConsoleEchoer(),
        
               linkages = {
                   ("CANVAS",  "eventsOut") : ("PEN", "inbox"),
                   ("PEN", "outbox")        : ("CANVAS", "inbox"),
                   ("PEN", "points")        : ("STROKER", "inbox"),
                   ("STROKER", "outbox")    : ("OUTPUT", "inbox"),
                   ("STROKER", "drawing")   : ("CANVAS", "inbox"),
                   },
            ).run()
    
Exemplo n.º 11
0
             1, TagWithSequenceNumber(),
             1, DetectShotChanges(threshold),
             FormatOutput(),
             ConsoleEchoer(),
             StopSelector(waitForTrigger=True),
             ).run()
         
 else:
     # cut detector plus playback at the same time
     
     from Kamaelia.UI.Pygame.Display import PygameDisplay
     from Kamaelia.UI.Pygame.VideoOverlay import VideoOverlay
     from Kamaelia.Util.Backplane import Backplane,PublishTo,SubscribeTo
     from Kamaelia.Util.RateFilter import MessageRateLimit
     
     PygameDisplay.setDisplayService(PygameDisplay(width=1024,height=500).activate())
     
     Pipeline(
         UnixProcess2("ffmpeg -i "+infile +" -f yuv4mpegpipe -y /dev/stdout"),
         2, YUV4MPEGToFrame(),
         50, MessageRateLimit(25,25),
         PublishTo("VIDEO"),
         Backplane("VIDEO"),
         StopSelector(waitForTrigger=True),
         ).activate()
         
     Pipeline(
         SubscribeTo("VIDEO"),
         TagWithSequenceNumber(),
         DetectShotChanges(threshold),
         FormatOutput(),
Exemplo n.º 12
0
#!/usr/bin/python

from Kamaelia.UI.Pygame.Display import PygameDisplay
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Util.Console import ConsoleEchoer
from Kamaelia.UI.Pygame.Text import Textbox, TextDisplayer

X = PygameDisplay(background_colour=(224,224,255),width=1000,height=400).activate()
PygameDisplay.setDisplayService(X)

Pipeline(
         Textbox(size = (800, 150), position = (100,230),      font_file="/home/michaels/.fonts/MichaelHW.ttf",padding=20, border_size=10, border_colour=(128,0,0)),
         TextDisplayer(size = (800, 150), position = (100,40), font_file="/home/michaels/.fonts/GillSans.ttf", padding=20, border_size=10, border_colour=(0,0,128))
).run()
                 
                  
Exemplo n.º 13
0
#!/usr/bin/python

from Kamaelia.UI.Pygame.Display import PygameDisplay
from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Util.Console import ConsoleEchoer
from Kamaelia.UI.Pygame.Text import Textbox, TextDisplayer

X = PygameDisplay(background_colour=(224, 224, 255), width=1000,
                  height=400).activate()
PygameDisplay.setDisplayService(X)

Pipeline(
    Textbox(size=(800, 150),
            position=(100, 230),
            font_file="/home/michaels/.fonts/MichaelHW.ttf",
            padding=20,
            border_size=10,
            border_colour=(128, 0, 0)),
    TextDisplayer(size=(800, 150),
                  position=(100, 40),
                  font_file="/home/michaels/.fonts/GillSans.ttf",
                  padding=20,
                  border_size=10,
                  border_colour=(0, 0, 128))).run()