Ejemplo n.º 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()
Ejemplo n.º 2
0
    def setMonitor_old(self, camera, resolution=None):
        """
        """

        if not resolution: resolution = self.size

        self.camera = camera
        self.resolution = resolution

        if not self.mon:
            self.mon = pysolovideo.Monitor()
            self.mon.setSource(self.camera, self.resolution)

        frame = self.mon.GetImage(drawROIs=self.drawROI,
                                  selection=self.selection,
                                  crosses=self.polyPoints,
                                  timestamp=self.timestamp)

        self.bmp = wx.BitmapFromBuffer(self.size[0], self.size[1], frame)

        self.Bind(wx.EVT_PAINT, self.onPaint)
        self.playTimer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onNextFrame)

        if self.keymode:
            self.Bind(wx.EVT_CHAR, self.onKeyPressed)
            self.SetFocus()
Ejemplo n.º 3
0
    def __init__(self,
                 source,
                 resolution=None,
                 window_title='video',
                 track_type=None,
                 mask_file=None,
                 output_file=None,
                 showROI=False,
                 showpath=False,
                 showtime=False):
        """
        """

        self.title = window_title
        self.resolution = resolution
        self.showROI = showROI
        self.timestamp = showtime
        self.showpath = showpath
        track = (track_type > -1)

        self.mon = pysolovideo.Monitor()
        self.mon.setSource(source, resolution)
        self.mon.setTracking(track, track_type, mask_file, output_file)

        cv2.namedWindow(self.title, cv2.CV_WINDOW_AUTOSIZE)
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    def __init__(self, source, resolution=None):
        """
        """

        self.resolution = resolution

        self.mon = pysolovideo.Monitor()
        self.mon.setSource(source, resolution)
Ejemplo n.º 6
0
    elif options.source:

        resolution = (800, 600)
        source = options.source  # integer or filename or dirname
        track = options.mask_file and options.track_type
        mask_file = options.mask_file or splitext(options.source)[0] + '.msk'
        track_type = options.track_type
        output_file = options.output_file or splitext(
            options.source)[0] + '.txt'

    else:
        parser.print_help()

    if options.source and options.printinfo:
        m = pysolovideo.Monitor()
        m.setSource(source, resolution)
        print m.debug_info
        exit()

    if options.snapshot:
        m = pysolovideo.Monitor()
        m.setSource(source, resolution)
        filename = "%s.jpg" % source
        m.saveSnapshot(filename)

    elif options.use_cv:
        c = cvPanel(source, resolution, str(source), track_type, mask_file,
                    output_file, options.showROIs, options.showpath,
                    options.showtime)
        c.mon.isTracking = True