def onChangeMonitor(self, event): """ FIX THIS this is a mess """ mn = event.GetSelection() + 1 if options.HasMonitor(mn): md = options.GetMonitor(mn) if md['source']: if self.fsPanel.isPlaying: self.fsPanel.Stop() self.fsPanel.setMonitor( pysolovideo.MONITORS[mn] ) self.sourceTXTBOX.SetValue( 'Source: %s' % md['source'] ) self.fsPanel.Play() if md['mask_file']: self.fsPanel.mon.loadROIS(md['mask_file']) self.currentMaskTXT.SetValue(os.path.split(md['mask_file'])[1] or '') else: #sourceType, source, track, mask_file, trackType = [0, '', False, '', 1] self.sourceTXTBOX.SetValue('No Source for this monitor')
def updateThumbnail(self): """ Refreshing thumbnail data """ if options.HasMonitor(self.monitor_number): sourceType, source, track, mask_file, trackType, isSDMonitor = options.GetMonitor( self.monitor_number) else: sourceType, source, track, mask_file, trackType, isSDMonitor = [ 0, '', False, '', 1, False ] if sourceType == 0 and source != '': source = self.WebcamsList[source] self.source = self.thumbnail.source = source self.sourceType = self.thumbnail.sourceType = sourceType self.thumbnail.track = track if self.thumbnail.hasMonitor(): self.thumbnail.mon.isSDMonitor = isSDMonitor #update first static box active = self.thumbnail.hasMonitor() self.applyButton.Enable(active) self.btnPlay.Enable(active) self.btnStop.Enable(active and self.thumbnail.isPlaying) text = os.path.split(str(self.source))[1] or "No Source Selected" self.currentSource.SetValue(text) #update second static box for radio, src in self.controls: src.Enable(False) src.SetValue('') radio, src = self.controls[self.sourceType] radio.SetValue(True) src.Enable(True) src.SetValue(self.source) #update third static box self.activateTracking.SetValue(self.thumbnail.track) self.isSDMonitor.SetValue(isSDMonitor) self.pickMaskBrowser.SetValue(mask_file or '') [self.trackDistanceRadio, self.trackVirtualBM, self.trackPosition][trackType].SetValue(True)
def updateNumCams(self, old): """ Updates the camera combofilebrowser when the number of cameras changes """ WebcamsList = [ 'Camera %02d' % (int(w) + 1) for w in range(self.num_cams) ] i = 11 # Skip the labels, start with first monitor for mn in range(1, self.mon_num + 1): # For each monitor 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']) self.gridSizer.Hide(i) self.gridSizer.Remove(i) # Remove the outdated dropdown menu self.gridSizer.Insert( i, # Insert a new dropdown menu in its place 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) self.gridSizer.Layout() # Show changes on GUI i += 9 # Move to next monitor (gridsizer rows are 9 items wide)
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 drawSingleMonitor(self, mn, WebcamsList, tracktypes): if not options.HasMonitor(mn): options.SetMonitor(mn) 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))) self.gridSizer.Add(self.status[-1], 0, wx.ALL | wx.ALIGN_CENTER, 5) self.changeIcon(mn) #TEXT self.gridSizer.Add( # Monitor number label wx.StaticText(self, -1, "Monitor %s" % mn), 0, wx.ALL | wx.ALIGN_CENTER, 5) self.gridSizer.Add( # Choose video input 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) self.gridSizer.Add( # Choose mask file 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) self.gridSizer.Add( # Choose output file 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"])) self.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)) self.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))) self.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)) self.gridSizer.Add(vb, 0, wx.ALL | wx.ALIGN_CENTER, 5)