コード例 #1
0
    def saveTest():
        def startDetector():
            detector.initMOG()
            detector.computeAll()
            tracker.trackAll(detector.detections)

        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        detector = Detector(playback_manager)
        tracker = Tracker(detector)
        fish_manager = FishManager(playback_manager, tracker)

        save_manager = SaveManager(playback_manager, detector, tracker,
                                   fish_manager)

        fish_manager.updateContentsSignal.connect(
            lambda: save_manager.saveFile(path, True))

        playback_manager.openTestFile()
        detector._show_detections = True
        playback_manager.mapping_done.connect(startDetector)

        main_window.show()
        sys.exit(app.exec_())
コード例 #2
0
    def loadTest():
        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        fish_manager = FishManager(None, None)

        file = playback_manager.selectLoadFile()
        fish_manager.loadFromFile(file)
        fish_list = FishList(fish_manager, playback_manager)

        main_window.setCentralWidget(fish_list)
        main_window.show()
        sys.exit(app.exec_())
コード例 #3
0
    def uiTest():
        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        # playback_manager.openTestFile()
        fish_manager = FishManager(None, None)
        fish_manager.testPopulate(500)
        #info_w = InfoWidget(playback_manager, fish_manager)
        fish_list = FishList(fish_manager, playback_manager)

        main_window.setCentralWidget(fish_list)
        main_window.show()
        sys.exit(app.exec_())
コード例 #4
0
    def loadTest():
        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        detector = Detector(playback_manager)
        tracker = Tracker(detector)
        fish_manager = FishManager(playback_manager, tracker)

        save_manager = SaveManager(playback_manager, detector, tracker,
                                   fish_manager)
        save_manager.loadFile(path)

        main_window.show()
        sys.exit(app.exec_())
コード例 #5
0
ファイル: detection_list.py プロジェクト: MiG-Ui/LUKE
    def defaultTest():
        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        playback_manager.fps = 1
        playback_manager.openTestFile()

        detector = Detector(playback_manager)
        detector.mog_parameters.nof_bg_frames = 100

        playback_manager.mapping_done.connect(
            lambda: startDetector(playback_manager, detector))
        playback_manager.frame_available.connect(
            lambda t: handleFrame(detector, t))

        data_model = DetectionDataModel(detector)
        detection_list = DetectionList(data_model)
        main_window.setCentralWidget(detection_list)
        main_window.show()
        sys.exit(app.exec_())
コード例 #6
0
ファイル: tracker.py プロジェクト: MiG-Ui/LUKE
    def playbackTest():
        """
        Test code to assure tracker works with detector.
        """
        def forwardImage(tuple):
            ind, frame = tuple
            detections = detector.getDetection(ind)

            image = cv2.applyColorMap(frame, cv2.COLORMAP_OCEAN)
            image = tracker.visualize(image, ind)

            figure.displayImage((ind, image))

        def startDetector():
            detector.initMOG()
            detector.computeAll()
            tracker.trackAll(detector.detections)
            playback_manager.play()

        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        detector = Detector(playback_manager)
        tracker = Tracker(detector)

        playback_manager.fps = 10
        playback_manager.openTestFile()
        playback_manager.frame_available.connect(forwardImage)
        detector.mog_parameters.nof_bg_frames = 500
        detector._show_detections = True
        playback_manager.mapping_done.connect(startDetector)

        figure = TestFigure(playback_manager.togglePlay)
        main_window.setCentralWidget(figure)

        LogObject().print(detector.parameters)
        LogObject().print(detector.parameters.mog_parameters)
        LogObject().print(tracker.parameters)

        main_window.show()
        sys.exit(app.exec_())
コード例 #7
0
def launch_ui():
    app = QtWidgets.QApplication(sys.argv)
    main_window = MainWindow()  #QtWidgets.QMainWindow()
    playback_manager = PlaybackManager(app, main_window)
    detector = Detector(playback_manager)
    tracker = Tracker(detector)
    fish_manager = FishManager(playback_manager, tracker)
    save_manager = SaveManager(playback_manager, detector, tracker,
                               fish_manager)

    detector.all_computed_event.append(playback_manager.refreshFrame)
    tracker.all_computed_signal.connect(playback_manager.refreshFrame)
    playback_manager.mapping_done.connect(
        lambda: playback_manager.runInThread(lambda: detector.initMOG(False)))
    playback_manager.frame_available_early.connect(detector.compute_from_event)
    playback_manager.file_opened.connect(lambda x: fish_manager.clear())
    playback_manager.file_opened.connect(lambda x: detector.clearDetections())

    ui_manager = UIManager(main_window, playback_manager, detector, tracker,
                           fish_manager, save_manager)
    sys.exit(app.exec_())
コード例 #8
0
    def dataTest():
        def startDetector():
            detector.initMOG()
            detector.computeAll()
            tracker.trackAll(detector.detections)

        app = QtWidgets.QApplication(sys.argv)
        main_window = Window()
        playback_manager = PlaybackManager(app, main_window)
        detector = Detector(playback_manager)
        tracker = Tracker(detector)
        fish_manager = FishManager(playback_manager, tracker)
        fish_list = FishList(fish_manager, playback_manager)

        playback_manager.openTestFile()
        detector.mog_parameters.nof_bg_frames = 500
        detector._show_detections = True
        playback_manager.mapping_done.connect(startDetector)

        main_window.setCentralWidget(fish_list)
        main_window.show()
        sys.exit(app.exec_())
コード例 #9
0
ファイル: track_process.py プロジェクト: MiG-Ui/LUKE
    def __init__(self,
                 app,
                 display,
                 file,
                 save_directory,
                 connection=None,
                 testFile=False):
        super().__init__()
        self.app = app
        self.display = display
        self.figure = None
        self.file = file
        self.save_directory = os.path.abspath(save_directory)
        self.connection = connection
        self.testFile = testFile
        self.alive = True

        self.save_detections = True
        self.save_tracks = True

        if display:
            self.main_window = QtWidgets.QMainWindow()
        else:
            self.main_window = None

        self.playback_manager = PlaybackManager(self.app, self.main_window)

        self.detector = Detector(self.playback_manager)
        self.tracker = Tracker(self.detector)
        self.fish_manager = FishManager(self.playback_manager, self.tracker)
        self.playback_manager.fps = 100

        self.playback_manager.runInThread(self.listenConnection)

        log = LogObject()
        log.disconnectDefault()
        #log.connect(writeToFile)
        log.connect(self.writeToConnection)
        log.print("Process created for file: ", self.file)
コード例 #10
0
ファイル: detection_list.py プロジェクト: MiG-Ui/LUKE
    def loadTest():
        app = QtWidgets.QApplication(sys.argv)
        main_window = QtWidgets.QMainWindow()
        playback_manager = PlaybackManager(app, main_window)
        playback_manager.fps = 1

        detector = Detector(playback_manager)
        detector.mog_parameters.nof_bg_frames = 100

        file = playback_manager.selectLoadFile()

        playback_manager.openTestFile()
        playback_manager.mapping_done.connect(
            lambda: startDetector(playback_manager, detector))

        detector.loadDetectionsFromFile(file)
        LogObject().print([d for d in detector.detections if d is not None])

        data_model = DetectionDataModel(detector)
        detection_list = DetectionList(data_model)
        main_window.setCentralWidget(detection_list)
        main_window.show()
        sys.exit(app.exec_())
コード例 #11
0
ファイル: detector.py プロジェクト: MiG-Ui/LUKE
def playbackTest():
    def forwardImage(tuple):
        ind, frame = tuple
        # detections = detector.compute(ind, frame)
        detections = detector.getCurrentDetection()

        image = cv2.applyColorMap(frame, cv2.COLORMAP_OCEAN)
        image = detector.overlayDetections(image, detections)

        figure.displayImage((ind, image))

    def startDetector():
        detector.initMOG()
        playback_manager.play()

    #LogObject().disconnectDefault()
    #LogObject().connect(LogObject().defaultPrint)

    app = QtWidgets.QApplication(sys.argv)
    main_window = QtWidgets.QMainWindow()
    playback_manager = PlaybackManager(app, main_window)
    playback_manager.fps = 10
    playback_manager.openTestFile()
    playback_manager.frame_available.connect(forwardImage)
    detector = Detector(playback_manager)
    detector.mog_parameters.nof_bg_frames = 100
    detector._show_detections = True
    detector._show_echogram_detections = True
    playback_manager.mapping_done.connect(startDetector)
    playback_manager.frame_available_early.connect(detector.compute_from_event)

    figure = TestFigure(playback_manager.togglePlay)
    main_window.setCentralWidget(figure)

    main_window.show()
    sys.exit(app.exec_())
コード例 #12
0
ファイル: echogram_widget.py プロジェクト: MiG-Ui/LUKE
            self.vertical_detections = [
                [d.center[0] for d in dets
                 if d.center is not None] if dets is not None else []
                for dets in self.detections
            ]

        def parametersDirty(self):
            return False

    class TestFishManager(QtCore.QAbstractTableModel):

        updateContentsSignal = QtCore.pyqtSignal()

        def __init__(self):
            super().__init__()
            self.show_fish = True
            self.show_echogram_fish = True

    app = QtWidgets.QApplication(sys.argv)
    main_window = QtWidgets.QMainWindow()
    playback_manager = PlaybackManager(app, main_window)
    playback_manager.openTestFile()
    detector = TestDetector(playback_manager.getFrameCount(),
                            playback_manager.sonar.samplesPerBeam)
    fish_manager = TestFishManager()
    echogram = EchogramViewer(playback_manager, detector, fish_manager)
    echogram.onFileOpen(playback_manager.sonar)
    main_window.setCentralWidget(echogram)
    main_window.show()
    main_window.resize(900, 300)
    sys.exit(app.exec_())
コード例 #13
0
ファイル: batch_dialog.py プロジェクト: MiG-Ui/LUKE

class EmptyOrIntValidator(QtGui.QIntValidator):
    def __init__(self, *args, **kwargs):
        super(EmptyOrIntValidator, self).__init__(*args, **kwargs)

    def validate(self, text, pos):
        state, text, pos = super(EmptyOrIntValidator, self).validate(text, pos)
            
        if state != QtGui.QValidator.Acceptable and text == "":
            state = QtGui.QValidator.Acceptable
        return state, text, pos


if __name__ == "__main__":
    def showDialog():
        dialog = BatchDialog(playback_manager)
        dialog.exec_()

    app = QtWidgets.QApplication(sys.argv)
    w = QtWidgets.QMainWindow()
    playback_manager = PlaybackManager(app, w)

    b = QtWidgets.QPushButton(w)
    b.setText("Show dialog")
    b.move(50,50)
    b.clicked.connect(showDialog)
    w.setWindowTitle("BatcDialog test")
    w.show()
    showDialog()
    sys.exit(app.exec_())