# Created by Leo from: C:\Python23\Tom\leo\pyro.leo # << Cameratest declarations >> import Image import VideoCapture import bz2,pickle,ImageChops import wx import time, string,bz2,threading import wx.lib.evtmgr as EventManager # -- end -- << Cameratest declarations >> # << Cameratest methods >> (1 of 4) class MyFrame(wx.Frame): # << class MyFrame methods >> (1 of 5) def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.DefaultSize) self.camdevice = VideoCapture.Device() self.imgcount = 0 self.mypak = paklist() self.Bind(wx.EVT_CLOSE, self.OnCloseWindow, id = self.GetId()) maintimerID = wx.NewId() self.maintimer = wx.Timer(self, maintimerID) self.Bind(wx.EVT_TIMER, self.OnTimer, id=maintimerID) StartButtonID = wx.NewId() self.StartButton = wx.Button(self, StartButtonID, "Go", wx.Point(20, 20)) self.StartButton.SetBackgroundColour(wx.BLUE) self.StartButton.SetForegroundColour(wx.WHITE) self.StartButton.SetDefault() StopButtonID = wx.NewId() self.StopButton = wx.Button(self, StopButtonID, "Stop", wx.Point(260, 20)) self.StopButton.SetBackgroundColour(wx.RED) self.StopButton.SetForegroundColour(wx.WHITE) self.Bind(wx.EVT_BUTTON, self.OnGoClick, id=StartButtonID) self.Bind(wx.EVT_BUTTON, self.OnStopClick, id=StopButtonID) self.Imagethen = self.camdevice.getImage(self) self.Imagenow = self.camdevice.getImage(self) self.imagedifference = ImageChops.difference(self.Imagethen,self.Imagenow) # << class MyFrame methods >> (2 of 5) def OnTimer(self, event): self.Imagethen = self.Imagenow if self.imgcount < 10: self.mypak.paklst[self.imgcount] = bz2.compress(self.imagedifference.tostring()) else: self.mypak.paklst[self.imgcount] = bz2.compress(self.Imagenow.tostring()) self.imgcount = -1 self.imgcount = self.imgcount + 1 self.Imagenow = self.camdevice.getImage(self) self.imagedifference = ImageChops.difference(self.Imagethen,self.Imagenow) # << class MyFrame methods >> (3 of 5) def OnCloseWindow(self, event): self.Destroy() # << class MyFrame methods >> (4 of 5) def OnGoClick(self, event): self.maintimer.Start(91) # << class MyFrame methods >> (5 of 5) def OnStopClick(self, event): self.maintimer.Stop() # -- end -- << class MyFrame methods >> # << Cameratest methods >> (2 of 4) class paklist: # << class paklist methods >> (1 of 2) def __init__(self): self.paklst = ['','','','','','','','','','',''] # << class paklist methods >> (2 of 2) def OnPak(self): #print len(self.paklst) return pickle.dumps(self.paklst) # -- end -- << class paklist methods >> # << Cameratest methods >> (3 of 4) class MyApp(wx.App): # << class MyApp methods >> def OnInit(self): # Create an instance of our customized Frame class self.frame = MyFrame(None, -1, "Transmition controll center") self.frame.Show(True) # Tell wxWindows that this is our main window self.SetTopWindow(self.frame) # Return a success flag return True # -- end -- << class MyApp methods >> # << Cameratest methods >> (4 of 4) class starter: # << class starter methods >> (1 of 3) def __init__(self): # Create an instance of the application class self.pythread = threading.Thread( group=None, target=self.GOGOGO, name=None, args=(), kwargs={}) self.pythread.start() #self.app.MainLoop() # Tell it to start processing events # << class starter methods >> (2 of 3) def OnPak(self): return pickle.dumps(self.app.frame.mypak.paklst) # << class starter methods >> (3 of 3) def GOGOGO(self): self.app = MyApp(0) self.app.MainLoop() # -- end -- << class starter methods >> # -- end -- << Cameratest methods >>