예제 #1
0
    def loadCSV(self):
        # TODO : restrict to CSV files
        file = str(
            QtGui.QFileDialog.getOpenFileName(self, "Open Segments File", "",
                                              "Segments file (*.csv)"))
        if file == "": return

        segmentNames = []
        self.faceIndexing = []
        try:
            with open(file, 'rb') as raw:
                f = csv.reader(raw)
                for [s, e, name] in f:
                    segmentNames.append((os.path.join(os.path.dirname(file),
                                                      name), int(s), int(e)))
            indexFile = os.path.join(os.path.dirname(file), "indexing.csv")
            if os.path.exists(indexFile):
                with open(indexFile, 'rb') as raw:
                    f = csv.reader(raw)
                    for arr in f:
                        name = arr[0]
                        filename = os.path.join(os.path.dirname(file), arr[1])
                        vals = ast.literal_eval(arr[2])
                        self.faceIndexing.append((name, filename, vals))
        except IOError:
            self.errorBox("Roxana")
            return
        except ValueError:
            self.errorBox("Agnieszka")
            return

        self.fillFaces()
        self.fillList(segmentNames)

        #load segments into the GUI, ignoring start and end frames
        self.segments = SegmentRegister(segmentNames)
        #self.ui.videoBackground.hide()
        self.setControls(True)
        self.updatePreviousNextButton()
        self.load(self.segments.current())
        self.showVideoScreen()
        self.selectListEntry()
예제 #2
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.segments = SegmentRegister([])
        self.basicInfo = None
        self.faceIndexing = []

        QtCore.QObject.connect(self.ui.segmentButton,
                               QtCore.SIGNAL("clicked()"), self.segment)
        QtCore.QObject.connect(self.ui.browseButton,
                               QtCore.SIGNAL("clicked()"), self.browse)
        QtCore.QObject.connect(self.ui.loadButton, QtCore.SIGNAL("clicked()"),
                               self.loadCSV)
        QtCore.QObject.connect(self.ui.saveButton, QtCore.SIGNAL("clicked()"),
                               self.save)
        QtCore.QObject.connect(self.ui.playButton, QtCore.SIGNAL("clicked()"),
                               self.play)
        QtCore.QObject.connect(self.ui.pauseButton, QtCore.SIGNAL("clicked()"),
                               self.ui.videoPlayer.pause)
        QtCore.QObject.connect(self.ui.nextButton, QtCore.SIGNAL("clicked()"),
                               self.next)
        QtCore.QObject.connect(self.ui.previousButton,
                               QtCore.SIGNAL("clicked()"), self.previous)
        QtCore.QObject.connect(self.ui.filePath,
                               QtCore.SIGNAL("returnPressed()"), self.preload)
        QtCore.QObject.connect(self.ui.lastFrameButton,
                               QtCore.SIGNAL("clicked()"), self.setLastFrame)
        QtCore.QObject.connect(self.ui.newButton, QtCore.SIGNAL("clicked()"),
                               self.reset)
        QtCore.QObject.connect(self.ui.playNextButton,
                               QtCore.SIGNAL("clicked()"), self.playNext)
        QtCore.QObject.connect(self.ui.advancedButton,
                               QtCore.SIGNAL("clicked()"), self.toggleAdvanced)
        self.ui.segmentList.doubleClicked.connect(self.selectSegment)
        self.ui.faceList.doubleClicked.connect(self.selectSegmentFromFace)
        self.ui.faceList.setIconSize(QtCore.QSize(100, 100))

        self.advanced = False
        self.reset()
예제 #3
0
    def segment(self):
        """
        Calls the Client class to perform segmenting. Handles bound checking
        errors. Fills in segment register and updates GUI (button activation).
        """
        self.setControls(False)
        self.currSegment = 0

        #Get all the correct options and create a client
        cap = None
        try:
            start = int(self.ui.startFrame.text())
            end = int(self.ui.endFrame.text())
            splitType = self.getSplitType()
            clusterType = self.getClusterType()
            comparisonMethod = self.getComparisonMethod()

            options = {}
            if splitType == SplitType.EVERY_X_SECONDS:
                options["xSeconds"] = int(self.ui.xSecs.value())

            options["clusterThreshold"] = float(
                self.ui.clusterThreshold.value())
            options["k"] = int(self.ui.kValue.value())
            options["cutoff"] = float(self.ui.shiftCutoff.value())
            options["maxIterations"] = int(self.ui.maxIters.value())
            options["segmentLength"] = int(self.ui.segmentLength.value())
            options["audio"] = str(self.ui.filePath.text())
            options["clusterAlgorithm"] = clusterType

            if clusterType == FaceClustering.standardCluster:
                options["comparator"] = comparisonMethod
            else:
                options["comparator"] = FaceClustering.PCAComparator

            cap = Client(str(self.ui.filePath.text()), splitType,
                         lambda x: self.setProgress(x),
                         lambda x: self.setState(x), start, end)
        except IOError:
            return self.errorBox("Jasper")
        except (ValueError, BoundsError):
            return self.errorBox("Ben")

        # create Segmenter object to segment the video
        self.seg = Segmenter()

        # call Client.run, which in turn calls Segmenter.run to perform the segmentation
        segmentNames = cap.run(self.seg,
                               self.ui.highlightFacesOption.isChecked(),
                               "MP42", "mkv", True, options)

        if "clusters" in options:
            self.genIndexing(segmentNames, options["clusters"])
        else:
            self.genIndexing(segmentNames, [])

        self.fillFaces()
        self.fillList(segmentNames)

        #load segments into the GUI, ignoring start and end frames
        self.segments = SegmentRegister(segmentNames)
        #self.ui.videoBackground.hide()
        self.setControls(True)
        self.updatePreviousNextButton()
        self.load(self.segments.current())
        self.showVideoScreen()
        self.selectListEntry()