Пример #1
0
    def __write_settings(self):
        """
        Zapisz wartości z widgetów
        """

        Configuration.distance_border1(self.border1_adjustment.get_value())
        Configuration.distance_border2(self.border2_adjustment.get_value())
        Configuration.meters_length(
            self.meters_length_spin_adjustment.get_value())
        Configuration.color_number(
            self.color_number_spin_adjustment.get_value())
        Configuration.horizontal_border(
            self.horizontal_border_spin_adjustment.get_value())
        Configuration.vertical_border(
            self.vertical_border_spin_adjustment.get_value())
        Configuration.pixel_limit(self.pixel_limit_spin_adjustment.get_value())
        Configuration.distance_from_border(
            self.distance_from_border_spin_adjustment.get_value())

        Configuration.draw_detection_region(
            self.draw_detection_region_check.get_active())
        Configuration.draw_speed_region(
            self.draw_speed_region_check.get_active())
        Configuration.draw_cars(self.draw_cars_check.get_active())
        Configuration.draw_conturs(self.draw_conturs_check.get_active())
        Configuration.draw_speed_info(self.draw_speed_info_check.get_active())
        Configuration.draw_size_info(self.draw_size_info_check.get_active())
        Configuration.draw_color_bar(self.draw_color_bar_check.get_active())

        Configuration.save_config()
Пример #2
0
    def __load_settings(self):
        """
        Wczytaj obecną konfigurację znajdującą się config.json do widgetów okna.
        """

        self.border1_adjustment.set_value(Configuration.distance_border1())
        self.border2_adjustment.set_value(Configuration.distance_border2())
        self.meters_length_spin_adjustment.set_value(
            Configuration.meters_length())
        self.color_number_spin_adjustment.set_value(
            Configuration.color_number())
        self.horizontal_border_spin_adjustment.set_value(
            Configuration.horizontal_border())
        self.vertical_border_spin_adjustment.set_value(
            Configuration.vertical_border())
        self.pixel_limit_spin_adjustment.set_value(Configuration.pixel_limit())
        self.distance_from_border_spin_adjustment.set_value(
            Configuration.distance_from_border())

        self.draw_detection_region_check.set_active(
            Configuration.draw_detection_region())
        self.draw_speed_region_check.set_active(
            Configuration.draw_speed_region())
        self.draw_cars_check.set_active(Configuration.draw_cars())
        self.draw_conturs_check.set_active(Configuration.draw_conturs())
        self.draw_speed_info_check.set_active(Configuration.draw_speed_info())
        self.draw_size_info_check.set_active(Configuration.draw_size_info())
        self.draw_color_bar_check.set_active(Configuration.draw_color_bar())
Пример #3
0
    def __write_settings(self):
        """
        Zapisz wartości z widgetów
        """

        Configuration.distance_border1(self.border1_adjustment.get_value())
        Configuration.distance_border2(self.border2_adjustment.get_value())
        Configuration.meters_length(self.meters_length_spin_adjustment.get_value())
        Configuration.color_number(self.color_number_spin_adjustment.get_value())
        Configuration.horizontal_border(self.horizontal_border_spin_adjustment.get_value())
        Configuration.vertical_border(self.vertical_border_spin_adjustment.get_value())
        Configuration.pixel_limit(self.pixel_limit_spin_adjustment.get_value())
        Configuration.distance_from_border(self.distance_from_border_spin_adjustment.get_value())

        Configuration.draw_detection_region(self.draw_detection_region_check.get_active())
        Configuration.draw_speed_region(self.draw_speed_region_check.get_active())
        Configuration.draw_cars(self.draw_cars_check.get_active())
        Configuration.draw_conturs(self.draw_conturs_check.get_active())
        Configuration.draw_speed_info(self.draw_speed_info_check.get_active())
        Configuration.draw_size_info(self.draw_size_info_check.get_active())
        Configuration.draw_color_bar(self.draw_color_bar_check.get_active())

        Configuration.save_config()
Пример #4
0
    def __load_settings(self):
        """
        Wczytaj obecną konfigurację znajdującą się config.json do widgetów okna.
        """

        self.border1_adjustment.set_value(Configuration.distance_border1())
        self.border2_adjustment.set_value(Configuration.distance_border2())
        self.meters_length_spin_adjustment.set_value(Configuration.meters_length())
        self.color_number_spin_adjustment.set_value(Configuration.color_number())
        self.horizontal_border_spin_adjustment.set_value(Configuration.horizontal_border())
        self.vertical_border_spin_adjustment.set_value(Configuration.vertical_border())
        self.pixel_limit_spin_adjustment.set_value(Configuration.pixel_limit())
        self.distance_from_border_spin_adjustment.set_value(Configuration.distance_from_border())

        self.draw_detection_region_check.set_active(Configuration.draw_detection_region())
        self.draw_speed_region_check.set_active(Configuration.draw_speed_region())
        self.draw_cars_check.set_active(Configuration.draw_cars())
        self.draw_conturs_check.set_active(Configuration.draw_conturs())
        self.draw_speed_info_check.set_active(Configuration.draw_speed_info())
        self.draw_size_info_check.set_active(Configuration.draw_size_info())
        self.draw_color_bar_check.set_active(Configuration.draw_color_bar())
Пример #5
0
    def perform(frame: Frame, database, img_saver, run_classyfication=True):
        """
        Dokonuje przetwarzania ramki obrazu przez algorytm.

        :param frame: Ramka obrazu.
        :param database: Baza danych do zapisywania parametrów.
        :param img_saver: Obiekt zapisyjący pliki obrazów.
        :return: Przetworzona ramka.
        """

        vehicles, mask = Detector.find_vehicles(frame)
        objects = Follower.update(vehicles, frame, mask)

        records = []

        if run_classyfication:
            if objects is not None:
                for obj in objects:
                    record = Classyfication.perform(obj, Algorithm.file)
                    records.append(record)
                    if database is not None:
                        database.write(record, Algorithm.file)
                    if img_saver is not None:
                        img_saver.write(record, Algorithm.file)

        mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR)

        # Rysowanie pojazdów.
        if Configuration.draw_cars():
            frame, mask = Detector.draw_vehicles(frame, mask, vehicles)

        # Rysowanie obszaru wykrywania.
        if Configuration.draw_detection_region():
            frame, mask = Detector.draw_detection_region(frame, mask)

        # Rysowanie obszaru pomiaru prędkości
        if Configuration.draw_speed_region():
            frame = Classyfication.draw_speed_region(frame)

        return frame, mask, records