def loadMonitors(self): self.active_monitors = {} resolution = options.GetOption("Resolution") data_folder = options.GetOption("Data_Folder") monitorsData = options.getMonitorsData() for mn in monitorsData: m = monitorsData[mn] track_type = ['DISTANCE', 'VBS', 'XY_COORDS'].index(m['track_type']) if type(m['source']) == int: source = int(m['source']) - 1 else: source = m['source'] output_file = m['outputfile'] or os.path.join( data_folder, 'Monitor%02d.txt' % mn) self.active_monitors[mn] = pysolovideo.Monitor() success = self.active_monitors[mn].setSource(source, resolution) if success: self.active_monitors[mn].setTracking(True, track_type, m['mask_file'], output_file) self.active_monitors[mn].SDserialPort = m['serial_port'] self.active_monitors[mn].inactivity_threshold = m[ 'inactivity_threshold'] or None #self.changeIcon(mn, 1) else: #self.changeIcon(mn, -1) pass pysolovideo.MONITORS = self.active_monitors
def loadMonitors(self): """ """ self.active_monitors = {} resolution = options.GetOption("Resolution") data_folder = options.GetOption("Data_Folder") monitorsData = options.getMonitorsData() for mn in monitorsData: m = monitorsData[mn] track_type = ['DISTANCE','VBS','XY_COORDS'].index(m['track_type']) if type(m['source']) == int: source = int(m['source']) - 1 else: source = m['source'] output_file = m['outputfile'] or os.path.join(data_folder, 'Monitor%02d.txt' % mn) self.active_monitors[mn] = pysolovideo.Monitor() success = self.active_monitors[mn].setSource(source, resolution) if success: self.active_monitors[mn].setTracking(True, track_type, m['mask_file'], output_file) self.active_monitors[mn].SDserialPort = m['serial_port'] self.active_monitors[mn].inactivity_threshold = m['inactivity_threshold'] or None #self.changeIcon(mn, 1) else: #self.changeIcon(mn, -1) pass pysolovideo.MONITORS = self.active_monitors
def drawPanel(self): # Draw the main interface for child in self.GetChildren(): child.Destroy() self.mon_num = options.GetOption( "Monitors") # Get number of monitors from config file self.num_cams = options.GetOption( "Webcams") # Get number of cameras from config file monitorsData = options.getMonitorsData() self.monitorsData = monitorsData WebcamsList = [ 'Camera %02d' % (int(w) + 1) for w in range(self.num_cams) ] # Generate a list of cameras colLabels = [ 'Status', 'Monitor', 'Source', 'Mask', 'Output', 'Track type', 'Track', 'uptime', 'preview' ] tracktypes = ['DISTANCE', 'VBS', 'XY_COORDS'] # create layouts and their items mainSizer = wx.BoxSizer(wx.VERTICAL) self.drawMonitorGrid(self.mon_num, colLabels, WebcamsList, tracktypes) btnSizer = self.drawButtons( ) # The buttons that do not go with a particular monitor # Add monitor grid and buttons to main layout mainSizer.Add(self.gridSizer, 1, wx.EXPAND, 0) mainSizer.Add(btnSizer, 0, wx.ALL, 5) mainSizer.Layout() # Store sizers as global variables in order to update UI later self.mainSizer = mainSizer self.SetSizer( mainSizer) # Make the panel display the mainSizer and its contents self.Refresh()
def drawPanel(self): """ """ ################################################### for child in self.GetChildren(): child.Destroy() mon_num = options.GetOption("Monitors") num_cams = options.GetOption("Webcams") monitorsData = options.getMonitorsData() WebcamsList = [ 'Camera %02d' % (int(w) +1) for w in range( num_cams ) ] colLabels = ['Status', 'Monitor', 'Source', 'Mask', 'Output', 'Track type', 'Track', 'uptime', 'preview'] tracktypes = ['DISTANCE','VBS','XY_COORDS'] mainSizer = wx.BoxSizer(wx.VERTICAL) gridSizer = wx.FlexGridSizer (cols=len(colLabels), vgap=5, hgap=5) #wx.BoxSizer(wx.VERTICAL) #FIRST ROW for key in colLabels: text = wx.StaticText(self, -1, key ) text.SetFont( wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD) ) gridSizer.Add(text, 0, wx.ALL|wx.ALIGN_CENTER, 5) self.status = [] self.recordBTNS = [] self.uptimeTXT = [] #LOOP THROUGH for mn in range(1, mon_num+1): if not options.HasMonitor(mn): options.SetMonitor(mn) #If monitor does not exist in options we create it md = options.GetMonitor(mn) try: _, source = os.path.split( md['source'] ) except: source = 'Camera %02d' % ( md['source'] ) _, mf = os.path.split(md['mask_file']) df = 'Monitor%02d.txt' % (mn) #ICON self.status.append( wx.StaticBitmap(self, -1, wx.EmptyBitmap(16,16)) ) gridSizer.Add(self.status[-1], 0, wx.ALL|wx.ALIGN_CENTER, 5) self.changeIcon(mn) #TEXT gridSizer.Add(wx.StaticText(self, -1, "Monitor %s" % mn ), 0, wx.ALL|wx.ALIGN_CENTER, 5) #INPUT SOURCE gridSizer.Add(comboFileBrowser(self, wx.ID_ANY, size=(-1,-1), dialogTitle = "Choose an Input video file", startDirectory = options.GetOption("Data_Folder"), value = source, choices=WebcamsList, fileMask = "Video File (*.*)|*.*", browsevalue="Browse for video...", changeCallback = partial(self.onChangeDropDown, [mn, "source"])), 0, wx.ALL|wx.ALIGN_CENTER, 5 ) #MASK FILE gridSizer.Add(comboFileBrowser(self, wx.ID_ANY, size=(-1,-1), dialogTitle = "Choose a Mask file", startDirectory = options.GetOption("Mask_Folder"), value = mf, fileMask = "pySolo mask file (*.msk)|*.msk", browsevalue="Browse for mask...", changeCallback = partial(self.onChangeDropDown, [mn, "mask_file"])), 0, wx.ALL|wx.ALIGN_CENTER, 5 ) #OUTPUT FILE gridSizer.Add(comboFileBrowser(self, wx.ID_ANY, size=(-1,-1), dialogTitle = "Choose the output file", startDirectory = options.GetOption("Data_Folder"), value = md['outputfile'], fileMask = "Output File (*.txt)|*.txt", browsevalue="Browse for output...", changeCallback = partial(self.onChangeDropDown, [mn, "outputfile"])), 0, wx.ALL|wx.ALIGN_CENTER, 5 ) #TRACKTYPE ttcb = wx.ComboBox(self, -1, size=(-1,-1), value=md['track_type'], choices=tracktypes, style=wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT) ttcb.Bind (wx.EVT_COMBOBOX, partial(self.onChangeDropDown, [mn, "track_type"])) gridSizer.Add(ttcb , 0, wx.ALL|wx.ALIGN_CENTER, 5) #RECORD BUTTON self.recordBTNS.append ( wx.ToggleButton(self, wx.ID_ANY, 'Start') ) self.recordBTNS[-1].Bind (wx.EVT_TOGGLEBUTTON, partial( self.onToggleRecording, mn)) gridSizer.Add(self.recordBTNS[-1], 0, wx.ALL|wx.ALIGN_CENTER, 5) #UPTIME self.uptimeTXT.append(wx.TextCtrl(self, value="00:00:00", size=(140,-1))) gridSizer.Add(self.uptimeTXT[-1], 0, wx.ALL|wx.ALIGN_CENTER, 5) #VIEW BUTTON vb = wx.Button(self, wx.ID_ANY, 'View') vb.Bind(wx.EVT_BUTTON, partial( self.onViewMonitor, mn)) gridSizer.Add(vb, 0, wx.ALL|wx.ALIGN_CENTER, 5) btnSizer = wx.BoxSizer(wx.HORIZONTAL) conf_btnSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Configuration'), wx.HORIZONTAL) acq_btnSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Acquisition'), wx.HORIZONTAL) self.saveOptionsBtn = wx.Button(self, wx.ID_ANY, 'Save') self.saveOptionsBtn.Enable(False) self.Bind(wx.EVT_BUTTON, self.onSave, self.saveOptionsBtn) conf_btnSizer.Add (self.saveOptionsBtn, 0, wx.ALL, 5) self.startBtn = wx.Button(self, wx.ID_ANY, 'Start All') self.stopBtn = wx.Button(self, wx.ID_ANY, 'Stop All') self.startBtn.Enable(True) self.stopBtn.Enable(False) self.Bind(wx.EVT_BUTTON, self.onStopAll, self.stopBtn) self.Bind(wx.EVT_BUTTON, self.onStartAll, self.startBtn) acq_btnSizer.Add (self.startBtn, 0, wx.ALL, 5) acq_btnSizer.Add (self.stopBtn, 0, wx.ALL, 5) btnSizer.Add(conf_btnSizer, 0, wx.ALL, 5) btnSizer.Add(acq_btnSizer, 0, wx.ALL, 5) #mainSizer.Add(self.FBconfig, 0, wx.EXPAND|wx.ALL, 5) mainSizer.Add(gridSizer, 1, wx.EXPAND, 0) mainSizer.Add(btnSizer, 0, wx.ALL, 5) mainSizer.Layout() self.SetSizer(mainSizer) self.Refresh()
def drawPanel(self): """ """ ################################################### for child in self.GetChildren(): child.Destroy() mon_num = options.GetOption("Monitors") num_cams = options.GetOption("Webcams") monitorsData = options.getMonitorsData() WebcamsList = [ 'Camera %02d' % (int(w) +1) for w in range( num_cams ) ] colLabels = ['Status', 'Monitor', 'Source', 'Mask', 'Output', 'Track type', 'Track', 'uptime', 'preview'] tracktypes = ['DISTANCE','VBS','XY_COORDS'] mainSizer = wx.BoxSizer(wx.VERTICAL) gridSizer = wx.FlexGridSizer (cols=len(colLabels), vgap=5, hgap=5) #wx.BoxSizer(wx.VERTICAL) #FIRST ROW for key in colLabels: text = wx.StaticText(self, -1, key ) text.SetFont( wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD) ) gridSizer.Add(text, 0, wx.ALL|wx.ALIGN_CENTER, 5) self.status = [] self.recordBTNS = [] self.uptimeTXT = [] #LOOP THROUGH for mn in range(1, mon_num+1): if not options.HasMonitor(mn): options.SetMonitor(mn) #If monitor does not exist in options we create it md = options.GetMonitor(mn) try: _, source = os.path.split( md['source'] ) except: source = 'Camera %02d' % ( md['source'] ) _, mf = os.path.split(md['mask_file']) df = 'Monitor%02d.txt' % (mn) #ICON self.status.append( wx.StaticBitmap(self, -1, wx.EmptyBitmap(16,16)) ) gridSizer.Add(self.status[-1], 0, wx.ALL|wx.ALIGN_CENTER, 5) self.changeIcon(mn) #TEXT gridSizer.Add(wx.StaticText(self, -1, "Monitor %s" % mn ), 0, wx.ALL|wx.ALIGN_CENTER, 5) #INPUT SOURCE gridSizer.Add(comboFileBrowser(self, wx.ID_ANY, size=(-1,-1), dialogTitle = "Choose an Input video file", startDirectory = options.GetOption("Data_Folder"), value = source, choices=WebcamsList, fileMask = "Video File (*.*)|*.*", browsevalue="Browse for video...", changeCallback = partial(self.onChangeDropDown, [mn, "source"])), 0, wx.ALL|wx.ALIGN_CENTER, 5 ) #MASK FILE gridSizer.Add(comboFileBrowser(self, wx.ID_ANY, size=(-1,-1), dialogTitle = "Choose a Mask file", startDirectory = options.GetOption("Mask_Folder"), value = mf, fileMask = "pySolo mask file (*.msk)|*.msk", browsevalue="Browse for mask...", changeCallback = partial(self.onChangeDropDown, [mn, "mask_file"])), 0, wx.ALL|wx.ALIGN_CENTER, 5 ) #OUTPUT FILE gridSizer.Add(comboFileBrowser(self, wx.ID_ANY, size=(-1,-1), dialogTitle = "Choose the output file", startDirectory = options.GetOption("Data_Folder"), value = md['outputfile'], fileMask = "Output File (*.txt)|*.txt", browsevalue="Browse for output...", changeCallback = partial(self.onChangeDropDown, [mn, "outputfile"])), 0, wx.ALL|wx.ALIGN_CENTER, 5 ) #TRACKTYPE ttcb = wx.ComboBox(self, -1, size=(-1,-1), value=md['track_type'], choices=tracktypes, style=wx.CB_DROPDOWN | wx.CB_READONLY) ttcb.Bind (wx.EVT_COMBOBOX, partial(self.onChangeDropDown, [mn, "track_type"])) gridSizer.Add(ttcb , 0, wx.ALL|wx.ALIGN_CENTER, 5) #RECORD BUTTON self.recordBTNS.append ( wx.ToggleButton(self, wx.ID_ANY, 'Start') ) self.recordBTNS[-1].Bind (wx.EVT_TOGGLEBUTTON, partial( self.onToggleRecording, mn)) gridSizer.Add(self.recordBTNS[-1], 0, wx.ALL|wx.ALIGN_CENTER, 5) #UPTIME self.uptimeTXT.append(wx.TextCtrl(self, value="00:00:00", size=(140,-1))) gridSizer.Add(self.uptimeTXT[-1], 0, wx.ALL|wx.ALIGN_CENTER, 5) #VIEW BUTTON vb = wx.Button(self, wx.ID_ANY, 'View') vb.Bind(wx.EVT_BUTTON, partial( self.onViewMonitor, mn)) gridSizer.Add(vb, 0, wx.ALL|wx.ALIGN_CENTER, 5) btnSizer = wx.BoxSizer(wx.HORIZONTAL) conf_btnSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Configuration'), wx.HORIZONTAL) acq_btnSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, 'Acquisition'), wx.HORIZONTAL) self.saveOptionsBtn = wx.Button(self, wx.ID_ANY, 'Save') self.saveOptionsBtn.Enable(False) self.Bind(wx.EVT_BUTTON, self.onSave, self.saveOptionsBtn) conf_btnSizer.Add (self.saveOptionsBtn, 0, wx.ALL, 5) self.startBtn = wx.Button(self, wx.ID_ANY, 'Start All') self.stopBtn = wx.Button(self, wx.ID_ANY, 'Stop All') self.startBtn.Enable(True) self.stopBtn.Enable(False) self.Bind(wx.EVT_BUTTON, self.onStopAll, self.stopBtn) self.Bind(wx.EVT_BUTTON, self.onStartAll, self.startBtn) acq_btnSizer.Add (self.startBtn, 0, wx.ALL, 5) acq_btnSizer.Add (self.stopBtn, 0, wx.ALL, 5) btnSizer.Add(conf_btnSizer, 0, wx.ALL, 5) btnSizer.Add(acq_btnSizer, 0, wx.ALL, 5) #mainSizer.Add(self.FBconfig, 0, wx.EXPAND|wx.ALL, 5) mainSizer.Add(gridSizer, 1, wx.EXPAND, 0) mainSizer.Add(btnSizer, 0, wx.ALL, 5) mainSizer.Layout() self.SetSizer(mainSizer) self.Refresh()