예제 #1
0
    def __init__(self, parent, source, resolution, track, track_type,
                 mask_file, output_file, showROIs, showpath, showtime, record):
        wx.Frame.__init__(self, parent)

        self.displayPanel = previewPanel(self,
                                         size=resolution,
                                         keymode=True,
                                         singleFrameMode=True)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.displayPanel)
        #self.setSizer(sizer)

        #self.SetSize((-1, -1))
        self.SetTitle(source)

        monitor = pysolovideo.Monitor()
        monitor.setSource(source, resolution)
        self.displayPanel.setMonitor(monitor)
        self.displayPanel.mon.setTracking(track, track_type, mask_file,
                                          output_file)
        self.displayPanel.mon.isTracking = True
        self.displayPanel.timestamp = showtime

        if record:
            self.displayPanel.mon.saveMovie('video_output.avi',
                                            fps=14,
                                            startOnKey=True)

        self.displayPanel.prinKeyEventsHelp()
        self.displayPanel.Play(showROIs=showROIs)
        self.Show()
 def __init__(self, parent, source, resolution, track, track_type, mask_file, output_file, showROIs, showpath, showtime, record ):
     wx.Frame.__init__(self, parent)
     
    
     self.displayPanel = previewPanel(self, size=resolution, keymode=True, singleFrameMode=True)
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add (self.displayPanel)
     #self.setSizer(sizer)
     
     #self.SetSize((-1, -1))
     self.SetTitle(source)
     
     monitor = pysolovideo.Monitor()
     monitor.setSource(source, resolution)
     self.displayPanel.setMonitor( monitor )
     self.displayPanel.mon.setTracking(track, track_type, mask_file, output_file)
     self.displayPanel.mon.isTracking = True
     self.displayPanel.timestamp = showtime
    
     if record:
         self.displayPanel.mon.saveMovie('video_output.avi', fps=14, startOnKey=True)
     
     self.displayPanel.prinKeyEventsHelp()
     self.displayPanel.Play(showROIs=showROIs)
     self.Show()
예제 #3
0
    def __init__(self, parent, source, resolution, track, track_type, mask_file, outputFile, showROIs, showpath, showtime, record, trackonly ):
        wx.Frame.__init__(self, parent)
        self.displayPanel = previewPanel(self, size=resolution, keymode=True)
        self.SetSize(resolution)

        self.displayPanel.setMonitor(source, resolution)
        self.displayPanel.mon.setTracking(track, track_type, mask_file, outputFile)
        self.displayPanel.timestamp = showtime
       
        if record:
            self.displayPanel.mon.saveMovie('video_output.avi', fps=14, startOnKey=True)
        
        if not trackonly:
            self.displayPanel.prinKeyEventsHelp()
            self.displayPanel.Play(showROIs=showROIs)
            self.Show()
        else:
            print "file: %s" % source
            print "Processing the video without output. This may take sometime..."
            while not self.displayPanel.mon.isLastFrame():
                self.displayPanel.mon.GetImage(timestamp=showtime)
            self.Close()
예제 #4
0
    def __init__(self, parent):
        """
        """
        
        wx.Panel.__init__(self, parent, wx.ID_ANY)

        self.monitor_name = ''
        self.fsPanel = previewPanel(self, size=options.GetOption("Resolution"), showtime=True)
        
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_4 = wx.BoxSizer(wx.VERTICAL)
        
        #Static box1: monitor input
        sb_1 = wx.StaticBox(self, -1, "Select Monitor")#, size=(250,-1))
        sbSizer_1 = wx.StaticBoxSizer (sb_1, wx.VERTICAL)
        self.MonitorList = ['Monitor %s' % (int(m) + 1) for m in range(options.GetOption("Monitors"))]
        self.thumbnailNumber = wx.ComboBox(self, -1, size=(-1,-1) , choices=self.MonitorList, style=wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT)
        self.Bind(wx.EVT_COMBOBOX, self.onChangeMonitor, self.thumbnailNumber)

        self.sourceTXTBOX =  wx.TextCtrl (self, -1, "No monitor selected", style=wx.TE_READONLY)

        sbSizer_1.Add ( self.thumbnailNumber, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
        sbSizer_1.Add ( self.sourceTXTBOX, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5 )

        #Static box2: mask parameters
        sb_2 = wx.StaticBox(self, -1, "Mask Editing")#, size=(250,-1))
        sbSizer_2 = wx.StaticBoxSizer (sb_2, wx.VERTICAL)
        fgSizer_1 = wx.FlexGridSizer( 0, 2, 0, 0 )
        
        self.btnClear = wx.Button( self, wx.ID_ANY, label="Clear All")
        self.Bind(wx.EVT_BUTTON, self.fsPanel.ClearAll, self.btnClear)

        self.btnClearLast = wx.Button( self, wx.ID_ANY, label="Clear selected")
        self.Bind(wx.EVT_BUTTON, self.fsPanel.ClearLast, self.btnClearLast)

        
        self.AFValue = wx.TextCtrl (self, -1, "32")
        self.btnAutoFill = wx.Button( self, wx.ID_ANY, label="Auto Fill")
        self.Bind(wx.EVT_BUTTON, self.onAutoMask, self.btnAutoFill)
        #self.btnAutoFill.Enable(False)

        fgSizer_1.Add (self.btnClear)
        fgSizer_1.Add (self.btnClearLast)
        fgSizer_1.Add (self.AFValue)
        fgSizer_1.Add (self.btnAutoFill)
        
        sbSizer_2.Add (fgSizer_1)


        #Static box3: mask I/O
        sb_3 = wx.StaticBox(self, -1, "Mask File")#, size=(250,-1))
        sbSizer_3 = wx.StaticBoxSizer (sb_3, wx.VERTICAL)

        self.currentMaskTXT = wx.TextCtrl (self, -1, "No Mask Loaded", style=wx.TE_READONLY)

        btnSizer_1 = wx.BoxSizer(wx.HORIZONTAL)
        self.btnLoad = wx.Button( self, wx.ID_ANY, label="Load Mask")
        self.Bind(wx.EVT_BUTTON, self.onLoadMask, self.btnLoad)
        self.btnSave = wx.Button( self, wx.ID_ANY, label="Save Mask")
        self.Bind(wx.EVT_BUTTON, self.onSaveMask, self.btnSave)
        self.btnSaveApply = wx.Button( self, wx.ID_ANY, label="Save and Apply")
        self.Bind(wx.EVT_BUTTON, self.onSaveApply, self.btnSaveApply)
        
        btnSizer_1.Add(self.btnLoad)
        btnSizer_1.Add(self.btnSave)
        btnSizer_1.Add(self.btnSaveApply)

        sbSizer_3.Add ( self.currentMaskTXT, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5 )
        sbSizer_3.Add (btnSizer_1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )

        ##
        
        #Static box4: help
        sb_4 = wx.StaticBox(self, -1, "Help")
        sbSizer_4 = wx.StaticBoxSizer (sb_4, wx.VERTICAL)
        titleFont = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
        instr = [ ('Left mouse button - single click outside ROI', 'Start dragging ROI. ROI will be a perfect rectangle'),
                  ('Left mouse button - single click inside ROI', 'Select ROI. ROI turns red.'),
                  ('Left mouse button - double click', 'Select corner of ROI.\nWill close ROI after fourth selection'),
                  ('Middle mouse button - single click', 'Add currently selected ROI. ROI turns white.'),
                  ('Right mouse button - click', 'Remove selected currently selected ROI'),
                  ('Auto Fill', 'Will fill 32 ROIS (16x2) to fit under the last two\nselected points. To use select first upper left corner,\n then the lower right corner, then use "Auto Fill".')
                  ]
                  
        for title, text in instr:
            t = wx.StaticText(self, -1, title); t.SetFont(titleFont)
            sbSizer_4.Add( t, 0, wx.ALL, 2 )
            sbSizer_4.Add(wx.StaticText(self, -1, text) , 0 , wx.ALL, 2 )
            sbSizer_4.Add ( (wx.StaticLine(self)), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5 )
        
        sizer_4.Add(sbSizer_1, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5 )
        sizer_4.Add(sbSizer_2, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5 )
        sizer_4.Add(sbSizer_3, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5 )
        sizer_4.Add(sbSizer_4, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP|wx.EXPAND, 5 )

        
        sizer_3.Add(self.fsPanel, 0, wx.LEFT|wx.TOP, 20 )
        sizer_3.Add(sizer_4, 0, wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT|wx.TOP, 5 )

        sizer_1.Add(sizer_3, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )
        sizer_1.Add(sizer_2, 0, wx.ALIGN_CENTRE|wx.LEFT|wx.RIGHT|wx.TOP, 5 )

        
        self.SetSizer(sizer_1)
        print wx.Window.FindFocus()
        
        self.Bind( wx.EVT_CHAR, self.fsPanel.onKeyPressed )
예제 #5
0
    def __init__(self, parent):

        self.panel = wx.Panel.__init__(self, parent)
        self.fsPanel = previewPanel(self,
                                    size=options.GetOption("Resolution"),
                                    showtime=True)

        # %%%%%%%%%%%%%%%%%% sizer_Left: Monitor Display
        #  Monitor Selection on top
        # Give title to the monitor selection combobox
        title_1 = wx.StaticText(self, wx.ID_ANY, 'Select Monitor')
        # create select monitor combobox on top of left column
        MonitorList = [
            'Monitor %s' % (int(m) + 1)
            for m in range(options.GetOption("Monitors"))
        ]  # not reflecting number of monitors in configuration
        thumbnailNumber = wx.ComboBox(self,
                                      wx.ID_ANY,
                                      choices=MonitorList,
                                      style=wx.CB_DROPDOWN | wx.CB_READONLY
                                      | wx.CB_SORT)
        self.Bind(wx.EVT_COMBOBOX, self.onChangeMonitor, thumbnailNumber)

        #   sizer for left side, top row control buttons
        sizer_top_Left = wx.BoxSizer(wx.HORIZONTAL)
        sizer_top_Left.Add(title_1, 0, wx.ALL, 5)  # menu title
        sizer_top_Left.Add(thumbnailNumber, 0, wx.ALL, 5)  # menu

        # %%  Movie Display on bottom
        videoWarper = wx.StaticBox(self,
                                   label='Movie Label',
                                   size=(x / 2, y * 2 / 3))
        videoBoxSizer = wx.StaticBoxSizer(videoWarper, wx.VERTICAL)
        videoFrame = wx.Panel(self, wx.ID_ANY, size=(640, 480))
        #        cap = cv2.VideoCapture('fly_movie.avi')                                # not working on thinkpad computer
        #        showCap = ShowCapture(videoFrame, cap)                                 # not working on thinkpad computer
        videoBoxSizer.Add(videoFrame, 0)

        #  Sizer for left side of display
        sizer_Left = wx.BoxSizer(wx.VERTICAL)
        sizer_Left.Add(sizer_top_Left, 0, wx.ALL, 5)  # monitor combobox
        sizer_Left.Add(videoBoxSizer, 0, wx.ALL, 5)  # movie

        # %%%%%%%%%%%%%%%%%%  sizer_Right:  Mask Editing
        #     Section Title
        mask_editing = wx.StaticText(self, wx.ID_ANY, 'Mask Editing')

        #      top row is single item, no sizer needed
        #
        # %% Clear Buttons
        btnClearAll = wx.Button(self, wx.ID_ANY, label="Clear All")
        #        self.Bind(wx.EVT_BUTTON, self.fsPanel.ClearAll, self.btnClearAll)
        #
        btnClearSelected = wx.Button(self, wx.ID_ANY, label="Clear Selected")
        #        self.Bind(wx.EVT_BUTTON, self.fsPanel.ClearLast, self.btnClearSelected)
        #
        #  sizer for clear buttons on right side of display
        sizer_ClrBtns_Right = wx.BoxSizer(wx.HORIZONTAL)
        sizer_ClrBtns_Right.Add(btnClearSelected, 0, wx.ALL,
                                5)  # clear selected
        sizer_ClrBtns_Right.Add(btnClearAll, 0, wx.ALL, 5)  # clear all

        # %%   AutoFill Value
        AFValue = wx.TextCtrl(self, -1, "32")  #  make this variable?

        btnAutoFill = wx.Button(self, wx.ID_ANY, label="Auto Fill")
        #        self.Bind(wx.EVT_BUTTON, self.onAutoMask, self.btnAutoFill)
        #        self.btnAutoFill.Enable(False)

        #  sizer for AutoFill controls
        sizer_Autofill_Right = wx.BoxSizer(wx.HORIZONTAL)
        sizer_Autofill_Right.Add(btnAutoFill, 0, wx.ALL, 5)  # Autofill
        sizer_Autofill_Right.Add(AFValue, 0, wx.ALL, 5)  # AF Value

        # %%  Right Side, Mask selection controls
        #   Mask Title
        Mask_File_Title = wx.StaticText(self, wx.ID_ANY, "Curent Mask")
        self.currentMaskTXT = wx.TextCtrl(self,
                                          wx.ID_ANY,
                                          value='No Mask Selected',
                                          size=(x / 4, 20))
        #                                     style=wx.TE_READONLY)                     #  get the current mask text for this
        #  sizer for current mask
        sizer_currmsk_Right = wx.BoxSizer(wx.HORIZONTAL)  # button section
        sizer_currmsk_Right.Add(Mask_File_Title, 0, wx.ALL, 5)  # title
        sizer_currmsk_Right.Add(self.currentMaskTXT, 0, wx.ALL, 5)  # title

        # %%
        #   Mask Buttons
        btnLoad = wx.Button(self, wx.ID_ANY, label="Load Mask")
        self.Bind(wx.EVT_BUTTON, self.onLoadMask, btnLoad)

        btnSave = wx.Button(self, wx.ID_ANY, label="Save Mask")
        self.Bind(wx.EVT_BUTTON, self.onSaveMask, btnSave)

        btnSaveApply = wx.Button(self, wx.ID_ANY, label="Save + Apply")
        #        self.Bind(wx.EVT_BUTTON, self.onSaveApply, self.btnSaveApply)

        #  sizer for mask buttons
        sizer_maskIO_Right = wx.BoxSizer(wx.HORIZONTAL)  # button section
        sizer_maskIO_Right.Add(btnLoad, 0, wx.ALL, 5)  # load mask btn
        sizer_maskIO_Right.Add(btnSave, 0, wx.ALL, 5)  # Save mask btn
        sizer_maskIO_Right.Add(btnSaveApply, 0, wx.ALL, 5)  # Apply mask btn

        # %% Mouse Instructions
        #   Section Title
        Controls_Title = wx.StaticText(self, wx.ID_ANY, "Mouse Controls")
        #        titleFont = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
        instr = [
            ('   Left mouse button - single click outside ROI'),
            ('        Start dragging ROI. ROI will be a perfect rectangle'),
            ('   Left mouse button - single click inside ROI'),
            ('        Select ROI. ROI turns red.'),
            ('   Left mouse button - double click'),
            ('        Select corner of ROI.  Will close ROI after fourth selection'
             ), ('   Middle mouse button - single click'),
            ('        Add currently selected ROI. ROI turns white.'),
            ('   Right mouse button - click'),
            ('        Remove selected currently selected ROI'),
            ('   Auto Fill'),
            ('        Will fill 32 ROIS (16x2) to fit under the last two'),
            ('        selected points. To use select first upper left corner,'
             ), ('        then the lower right corner, then use "Auto Fill".')
        ]

        #
        #   sizer for instructions
        sizer_instr_Right = wx.BoxSizer(wx.VERTICAL)  # Help Section
        sizer_instr_Right.Add(Controls_Title, 0, wx.ALL, 5)  # title
        for txtline in instr:
            instr_line = wx.StaticText(self, wx.ID_ANY,
                                       txtline)  #; t.SetFont(titleFont)
            sizer_instr_Right.Add(instr_line, 0, wx.ALL, 1)  # next instrctn

# %%  sizer for right side of display
        sizer_Right = wx.BoxSizer(wx.VERTICAL)
        sizer_Right.Add(mask_editing, 0, wx.ALL, 5)  # section title
        sizer_Right.Add(sizer_ClrBtns_Right, 0, wx.ALL, 5)  # Mask Buttons
        sizer_Right.Add(sizer_currmsk_Right, 0, wx.ALL, 5)  # Mask Selection
        sizer_Right.Add(sizer_maskIO_Right, 0, wx.ALL, 5)  # Mask Selection
        sizer_Right.Add(sizer_Autofill_Right, 0, wx.ALL, 5)  # AutoFill
        sizer_Right.Add(sizer_instr_Right, 0, wx.ALL, 5)  # Mouse Instruction

        # %%  Full Panel
        sizer_All = wx.BoxSizer(wx.HORIZONTAL)  # put everything together
        sizer_All.Add(sizer_Left, 0, wx.ALL, 5)
        sizer_All.Add(sizer_Right, 0, wx.ALL, 5)

        self.SetSizer(sizer_All)  # displays the grid