Ejemplo n.º 1
0
    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_())
Ejemplo n.º 2
0
    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_())
Ejemplo n.º 3
0
    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_())
Ejemplo n.º 4
0
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_())
Ejemplo n.º 5
0
import sys
import cv2
from PyQt5 import QtCore, QtGui, QtWidgets
from playback_manager import PlaybackManager

# Save frames using playback_manager


def saveImage(tuple):
    ind, frame = tuple
    print("ASD")
    cv2.imwrite("out/frame_{:06}.png".format(ind), frame)


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    main_window = QtWidgets.QMainWindow()
    playback_manager = PlaybackManager(app, main_window)
    playback_manager.fps = 1000
    playback_manager.openTestFile()

    playback_manager.playback_thread.signals.mapping_done_signal.connect(
        lambda: playback_manager.play())
    playback_manager.frame_available.append(saveImage)

    main_window.show()
    sys.exit(app.exec_())
    #main()